Board index » cppbuilder » Transparent Color of TImage, as i want...

Transparent Color of TImage, as i want...


2004-05-08 03:37:26 PM
cppbuilder97
The color of the left-bottom pixel of a TImage is the
Transparent color of the image when "Transparent = true", i
think that it's VERY restricting! sometimes i need to put an
image on the Form and i want that only the middle of the image
will be transparent (like a hole) and that the left-bottom
pixel will not be transparent.
So... the question is how actually do i tell the TImage what
color i want to be transparent, WITH NO ANY CONNECTION to the
pixel in the corner, my logic say that it's possible, becouse
the image must have some Veriable where it's keeping the color
which is the "Transparent Color" , so why can't i change it to
other value from inside my code?
Thanks,
Ramy.
 
 

Re:Transparent Color of TImage, as i want...

Ramy wrote:
Quote
The color of the left-bottom pixel of a TImage is the
Transparent color of the image when "Transparent = true", i
think that it's VERY restricting! sometimes i need to put an
image on the Form and i want that only the middle of the image
will be transparent (like a hole) and that the left-bottom
pixel will not be transparent.
This is the default behaviour, yes.
Quote
So... the question is how actually do i tell the TImage what
color i want to be transparent, WITH NO ANY CONNECTION to the
pixel in the corner, my logic say that it's possible, becouse
the image must have some Veriable where it's keeping the color
which is the "Transparent Color" , so why can't i change it to
other value from inside my code?
If the underlying TGraphic object of the TImage is a TBitmap you can use
the TransparentMode and TransparentColor properties to specify which
color is used for transparency.
For example:
Graphics::TBitmap* bmp = Image1->Picture->Bitmap;
if (bmp)
{
bmp->TransparentMode = tmFixed;
bmp->TransparentColor = clWhite;
bmp->Transparent = true;
}
Replace clWhite with the color you want to make transparent, of course.
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
 

Re:Transparent Color of TImage, as i want...

Hi, i'm not sure if this is what i need, becouse if i'll copy
bmp (from your example) back to the TImage on the Form, it will
still use the Left-Bottom pixel as the transparent color.
Ramy
Quote
the TransparentMode and TransparentColor properties to
specify which color is used for transparency.

For example:

Graphics::TBitmap* bmp = Image1->Picture->Bitmap;
if (bmp)
{
bmp->TransparentMode = tmFixed;
bmp->TransparentColor = clWhite;
bmp->Transparent = true;
}

Replace clWhite with the color you want to make transparent, of course.

Corey Murtagh
 

{smallsort}

Re:Transparent Color of TImage, as i want...

Ramy wrote:
Quote
Hi, i'm not sure if this is what i need, becouse if i'll copy
bmp (from your example) back to the TImage on the Form, it will
still use the Left-Bottom pixel as the transparent color.
The sample code I gave you doesn't copy the bitmap. I've used a TBitmap
pointer to access the internal bitmap of the TImage. It certainly does
work on BCB4.
To test I created an application, dropped a TImage and TButton on the
form, loaded a black and white image into the TImage and set its
Transparent property to true, then added a click handler for the button
like this:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap* bmp = Image1->Picture->Bitmap;
if (bmp)
{
bmp->TransparentMode = tmFixed;
bmp->TransparentColor = clWhite;
}
}
On running the program and clicking the button, the black areas (which
were formerly transparent, since the bottom-left pixel is black) became
solid and the white areas disappeared.
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
 

Re:Transparent Color of TImage, as i want...

Hmmm thanks very much! now i understand it, very nice method,
thanks again i'll use it!
Ramy
Quote
To test I created an application, dropped a TImage and TButton on the
form, loaded a black and white image into the TImage and set its
Transparent property to true, then added a click handler for the button
like this:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap* bmp = Image1->Picture->Bitmap;
if (bmp)
{
bmp->TransparentMode = tmFixed;
bmp->TransparentColor = clWhite;
}
}

On running the program and clicking the button, the black areas (which
were formerly transparent, since the bottom-left pixel is black) became
solid and the white areas disappeared.

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
 

Re:Transparent Color of TImage, as i want...

Corey Murtagh < XXXX@XXXXX.COM >wrote:
Quote
[...]
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"
OK - I give. What the hell does that say?
~ JD
 

Re:Transparent Color of TImage, as i want...

JD wrote:
Quote
Corey Murtagh < XXXX@XXXXX.COM >wrote:

>[...]
>The Electric Monk
>"Quidquid latine dictum sit, altum viditur!"

OK - I give. What the hell does that say?
lol... I've been using it so long I tend to forget it's even there :>
A close idomatic translation:
"Anything that is said in Latin sounds profound!"
--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"