Portable
Graphics Network |
release
notes for the PNG encoder and decoder for Delphi 5 version 1.2
This is version 1.2 of
the encoder and decoder to the Portable Graphics Network format
for Delphi 5. This implementation is capable of reading and saving
images with Gamma correction and direct access to all the PNG
chunks. This implementation was all worked on Delphi 5 and it can show
images progressively, as it is being decoded.
The unit was tested in
all the images Willem van Schaik test
page, and, it worked with 100% of the images.
This
implementation integrates with Delphi
As the implementation
derivates from the class TGraphic, TPNGImage integrates with
Delphi booth in run-time and design-time allowing reading PNG images in
components like TImage, TOpenPictureDialog thru the class TPicture. This
allows, for instance, conversion from any other formats to PNG or from
PNG.
Step
by step on how to install TPNGImage in your Delphi 5
-
Execute delphi
5
-
Go to the menu
item Tools>Enviroment Options...
-
Select the page
Library
-
Add the unit
directory in the field path (put a ; before the path)
-
Click OK
Now to install the
component:
-
Go to the
menu Component>Install
Component
-
In the unit file
name field, add the path and name for the PNGImage.DCU
-
Click OK
-
To the message
Package will be rebuilt, select No
-
Click on the
button Add on the window toolbar
-
In the next
window, put the path and name for PNGZLIB.DCU in the unit file name
field
-
Click OK
-
Now press the
button Compile
Now, the component
is installed in Delphi and now you add PNGImage in the uses field inside
your form units to use the component.
It
is really easy to use TPNGImage, here goes an example:
{*********************************************}
{* The following app allows to convert BMP *}
{* images into PNG. To use, call the program *}
{* from MS-DOS
prompt:
*}
{* CONVERT.EXE [BMP File]
*}
{*
*}
{* And the image in the parameter will be *}
{* converted to a PNG image with same name. *}
{*********************************************}
program convert;
{$APPTYPE CONSOLE}
uses SysUtils, Windows, Graphics, PNGImage;
procedure CallError(Msg: string);
begin
WriteLn(Msg);
WriteLn('');
WriteLn('Use:');
WriteLn(ExtractFileName(ParamStr(0)) + ' [File name.BMP]');
WriteLn('');
WriteLn('To convert the specified file to PNG
format.');
{Quits the program}
Halt;
end;
var
PNG: TPNGImage;
BMP: TBitmap;
Filename: String;
begin
{Get the file in the command line}
Filename := GetCommandLine;
Filename := Copy(Arquivo, Pos(' ', Filename) + 1, Length(Filename));
{Test if the specified file exits}
if (Filename = '') or (not FileExists(Filename))
then
CallError('No file was specified, or the specified file does
not exists!');
{Creates the TPNGImage and TBitmap}
PNG := TPNGImage.Create;
BMP := TBitmap.Create;
{Do the work}
BMP.LoadFromFile(Filename);
PNG.Assign(BMP);
PNG.SaveToFile(ChangeFileExt(Filename, '.PNG'));
{Destroy the objects}
BMP.Free;
PNG.Free;
{Shows a
message}
WriteLn(Format('The file:%s%s%sWas successfully saved as::%s%s',
[#13#10, Filename, #13#10#13#10, #13#10, ChangeFileExt(Filename,
'.PNG')]));
end.
How
to contact the component author to get more information
You may contact the
author to answer any doubts you have about the component or to report
bugs you find, or even to give ideas for future versions.
GUSTAVODAUD@UOL.COM.BR
Gustavo Huffenbacher Daud
Website:
http://www.overpower.com.br/png
|