繁体   English   中英

Delphi 7,加载PNG到TImage

[英]Delphi 7, load PNG to TImage

只想加载一个.PNG,尝试使用适用于其他格式的 OleGraphic 与我的 LoadPic() 一起使用,但它在 PNG 上失败了。

目标是将图像复制到隐藏的 bitmap,然后将其屏蔽并复制到可见的工作图像 canvas。 如果 CopyRect 不这样做,请随意提出其他建议。

但主要问题是:加载 PNG。 如何? 我找到了很多页面(例如 TPNGImage),但是 web 上的所有资源和链接都已失效、消失或无法下载。

Delphi 7 本身不支持 PNG。 有几个第三方组件可让您添加该支持。 例如,在Torry 的网站上

最新版本的 Delphi 原生支持 PNG,以及许多其他增强功能,建议您升级。

我现在将使用Soft GemsGraphicEx 感谢您提供有用的答案!

从下面下载...

http://delphi.pjh2.de/articles/graphic/png.php

使用 delphi 7 处理.png 图像非常容易...只需将其添加到使用...并创建一个 png object...

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

小型开源 SynGdiPlus 库能够加载和保存 gif、tiff 和 png 图片

它将调用 GdiPlus.dll 库,该库自 Windows XP 起可用。

它快速可靠。

同一单元能够渲染任何具有抗锯齿的 GDI 图元文件:您在常规 TCanvas 上书写,然后使用 GDI+ 进行抗锯齿绘制。 小的代码更改,更大的渲染。

开源单元,从 Delphi 6 到 XE。

您可以从http://synopse.info/fossil/finfo?name=SynGdiPlus.pas下载最新版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM