Solved

rgb values change randomly?! TImage?! TBitmap?!

Posted on 2001-06-25
4
172 Views
Last Modified: 2010-04-06
hi,

i'm making a simple colouring program. the program uses a colorbar i made myself. the colorbar consists of 39 rgb colors.

i've filled a simple black & white picture with some colors (using floodfill). now comes the trickiest part..
i've loaded the original black and white picture in a TImage(image1). and i've loaded the painted picture in another TImage(image2). Now, when i try to color the original picture, my program checks if the color i'm using is the same as the color i used before (and that is now on image2).

i'm using canvas.pixels[x,y] to determine to color of the pixel at [x,y] on image2 and i compare it with the current brush color i'm about to use.

in some cases the colors match and that's, cuz that's what i want. but in a lot of cases the colors differ a little. e.g. color about to be used on image1 = rgb(130,189,140) while the original color(image2) = rgb(130,187,139). this doesnt match, thus is wrong.

the essence of the program is, that a color can only be used when it matches. remember i'm only using the 39 colors.

it's very frustating...

thanks in advance
0
Comment
Question by:brutebass
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 100 total points
ID: 6224246
What pixel format are you using? Try setting the pixel format for your two images to be 24 bit:

Image1.Picture.Bitmap.PixelFormat := pf24Bit;

If you're using a 256 colour bitmap or your screen depth isn'y 24 bit then WIndows will either dither the colour (not likely) or go for a close approximation, and it's this that's causing your colour values to differ slightly

The Neil =:)
0
 

Author Comment

by:brutebass
ID: 6224280
both images are already 24bit images. and the timage controls are already set to pf24bit. didnt fix my problem...
0
 

Author Comment

by:brutebass
ID: 6224313
it did fix my problem..hehe ... forgot one thing to test...
thanks man!
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 6224546
Anytime

The Neil =:)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question