Solved

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

Posted on 2001-06-25
4
170 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tidtcpserver connection lost handle 2 111
Delphi: barcode reading on android platform 1 77
Browsing a TTreeView in Delphi 5 32
TlistView is Really heavy on Android 3 22
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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