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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Transparency problems

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Mar 15 2021 : 15:25:22
I create a Bitmap and initialize it:

Bitmap := TBitmap.Create;
try
  Bitmap.PixelFormat := TPixelFormat.pf32bit;   // 32bit bitmap
  Bitmap.AlphaFormat := TAlphaFormat.afDefined; // Enable alpha channel
  Bitmap.SetSize(500, 500); // Set the bitmap to a custom size
  // Fill Bitmap background with transparency:
  Bitmap.Canvas.Brush.Color := clNone;
  Bitmap.Canvas.FillRect(Rect(0, 0, Bitmap.Width, Bitmap.Height));
  Bitmap.SaveToFile('EmptyBitmap.bmp');


Then I draw on the Bitmap with another component and then save it as a .BMP file again:

Bitmap.SaveToFile('ReadyBitmap.bmp');


Then I assign the Bitmap to an ImageEnView:

ImageEnView1.Assign(Bitmap);
ImageEnView1.Update;
ImageEnView1.IO.SaveToFileBMP('ImageEnBitmap.bmp');


Unfortunately, the background of the image is NOT TRANSPARENT. Here is a screenshot of ImageEnView1:



Here are the .BMP files saved from the various stages of the procedure:

attach/PeterPanino/2021315151555_Bitmaps.zip
15.54 KB

If you analyze the attached file ReadyBitmap.bmp you can see that the background is still transparent!

How can I make the image background transparent in the ImageEnView?
2   L A T E S T    R E P L I E S    (Newest First)
PeterPanino Posted - Mar 15 2021 : 17:08:11
That works VERY WELL. Thank you, Nigel!
xequte Posted - Mar 15 2021 : 15:50:54
Hi Peter

With 32bit TBitmaps, you must sync the A channel to ImageEn's Alpha channel using:

SynchronizeRGBA( True );

https://www.imageen.com/help/TIEBitmap.SynchronizeRGBA.html

e.g.

// Assign a 32bit Bitmap with alpha channel to an ImageEnView (keeping the alpha)
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create();
  bmp.LoadFromFile( 'Bmp32_with_Alpha.bmp' );
  ImageEnView1.IEBitmap.Assign( bmp );
  ImageEnView1.IEBitmap.SynchronizeRGBA( true );
  ImageEnView1.Update();
  bmp.Free();
end;


Nigel
Xequte Software
www.imageen.com