ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 From ImageEnView to TImage
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Temoc

USA
7 Posts

Posted - May 01 2012 :  07:48:56  Show Profile  Reply
What is the proper way to assign an image from a ImageEnView to a TImage (without save to file)?
The following assignment results in a distorted image:
Image1.Picture.Bitmap.Assign(ImageEnView1.Bitmap);

My goal is to assing the image to a TPNGImage:
aPng:=TPngImage.CreateBlank(COLOR_RGB, 8, ImageEnView1.Bitmap.Width, ImageEnView1.Bitmap.Height);
aPng.Canvas.Draw(0,0,ImageEnView1.Bitmap);

But I am getting the same distorted image in both cases.

w2m

USA
1990 Posts

Posted - May 01 2012 :  08:51:20  Show Profile  Reply
I am not sure if this will help, but try setting the pixelformat of the bitmap to pf24bit after you assign the bitmap:

Image1.Picture.Bitmap.Assign(ImageEnView1.Bitmap);
Image1.Picture.Bitmap.PixelFormat := pf24Bit;

William Miller
Go to Top of Page

Temoc

USA
7 Posts

Posted - May 01 2012 :  09:04:54  Show Profile  Reply
The issue seems to happen when I load PNG images which have transparent background. I load a few bmp images and it works fine.
Any idea on what I'm missing?
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 01 2012 :  12:40:53  Show Profile  Reply
It turns out you do not have to set the pixelformat for what you are trying to do. You have to set Image1.Transparent := True and set the Image1.Bitmap.TransparentColor...

Try this:

var
iTransparentColor: TColor;
iRGB: hyiedefs.TRGB;
begin
  Image1.Transparent := True;
  Image1.Picture.Bitmap.Assign( ImageEnView1.Bitmap );
  iRGB := ImageEnView1.IEBitmap.Pixels [ 0, ImageEnView1.Bitmap.Height - 1 ];
  iTransparentColor := TRGB2TColor ( iRGB );
  Image1.Picture.Bitmap.TransparentColor := iTransparentColor ;
end;


I tested this with PNG images...

William Miller
Go to Top of Page

Temoc

USA
7 Posts

Posted - May 01 2012 :  16:05:50  Show Profile  Reply
Thank you very much for your help
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: