相关疑难解决方法(0)

如何保存透明度的png文件?

我正在使用Barcode Studio 2011将QR码绘制到Graphics32 - TImage32组件中,我希望以png格式保存它,但是白色是透明的,这是我在Graphics32的OuterColor中指定的.

OnFormCreate我有

procedure TForm1.FormCreate(Sender: TObject);
begin
  psBarcodeComponent1.BarCode := 'some text here...';
end;
Run Code Online (Sandbox Code Playgroud)

目前我已将绘画分配给按钮点击事件

procedure TForm1.Button8Click(Sender: TObject); // Paint the barcode
var
  bmp: TBitmap32;
  Coords: TRect;
begin
 bmp := TBitmap32.Create;
 bmp.SetSize(image.Width, image.Height);
 bmp.Canvas.Brush.Color := color;
 bmp.Canvas.Rectangle(-1, -1, image.Width+2, image.Height+2);

 bmp.DrawMode := dmTransparent;
 bmp.OuterColor := clWhite;

 // make Coords the size of image
 Coords := Rect(0,0,image.Width,image.Height);
 psBarcodeComponent1.PaintBarCode(bmp.Canvas, Coords);
 image.Bitmap.Assign(bmp);
end;
Run Code Online (Sandbox Code Playgroud)

我正在使用Vampyre成像库将Bitmap转换为PNG格式,但我很乐意使用任何库,功能和建议 - 我一直试图这样做近一个星期!我已阅读并重新阅读了graphics32以及Vampyre Imaging Library的文档,但我尝试的任何内容都不会将白色转换为透明色.我已经尝试了clWhite,clWhite32并且还将drawMode设置为dmBlend并且应用ChromaKey功能都无济于事但是很多挫折,咖啡和一点啤酒也;)

这是我如何保存它...

procedure TForm1.Button7Click(Sender: TObject); // Save with Vampyre Imaging Lib
{ Try to …
Run Code Online (Sandbox Code Playgroud)

delphi png transparency image save

5
推荐指数
2
解决办法
5807
查看次数

标签 统计

delphi ×1

image ×1

png ×1

save ×1

transparency ×1