Solved

Find background color

Posted on 1998-12-04
18
264 Views
Last Modified: 2010-04-04
Hi,
how can I get the background color of an image in TImage component?

Thank's
0
Comment
Question by:anton_as
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 3
18 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1349251
There isn't actually a background color for TImage components. You can get a colour of a specific pixel using the pixels property of the canvas property of the TImage component. So if you know a specific pixel or area of pixels will be representative of the background colour you could determine it by looking at them.

Cheers,

Raymond.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349252
There IS a specific pixel!
If your image is set to "image.bitmap.transparentMode=tmAuto", the following pixel determins the transparent color: "image.bitmap.canvas.pixels[0,image.bitmap.height]"
If your image is set to "image.bitmap.transparentMode=tmFixed", the property "image.bitmap.transparentColor" determines the transparent color.
If you use Delphi2, I think, there's no transparentMode nor a transparentColor. There the transparent color is always determined by the left-bottom pixel.

All what I said refers to bitmap. Of course an image could be an icon or a metafile, too. If it is an icon, there's no transparent color. The icon has a real mask.
Can't say anything about metafiles.

If you like my answer, I would really like to get the points for it. Sorry rwilson...    :-)

Regards, Madshi.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1349253
Ahem.

Madshi, anton_as said background colour not transparent colour!!! :-)

Cheers,

Raymond.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Madshi
ID: 1349254
Raymond,

that's right. But I think he means the transparent color. What else could he mean?

Regards, Madshi.
0
 

Author Comment

by:anton_as
ID: 1349255
Sorry, it took so long to post this comment. It's been a busy day for me.
Raymond and Madshi,
my purpose of finding the background is to be able to make the image transparent. Because i think sometimes Delphi's taking the wrong color, so the image become damaged.
To Madshi, are you sure by setting transparent mode to tmFixed we'll get the right background color? Because i'm sure that i can't use the auto mode, since the object of the image may reside in [0,height] position.

Thank's
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349256
Anton_as,

just set the transparent color (e.g. "transparentColor:=clWhite"). I think this will set the transparent mode to tmFix automatically. And - I think that should solve your problem. Of course you have to know which color you want to be transparent... Is that a problem? If yes, please tell me more about for what you need it.

Regards, Madshi.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1349257
Anton - it looks as though Madshi has hit the mail on the head - give him the points!

Cheers,

Raymond.

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349258
Thanx Raymond. That's fair...   :-)
0
 

Author Comment

by:anton_as
ID: 1349259
Madshi,
yes that's a problem for me.
Can you please help me find the transparent color?

Thank's
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349260
Anton_as,

Please tell me more: From where do you get the bitmap?

If YOU don't know what color shall be transparent and you don't like the automatism, then who should know the transparent color? You could try to program a artificial intelligence that searches all the border pixels and choose that color for transparent that you find most often.

Regards, Madshi.
0
 

Author Comment

by:anton_as
ID: 1349261
Hi Madshi,

I think I know the transparent color, and i guess i just have to use it.
Thank you.
Btw, i want to give you this point, how can i do that?
Should i choose reject or accept? This point belongs to you.
Please tell me.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349262
If you want to give the points to me, you should reject Raymond's answer. Afterwards I'll write a "dummy" answer that you can accept.

Thank you, regards... Madshi.

P.S: If you've still question about transparency, please ask...
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349263
Thanx for the points...  :-)
0
 

Author Comment

by:anton_as
ID: 1349264
I reject this because Madshi's the one who answered my question,
so I think he deserves the point.
0
 

Author Comment

by:anton_as
ID: 1349265
Madshi, please propose an answer.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 1349266
Hmmm. Perhaps you need some glasses?   :-)
0
 

Author Comment

by:anton_as
ID: 1349267
Sorry to keep you waiting.
Thank's

Happy New Year
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1349268
No prob...  :-)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When I am typing into a TEdit last word repeats 7 162
Delphi selector screen 2 92
drawing animated level bar based on numbers 3 113
Dynamically Created Query 3 70
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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…

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