Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now