Description: This dll converts a file image format to another (it does not rely on image libraries at all!). There is only one dll call.
File Size: 151Kb (dll) 149Kb (package)
Version: 1.0.5.7
Thanks: Some people suggesting doing this, and the source code by several people. Also thanks to Borland for making a great development IDE (the dll code is only a couple of lines!)
Download Page: http://covac-softwar...d...cat=2&id=22
Direct Download: http://covac-softwar...nload.php?id=22
GML source: http://covac-softwar...tView.php?id=22
Usage: Example of use (gml):
// 3rd parameter optional in v1.0.5.7
ic_init();
ic_convert("original.bmp","new.gif",c_fuchsia);
ic_fini();
Explanation: Converts the file "original.bmp" to a gif file named "new.gif".Usage Notes:
-Not all formats are perfectly interchangeable (eg,
-Formats are limited to: BMP, ICO, PNG, GIF, JPG
-Converting to GIF is single frame
--Likewise, converting a GIF to something else will probably convert first frame only.
Credits: Not needed (see my sig).
SOURCE CODE Please note, the source code is open to change and may remain unchanged so as not to match the actual dll. Use at your own risk.
library ImgConv;
uses SysUtils,Graphics,pngimage,jpeg,gifimage;
var t:String;
{$R *.res}
function ExtToClass(Ext:String):TGraphic;
begin
if Ext='.bmp' then Result:=TBitmap.Create
else if Ext='.ico' then Result:=TIcon.Create
else if Ext='.png' then Result:=TPNGObject.Create
else if Ext='.gif' then Result:=TGIFImage.Create
else if Ext='.jpg' then Result:=TJPEGImage.Create
else raise Exception.Create('Unknown file extension "'+Ext+'"');
end;
function GetExt(FileName:String):String;
begin
Result:=ExtractFileExt(FileName);
// convert other extension like "jpeg" here
if Result='.jpeg' then Result:='.jpg';
end;
function convert(ExistingFile, NewFile: PChar):PChar; stdcall;
var e,n:TGraphic;
begin // Convert an existing image file to another. Returns True on success, False otherwise.
t:='';
try
if not FileExists(ExistingFile) then
raise Exception.Create('File "'+ExistingFile+'" does not exist');
e:=ExtToClass(GetExt(ExistingFile)); n:=ExtToClass(GetExt(NewFile));
e.LoadFromFile(ExistingFile);
n.Assign(e);
n.SaveToFile(NewFile);
e.Free; n.Free;
t:='Done';
except
on E:Exception do t:=E.Message;
end;
Result:=PChar(t);
end;
exports
convert; // Convert an existing image file to another. Returns True on success, False otherwise.
begin
end.
Kind regards,
Christian Sciberras.
Edited by uuf6429, 27 May 2009 - 04:33 PM.