我想加载一个 .PNG 文件,使用了 OleGraphic 中的 LoadPic() 方法,这个方法可以处理其他格式的图片,但是对于 PNG 格式失败了。
目标是将图片复制到一个隐藏的位图中,然后对其进行遮罩处理,并复制到可见的工作图片画布中。如果 CopyRect 无法实现此操作,请随意提出其他建议。
但主要问题是:如何加载 PNG 格式的图片?我找到了很多网页(例如 TPNGImage),但所有的资源和链接都已经失效、消失或无法下载。
Delphi 7 不支持 PNG 格式。但是有一些第三方组件可以添加这种支持。例如,在 Torry 网站 上可以找到一些。
最近的Delphi版本原生支持PNG格式,还有许多其他增强功能,建议您升级。
从下面下载...
http://delphi.pjh2.de/articles/graphic/png.php
使用Delphi 7处理.png图像非常容易... 只需将其添加到uses中... 并创建一个png对象即可...
这个小型的开源SynGdiPlus库能够加载和保存gif、tiff和png图片。
它将调用自Windows XP以来可用的GdiPlus.dll库。
它快速而可靠。
同一个单元能够使用抗锯齿渲染任何GDI元文件:您可以在常规TCanvas上编写,然后使用GDI+ 进行抗锯齿绘制。小的代码更改,更好的渲染效果。
开源单元,适用于Delphi 6到XE。
您可以从http://synopse.info/fossil/finfo?name=SynGdiPlus.pas下载最新版本。
Soft Gems的GraphicEx已经迁移到https://github.com/mike-lischke/GraphicEx
关于此次迁移的说明可以在http://www.soft-gems.net/index.php/libs/43-graphicex-on-github找到。
我将GraphicEx添加到我的Delphi 6项目中,它可以直接使用,但是当我用Delphi 5测试时却不能正常工作。
不管怎样,它很好用,不仅实现了PNG图像,还实现了许多其他功能,这些功能可以从GraphicConfiguration.inc进行配置:
// Pick your preferred image formats here or leave them all enabled. By disabling
// certain formats which are not of interest you can save some memory.
{$define UseLZW} //patent is out, yay!
{$define SGIGraphic} // *.bw, *.rgb, *.rgba, *.sgi images are supported
{$define AutodeskGraphic} // *.cel, *.pic images
{-$define NewTIFFGraphic} // *.tif, *.tiff images
{$define OldTIFFGraphic}
{$define TargaGraphic} // *.tga, *.vst, *.icb, *.vda, *.win images
{$define PCXGraphic} // *.pcx, *.pcc, *.scr images
{$define PCDGraphic} // *.pcd images
{$define PortableMapGraphic} // *.ppm, *.pgm, *.pbm images
{$define CUTGraphic} // *.cut (+ *.pal) images
{$define GIFGraphic} // *.gif images
{$define RLAGraphic} // *.rla, *.rpf images
{$define PhotoshopGraphic} // *.psd, *.pdd images
{$define PaintshopProGraphic} // *.psp images
{$define PortableNetworkGraphic} // *.png images
{$define EPSGraphic} // *.eps images
{$define ArtsAndLettersGraphic} // *.ged images
PNG Delphi
。 - Premature Optimization