Board index » cppbuilder » Timage Transparent

Timage Transparent


2006-09-11 02:59:30 PM
cppbuilder17
Hello All,
I placed several TImage components over each other each containing the
JPEG image of a T-Shirt of a different color.
The last TImage component is the design that is to be printed on the
chest position of the tshirt and it's property is set transparent.
The quality of the transparent image deteriorates.
Which format must I use to get a good quality because if tranparent of the
TImage is set true I get the limits of the TImage
Thanks
Alain
 
 

Re:Timage Transparent

JPEG is a lossy compression which uses a resonably close colors to the
original image but it won't necessarily be the same. Because of this you
get artifacts all over the place (as you have found out). BMP is probably
the easiest for you to use to correct this scenario.
However, GIF is a little better since it offers image compression.
Personally, I use nothing but PNG since it offers multiple levels of
transparency with true-color images. To download a good PNG component for
the VCL head to: sourceforge.net/projects/pngdelphi
- Clayton
 

Re:Timage Transparent

Quote
To download a good PNG component for
the VCL head to: sourceforge.net/projects/pngdelphi

- Clayton
How to use Delphi *.pas codes under C++Builder 4 ?
Thanks
 

{smallsort}

Re:Timage Transparent

I have been able to install the PNG package
But still can't remove the JPEG error.
How can I identify which components need to be register so that I may remove
them safely ?
Thanks
 

Re:Timage Transparent

Quote
To download a good PNG component for
the VCL head to: sourceforge.net/projects/pngdelphi

Getting EInvalidGraphic when I
DESIGN->Picture->LoadFromFile(FileListBox1->FileName);
for image file with .png extension
 

Re:Timage Transparent

You need to have the following line in one of your CPP files:
#pragma link "PNGImage"
- Clayton
 

Re:Timage Transparent

"Alain" < XXXX@XXXXX.COM >wrote in message
Quote
But still can't remove the JPEG error.
What error? Are you referring to the transparent quality of the JPEGs? If
so, did you convert to PNG from the JPEG or from an original clear source
(such as BMP or TIFF)?
Can you post to the "attachments" group an example of one of the images that
is giving you a problem? It also wouldn't hurt to post a screen shot of the
problem you are having.
- Clayton
 

Re:Timage Transparent

Quote
#pragma link "PNGImage"

- Clayton
Done ..My *.png files open
And the transparency is GREAT as expected
Now I must work out the proportion resizing
Thanks again
Alain
 

Re:Timage Transparent

To Clayton:
The PNG works great !!
I wonder How can such application can be done for the WEB ?
My I sent it (the compile or source) to you as attachement so that you can
redirect me to
the appropriate group to get it web based? at least a starting point
Thanks
Alain
 

Re:Timage Transparent

I haven't yet made any of my applications run from within a web browser so I
cannot help you there. Most likely you will need to make an ActiveX control
but that will limit those who use your product to Internet Explorer users
(and a few other various browsers) on the Windows platform. You can try
asking your question in the "vcl.components.writing" newsgroup or ask a
general question in the "non-technical" group.
Good luck,
- Clayton
 

Re:Timage Transparent

Hello All,
Is it possible to control the transparency of a PNG image loaded on a TImage
using a Trackbar component ?
Thanks
Alain
 

Re:Timage Transparent

"Alain" < XXXX@XXXXX.COM >wrote in message
Quote
Hello All,

Is it possible to control the transparency of a PNG image loaded on a
TImage using a Trackbar component ?

Thanks

Alain
This is from Michel Leunen
Here is how to change the amount of transparency of an image and draw it
on a TImage. All the work is done in a TButton event handler here. I
leave to you the part with the trackbar. You just have to slightly
change the code to be used in the OnChange event of the trackbar.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap* SourceBmp = new Graphics::TBitmap();
Graphics::TBitmap* DestBmp = new Graphics::TBitmap();
SourceBmp->LoadFromFile("your_image.bmp");
DestBmp->PixelFormat = pf24bit;
DestBmp->Width = SourceBmp->Width;
DestBmp->Height = SourceBmp->Height;
/* alpha gives the amount of transparency.
* 1.0 completely transparent
* 0.0 no transparency
*/
const float alpha = 0.8;
for(int row = 0; row < SourceBmp->Height; row++)
{
RGBTRIPLE* source = static_cast<RGBTRIPLE*>(SourceBmp->ScanLine[row]);
RGBTRIPLE* dest = static_cast<RGBTRIPLE*>(DestBmp->ScanLine[row]);
for(int col = 0; col < SourceBmp->Width; col++)
{
dest->rgbtRed = alpha * dest->rgbtRed + (1-alpha) * source->rgbtRed;
dest->rgbtGreen = alpha * dest->rgbtGreen + (1-alpha) *
source->rgbtGreen;
dest->rgbtBlue = alpha * dest->rgbtBlue + (1-alpha) *
source->rgbtBlue;
source++; dest++;
}
}
Image1->Picture->Assign(DestBmp);
delete SourceBmp;
delete DestBmp;
}