我可以取得32幅图像,在德国国际移民发展公司加工业公司中展示,这种图像具有部分(男性)透明度,但甲型数值要么0,要么255,在两者之间没有任何价值。 我试图装载PngImage、32幅比图和ons,所有这些都会产生同样的......掩盖了透明度,但并非完全透明。
是否还有另一种方式使TImage能够以完全透明的方式展示全球DI+图象,如预期结果图像所示?
GDI Plus After Open
Desired Result
procedure TFormMain.Open1Click ( Sender: TObject );
// Load a GDIPlus Bitmap into TImage
var
GPBitmap: TGPBitmap;
iHBitmap: HBITMAP;
iStatus: TStatus;
const
TRANS_COLOR = clBlack;
begin
if OpenPictureDialog1.Execute then
begin
FilePath := OpenPictureDialog1.FileName;
begin
GPBitmap := TGpBitmap.Create ( FilePath );
try
iStatus := GPBitmap.GetHBITMAP ( aclBlack, iHBitmap );
// As best as I can determine from the internet, the GetHBitmap which is needed to assign a GPbitmap to TImage
// does not hold an alphachannel, so loaded images alpha are either 0 or 255, but drawing with alphachannel values does work.
if iStatus = Ok then
begin
Image1.Picture.Bitmap.Handle := iHBitmap;
Image1.Picture.Bitmap.TransparentColor := Image1.Picture.Bitmap.Canvas.Pixels [ 0, Image1.Picture.Bitmap.Height - 1 ];
StatusBar1.Panels [ 0 ].Text := FileCtrl.MinimizeName ( ExtractFileDir ( FilePath ), Canvas, 200 ); // Folder
StatusBar1.Panels [ 1 ].Text := FileCtrl.MinimizeName ( ExtractFileName ( FilePath ), Canvas, 75 ); // Filename
StatusBar1.Panels [ 2 ].Text := Width: + IntegerToString ( Image1.Picture.Bitmap.Width ); // Width
StatusBar1.Panels [ 3 ].Text := Height: + IntegerToString ( Image1.Picture.Bitmap.Height ); // Height
StatusBar1.Panels [ 4 ].Text := BitDepthToColorString ( GetPixelFormatSize ( GPBitmap.GetPixelFormat ) ); // Bitdepth
Image1.Refresh;
end;
finally
GPBitmap.Free;
end;
end;
end;
end;