此代码在PngImage组件上工作(来自G.Daud)。现在,在将PngImage替换为PngComponents for D7 (http://code.google.com/p/cubicexplorer/downloads/list)之后,它不再编译。
function Bmp32ToPng(bmp: TBitmap): TPngObject;
var
x, y: integer;
src, dst: PngImage.pByteArray;
begin
Result:= nil;
if bmp.PixelFormat<>pf32bit then
Exit;
Result:= TPngObject.CreateBlank(COLOR_RGBALPHA, 8, bmp.Width, bmp.Height);
Result.Canvas.Draw(0, 0, bmp);
for y:= 0 to bmp.Height-1 do begin
src:= bmp.ScanLine[y];
dst:= Result.AlphaScanLine[y];
for x:= 0 to bmp.Width-1 do
dst[x]:= src[x*4+3];
end;
end;PngComponents.中不存在Createblank方法不能用简单的Create替换它,然后设置Width/height。PngComponents.中的Width/height是R/O
如何将32 BMP (例如从32bpp 32.dll获得)转换为PNG?
发布于 2015-01-19 04:06:49
GraphicEx和PngComponents以及pngimage是相互冲突的。要解决这个问题:
( 1)始终将它们按特定的顺序放在uses子句中- GraphicEx或PngComponents,last。
2)建设工程。仅在uses子句更改后运行(或编译)项目是不够的。
与PNGcomponent包一起安装的pngimage,但是这个版本已经过时了。
https://stackoverflow.com/questions/17194505
复制相似问题