如题 delphi7 用pngimage 这个单元加载png 图片的时候 ,会出现 错误,
出问题的时候,代码直接跳到 TPngObject.DrawPartialTrans
中的 case Header.BitmapInfo.bmiHeader.biBitCount of
{R, G, B images}
24:
FOR j := 1 TO H DO
begin
{Process all the pixels in this line}
FOR i := 0 TO W - 1 DO
begin
if Stretch then i2 := trunc(i / FactorX) else i2 := i;
{Optmize when we don磘 have transparency}
if (AlphaSource[i2] <> 0) then
if (AlphaSource[i2] = 255) then
ImageData[i] := pRGBQuad(@ImageSource[i2 * 3])^ ----》 直接跳到这里,
else
with ImageData[i] do
begin
rgbRed := (255+ImageSource[2+i2*3] * AlphaSource[i2] + rgbRed *
(not AlphaSource[i2])) shr 8;
rgbGreen := (255+ImageSource[1+i2*3] * AlphaSource[i2] +
rgbGreen * (not AlphaSource[i2])) shr 8;
rgbBlue := (255+ImageSource[i2*3] * AlphaSource[i2] + rgbBlue *
(not AlphaSource[i2])) shr 8;
end;
end;然后 往下走之后 ,图片就不能加载,
求解
出问题的时候,代码直接跳到 TPngObject.DrawPartialTrans
中的 case Header.BitmapInfo.bmiHeader.biBitCount of
{R, G, B images}
24:
FOR j := 1 TO H DO
begin
{Process all the pixels in this line}
FOR i := 0 TO W - 1 DO
begin
if Stretch then i2 := trunc(i / FactorX) else i2 := i;
{Optmize when we don磘 have transparency}
if (AlphaSource[i2] <> 0) then
if (AlphaSource[i2] = 255) then
ImageData[i] := pRGBQuad(@ImageSource[i2 * 3])^ ----》 直接跳到这里,
else
with ImageData[i] do
begin
rgbRed := (255+ImageSource[2+i2*3] * AlphaSource[i2] + rgbRed *
(not AlphaSource[i2])) shr 8;
rgbGreen := (255+ImageSource[1+i2*3] * AlphaSource[i2] +
rgbGreen * (not AlphaSource[i2])) shr 8;
rgbBlue := (255+ImageSource[i2*3] * AlphaSource[i2] + rgbBlue *
(not AlphaSource[i2])) shr 8;
end;
end;然后 往下走之后 ,图片就不能加载,
求解
D7 升级到 2010 就自带了.
加载的全部是 png 的图片 ,我想请问 这段代码 具体的作用是干啥的,
第一步,建一个visio空文件,将想要的png图片插入Visio中,然后再文件中的另存为,保存为windows图元文件,wmf 格式类型,或者增强型图元文件 emf格式。
第二部,直接将wmf 或emf 格式图片加载到image,delphi 7 中的image是支持wmf与emf格式的文件,并且能够实现透明显示。
可以用ps重新转下,重新生成png5楼的方法我试了下,可以用,但又两个缺点:
1 。转成emf,文件大了好多
2. 产生锯齿。没有了alpha
delphi 2007 就自带了
你说的这个函数是用绘制带Alpha通道的,实际应用上没遇到过你说的问题,你检查一下是否用的最新版本。