我正在使用2011年版的Barcode Studio将QR码绘制到Graphics32-TImage32组件中,并且我希望以png格式保存,但是白色作为透明色,这在Graphics32的OuterColor中进行了指定。
在FormCreate事件中,我只是:
我正在使用Vampyre Imaging Library将位图转换为PNG格式,但我很乐意使用任何库、函数和建议——我已经尝试了近一个星期!我已经阅读并反复阅读了graphics32和Vampyre Imaging Library的文档,但是我尝试的所有方法都无法将白色转换为透明颜色。我已经尝试了clWhite、clWhite32,并将drawMode设置为dmBlend并应用ChromaKey函数,但都没有成功,只有沮丧、咖啡和一点啤酒;)
这是我保存它的方式...
在FormCreate事件中,我只是:
procedure TForm1.FormCreate(Sender: TObject);
begin
psBarcodeComponent1.BarCode := 'some text here...';
end;
目前我已将绘画分配给按钮点击事件
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;
我正在使用Vampyre Imaging Library将位图转换为PNG格式,但我很乐意使用任何库、函数和建议——我已经尝试了近一个星期!我已经阅读并反复阅读了graphics32和Vampyre Imaging Library的文档,但是我尝试的所有方法都无法将白色转换为透明颜色。我已经尝试了clWhite、clWhite32,并将drawMode设置为dmBlend并应用ChromaKey函数,但都没有成功,只有沮丧、咖啡和一点啤酒;)
这是我保存它的方式...
procedure TForm1.Button7Click(Sender: TObject); // Save with Vampyre Imaging Lib
{ Try to save in PNG format with transparancy }
var
FImage: TSingleImage;
begin
FImage := TSingleImage.Create;
ConvertBitmap32ToImage(image.Bitmap, FImage);
FImage.SaveToFile('VampyreLibIMG.png');
end;
这将导致缩略图呈黑色,并且在Windows照片查看器中查看时完全透明。
希望我提供的信息足够,有人能够帮助我。
Chris