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, '');