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?

[Webinar] Streamline your web hosting managementRegister Today

fulvio_brasilConnect With a Mentor Commented:
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!

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.


All Courses

From novice to tech pro — start learning today.