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
 Roate and keep background transparent
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

chukkan

1 Posts

Posted - Nov 04 2015 :  00:25:02  Show Profile  Reply
Hello there,
just trying to learn this wonderful component. How to rotate an image while keeping the background transparent?

Thanks in advance

w2m

USA
1990 Posts

Posted - Nov 04 2015 :  07:42:04  Show Profile  Reply
What file types are you rotating? Are you loading bitmaps? If so then convert the bitmaps to png then rotate will maintain the alphachannel or if loading BMP 32 bits per pixel set BMP_HandleTransparency to true. When BMP_HandleTransparency is true the extra byte is interpreted as an alpha channel, otherwise it is just ignored. So if BMP_HandleTransparency = True the image will be displayed in ImageEn with transparency. Whereas if BMP_HandleTransparency = False the transparent color will not be used.
// if BMP_HandleTransparency = true then display with transparency
ImageENVect1.IO.Params.BMP_HandleTransparency := chkBMPHandleTransparency.Checked;
ImageENVect1.IO.LoadFromFile( FilePath );

if this does not work, then convert the image to 32-bit png and set the transparent color:
var
iRGB: TRGB;
ImageEnView1.IO.Params.BitsPerSample := 8;
ImageEnView1.IO.Params.SamplesPerPixel := 4;
iRGB := ImageEnView1.IEBitmap.Pixels[0, ImageEnView1.IEBitmap.Height - 1];
ImageEnView1.Proc.SetTransparentColors(iRGB, iRGB, 0);

Generally it is best to use png image files when using transparency.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: