Form.Color := a JPEG pixel

I am using Delphi 1 and 3 and I would like to use a GIF or JPEG image placed on a form for a "splash" screen.  I want to have the background color of the GIF or JPEG match the same color as the form's color.   Since Delphi 1 and 3 do not support GIF, and Delphi 3 supports only JPEG and BMP, could I instead try to change the form's color to match the bitmap background?

If so, how would I do that (code example)?

One would need to fetch a pixel color (let's assume is at the bottom left corner of the JPEG) and then change the form's color to match that pixel.

How can I do this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi Monroe,

If a understood you want to peek the color of a pixel (in JPEG or BMP) and make you window the same color, so you can try this:

procedure TfrmSplash.FormCreate(Sender: TObject);
  Color := Image1.Canvas.Pixels[0,0];

Where Image1 contains a JPEG or a BMP.

It will take the top left corner, to take de bottom left use:

procedure TfrmSplash.FormCreate(Sender: TObject);
  Color := Image1.Canvas.Pixels[0,Image1.Height];

Hope that you enjoy!


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Monroe406Author Commented:
A few problems...  The following should be changed from...

Color := Image1.Canvas.Pixels[0,Image1.Height];

Image.Height-1 ?


The code works sometimes.  For example, create a bitmap with the following RGB values:

R 198
G 195
B 198

Then create a form in Delphi 3, and place the bitmap in a TImage.  Then try your code above.   My eye can see that the form's color does not match the TImage.  It appears that the form's color is 192,192,192 when the bitmap is 198,195,198.

Is there a reason why this gray color refuses to be matched?
Monroe406Author Commented:
I meant...

Image1.Height-1 ?
Sorry about de Height - 1... I just have tested for [0,0]

Well, I saw the problem (and it's big, I could see a big diferent colors!!)

But, if you look well, the form have the correct color, the bitmap isn't displayed with the correct color.

I used R198,G195,B198; R192,G198,B192; and some others and i could see that the bitmap appears equal, but the form has the correct color...

I don't know what is the problem...

By the way, if you use:
  Color := Image1.Canvas.Pixels[0,Image1.Height-1]+$00050505;
you can't see the diferent colors (i tested a lot of them).

Please, try again.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Graphics Software

From novice to tech pro — start learning today.