Solved

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

Posted on 2001-06-25
4
169 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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