ImageEn, unit iexBitmaps

TIEBitmap.SynchronizeRGBA

TIEBitmap.SynchronizeRGBA


Declaration


procedure SynchronizeRGBA(RGBAtoAlpha: boolean; UpdatePixelFormat: Boolean = False);


Description


When ie32RGB (RGBA) pixel format is used, the A channel is not used. Alpha channel is stored in a separated plane (AlphaChannel).
To copy from A channel to ImageEn Alpha channel, call SynchronizeRGBA( True ); If UpdatePixelFormat is true, the PixelFormat will be set to ie24RGB.
To copy from ImageEn Alpha channel to A channel, call SynchronizeRGBA( False );


Examples


// 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;

// Create a 32bit Bitmap with alpha channel
var
  bmp: TBitmap;
begin
  bmp := TBitmap.Create();
  ImageEnView1.IEBitmap.SynchronizeRGBA( false );
  ImageEnView1.IEBitmap.CopyToTBitmap( bmp );
  bmp.SaveToFile( 'test.bmp' );
  bmp.Free();
end;

// Draw a semi-transparent ellipse
var
  bitmap: TIEBitmap;
begin
  bitmap := TIEBitmap.Create( 500, 500, ie32RGB ); // <= RGBA required!
  bitmap.Fill( 0 );
  bitmap.AlphaChannel.Fill( 0 );

  bitmap.IECanvas.SetCompositingMode( ieCompositingModeSourceOver, ieCompositingQualityDefault );
  bitmap.IECanvas.Pen.Width := 4;
  bitmap.IECanvas.Pen.Color := clRed;
  bitmap.IECanvas.Brush.Color := clBlue;
  bitmap.IECanvas.Pen.Transparency := 90;
  bitmap.IECanvas.Brush.Transparency := 90;

  bitmap.IECanvas.Ellipse(10, 10, 400, 400);

  bitmap.SynchronizeRGBA( True ); // <= gdi+ draws alpha on RGBA. This copies 'A' to TIEBitmap alpha channel

  imageenview1.iebitmap.Assign( bitmap );
  imageenview1.update;
  bitmap.Free();
end;



See Also


- BMP_HandleTransparency