问题
Just want to load a .PNG, tried with my LoadPic() using OleGraphic that works with other formats, but it failed on PNG.
The goal is to copy the image to a hidden bitmap whence it is then masked and copied to a visible working image canvas. Feel free to suggest something else if CopyRect doesn't do this.
But the main question: Load PNG. How? I've found a lot of pages (f.ex. TPNGImage), but all the resources and links on the web are dead, gone or not downloadable.
回答1:
Delphi 7 doesn't support PNG natively. There are several third party components that will let you add that support. For example, on Torry's site.
回答2:
Recent versions of Delphi support PNG natively, amongst many other enhancements, and you would be well advised to upgrade.
回答3:
I will use GraphicEx from Soft Gems for now. Thanks for helpful answers!
回答4:
Download from below...
http://delphi.pjh2.de/articles/graphic/png.php
It is very easy to handle .png images with delphi 7... Just add it into uses... and create a png object...
回答5:
The small Open Source SynGdiPlus library is able to load and save gif, tiff and png pictures.
It will call the GdiPlus.dll library, which is available since Windows XP.
It's fast and reliable.
The same unit is able to render any GDI metafile with anti-aliasing: you write on a regular TCanvas, then it's drawn with anti-aliasing using GDI+. Small code change, greater rendering.
Open Source unit, working from Delphi 6 up to XE.
You can download the latest version from http://synopse.info/fossil/finfo?name=SynGdiPlus.pas
回答6:
GraphicEx by Soft Gems has been moved to https://github.com/mike-lischke/GraphicEx
An explaination regarding the move can be found at http://www.soft-gems.net/index.php/libs/43-graphicex-on-github
I added GraphicEx to my Delphi 6 project and it worked out of the box but when I tested it with Delphi 5 it did not.
Regardless, it works well and implements not only PNG images but also many others which are configurable from 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
来源:https://stackoverflow.com/questions/6237711/delphi-7-load-png-to-timage