如题 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;然后 往下走之后 ,图片就不能加载, 
求解 

解决方案 »

  1.   

    加载的不是png的图吧?
    D7 升级到 2010 就自带了.
      

  2.   

    有pngimage这个东西么。。
      

  3.   


    加载的全部是 png 的图片 ,我想请问 这段代码 具体的作用是干啥的,
      

  4.   

    使用的是gdiplus吗?
      

  5.   

    不需要用pngimage ,教你一个简单的方法实现delphi 7加载 png 透明图片,需要用到微软的Visio软件。
    第一步,建一个visio空文件,将想要的png图片插入Visio中,然后再文件中的另存为,保存为windows图元文件,wmf 格式类型,或者增强型图元文件 emf格式。
    第二部,直接将wmf 或emf 格式图片加载到image,delphi 7 中的image是支持wmf与emf格式的文件,并且能够实现透明显示。
      

  6.   

    一直用png ,未发现问题,
    可以用ps重新转下,重新生成png5楼的方法我试了下,可以用,但又两个缺点:
    1 。转成emf,文件大了好多
    2. 产生锯齿。没有了alpha
      

  7.   

    可以用白色背景的bmp图,把form.transparentColor 设为True , transparentColorvalue 设为ClWihite 可以达到相同的效果。
      

  8.   


    delphi 2007 就自带了
      

  9.   

    PNG有很多种格式,TPNGIMAGE会根据色彩深度、透不透明、有没有Alpha通道决定用哪个函数来绘制。
    你说的这个函数是用绘制带Alpha通道的,实际应用上没遇到过你说的问题,你检查一下是否用的最新版本。
      

  10.   

    我们用PNG一般来做水印,有时候也出错