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
 Retain Alpha Transparency on 32bit RGB Export

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
PaulAtMass Posted - Apr 08 2020 : 09:45:55
Hi, I'm having trouble retaining the background and fill transparency when writing/saving a TIELayer to a 32bit bitmap file or VCL Bitmap. See code below:
I really need to convert a TIELayer to a 32bit RBGA bitmap to create a video overlay frame. See attached PowerPoint for different image files.


  { Create transparent 200x200 yellow circle layer. }
  LLyrRect := Rect( 0, 0, 200, 200);
  IEView.LayersAdd( iesEllipse, LLyrRect, clYellow, 1, clYellow );
  LLyr         := IEView.CurrentLayer;
  LLyr.Opacity := 0.5;  { Doesn't work on PNG file }
//  LLyr.FillOpacity := 0.5;   { Does work on PNG file but pen solid }
  LLyr.ConvertToImageLayer(1, False);
  IEView.Update();
  LLyr.Bitmap.Write( 'IELayer PNG.png');   //Background Transparent but fill not.
  LLyr.Bitmap.Write( 'IELayer BMP.bmp');   //Neither background or fill transparent.
  Image2.Picture.Assign(LLyr.Bitmap.VclBitmap);

  //Try setting pixel format and using SynchronizeRGBA.
  IEBmpOvr := TIEBitmap.Create(LLyr.Bitmap);
  IEBmpOvr.PixelFormat := ie32RGB;
  IEBmpOvr.Write( 'IEBitmap BMP.bmp');
  IEBmpOvr.Free();
  IEBmpOvr := TIEBitmap.Create(LLyr.Bitmap);
  IEBmpOvr.SynchronizeRGBA( False, True);  //Convert 24bit image + alpha channel to 32bit RGBA.
  IEBmpOvr.Write( 'IEBitmap Sync BMP.bmp');

  { Create video overlay frame using Bitmap Handle (assumes 32RGBA format). }
  if m_pFrameFactory = nil then
    m_pFrameFactory := CreateComObject(CLASS_MFFactory) as IMFFactory;
   m_pFrameFactory.MFFrameCreateFromHBITMAP( IEBmpOvr.VclBitmap.Handle, CursorData.MFCsrOverlay, '');
//  m_pFrameFactory.MFFrameCreateFromFile('IILayer PNG.png', CursorData.MFCsrOverlay, '');



1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 09 2020 : 22:54:44
Hi Paul

It is not intended that layers be a way of outputting content. Layers are just part of a greater image, which is output. So, for instance Opacity is only a display property that does not affect the image itself until you flatten the image (i.e. merge it to the background).

  // Create a PNG with a 50% transparent ellipse
  ImageEnView1.Blank;
  aRect := Rect( 0, 0, 200, 200);
  ImageEnView1.LayersAdd( iesEllipse, aRect, clNone, 0, clRed );
  ImageEnView1.CurrentLayer.Opacity := 0.5;

  // Merge with Alpha Compositing
  ImageEnView1.LayersMergeAll( True );

  ImageEnView1.IO.SaveToFile( 'D:\out.png');



Nigel
Xequte Software
www.imageen.com