Jump to content


Photo

Image Conversion (dll) [bmp,gif,jpg,png,ico]


  • Please log in to reply
40 replies to this topic

#1 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 10 May 2009 - 01:24 PM

Name: ImgConv (ImgConv.dll)
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):
PRE
// 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, bitmap to icon fails).
-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.
PRE
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.

  • 0

#2 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 10 May 2009 - 05:58 PM

Cool. Finally. I tried to find a library to make a dll in c++ to do this but none would compile. Most had multiple libraries which I had to get individually from multiple sources that no longer were compaitible.


Thanks.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#3 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 10 May 2009 - 06:22 PM

This dll was sooo easy to make that I feel kinda cheating on you (lol). I'll put the source above for people to see.
  • 0

#4 halo shg

halo shg

    Programmer

  • GMC Member
  • 600 posts
  • Version:GM:Studio

Posted 10 May 2009 - 06:41 PM

This is brilliant. Actually, I believe the DLL is 342kb, but you used UPX to shrink it to 151kb. Right?
You have convinced me to take up Delphi programming with all your amazing DLLs.

Anyways, thank your for making this DLL. I may add it to my upcoming project (depending on whether or not I need image conversion)
  • 0

Dev: MacBook Pro Retina Display 15" w/ Win7 (Parallels) running GM Studio: Master and GM8 (GMS: ANDROID JAVA EXTENSIONS ARE HERE!)
Devices: Samsung Galaxy Note II / Samsung Galaxy S III / iPhone 4S / iPad 2 / iPod Touch 5th gen



Politics' is made up of two words, 'poli,' which is Greek for 'many,' and 'tics,' which are blood-sucking insects.


-Gore Vidal


#5 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 10 May 2009 - 06:49 PM

This is brilliant. Actually, I believe the DLL is 342kb, but you used UPX to shrink it to 151kb. Right?

Yup. lol.

You have convinced me to take up Delphi programming with all your amazing DLLs.

Well, you know who to ask for help. However, unless you get your hands on Delphi7 personal, I'm afraid there isn't anything else free, except TurbuPascal (which is a bit limited) and FPC/Lazarus. Not sure if Lazarus can compile windows dlls? [it does] However, their VCL (well, it's wxwidgets, I think [not true, they support different widget sets including winapi/qt4/gtk]) increases exe size by 20megs :( [this is actually due to adding debug info to exe, the actual size is more or less like Delphi's].
However, the real Delphi works just fine; I fully blown GUI app in Delphi is at max 0.6 to 1 megabyte (similarly to GM exes). Removing VCL decreases size to like 18Kb (my font un/installer dll). And UPX seems to do a good job with the dlls too.
Anyway, good luck :D.

Kind regards,
Christian Sciberras.

Edited by uuf6429, 21 February 2010 - 12:35 AM.

  • 0

#6 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 10 May 2009 - 06:51 PM

This dll was sooo easy to make that I feel kinda cheating on you (lol). I'll put the source above for people to see.


From the libraries I found, yes it's not hard to make... But having them compile. That was my major hurdle. Consider adding compression value for those compression method that you can decide how much to compress.
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#7 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 10 May 2009 - 06:52 PM

From the libraries I found, yes it's not hard to make... But having them compile. That was my major hurdle.

Don't know if you know Delphi (or it's basic syntax) but the nice part is that object overloading is being used above.
All images formats are derived from TGraphic class. So, I just create and return the correct class to the filename. Then the rest, is using the created classes to convert (handle convertion) between them. The convertion part happens when a class uses Assign with a different (but compatible) class as parameter.
If you try loading a bitmap then choose to save as icon, you get an error message showing clearly that Assign() failed.

Consider adding compression value for those compression method that you can decide how much to compress.

I think they are at maximum, except jpeg which is lossy (I think it's at 70%-80%).

Edited by uuf6429, 10 May 2009 - 06:59 PM.

  • 0

#8 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 10 May 2009 - 07:08 PM

From the libraries I found, yes it's not hard to make... But having them compile. That was my major hurdle.

Don't know if you know Delphi (or it's basic syntax) but the nice part is that object overloading is being used above.
All images formats are derived from TGraphic class. So, I just create and return the correct class to the filename. Then the rest, is using the created classes to convert (handle convertion) between them. The convertion part happens when a class uses Assign with a different (but compatible) class as parameter.
If you try loading a bitmap then choose to save as icon, you get an error message showing clearly that Assign() failed.

Consider adding compression value for those compression method that you can decide how much to compress.

I think they are at maximum, except jpeg which is lossy (I think it's at 70%-80%).


So the image compression classes are already part of delphi? Even esasier then.

The icon fails because <pretty sure> you need to convert to a paleted image first. Check if you have a function in the class that reduces the bpp. Call it before the convertion. The size may also be a factor (16x16, 32x32).
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#9 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 10 May 2009 - 08:52 PM

So the image compression classes are already part of delphi? Even esasier then.

Not all, Delphi has classes in units. Default units are Graphics (everything from TGraphic to TBitmap and TIcon) and jpeg (for JPGs lol). The other two, png and gif are 3rd party components, which build on TGraphic.

The icon fails because <pretty sure> you need to convert to a paleted image first. Check if you have a function in the class that reduces the bpp. Call it before the convertion.

Don't know, doesn't icons support all colours? The gif conversion works, and it is worse with palettes.

The size may also be a factor (16x16, 32x32).

I think this is more likely, untested though.

Edited by uuf6429, 10 May 2009 - 08:56 PM.

  • 0

#10 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 11 May 2009 - 01:19 AM

Don't know, doesn't icons support all colours? The gif conversion works, and it is worse with palettes.

The size may also be a factor (16x16, 32x32).

I think this is more likely, untested though.


Gif to ico?
Gifs are 256 color palette... That's why it works. <Again, pretty sure>. Paleted images from true rbg is quite hard to make though. You have to figure the right color palete entries, balancing important color and apply dithering to colors that could not be added to the palete right in the image.

To confirm, Use Paint to save a BMP as 256 and another as 16 colors. Then call your code with the file to see...
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#11 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 11 May 2009 - 11:10 AM

Ok, I'll check.

Edit: tried changing 3 BMPs all 32x32: 24, 256, 16: None worked.

Edited by uuf6429, 11 May 2009 - 11:17 AM.

  • 0

#12 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 11 May 2009 - 09:03 PM

*ahem* ImageMagick *ahem*

That would be better for C, though.
  • 0

#13 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 11 May 2009 - 10:54 PM

Ok, I'll check.

Edit: tried changing 3 BMPs all 32x32: 24, 256, 16: None worked.


Bah, no one uses ico anyway.

*ahem* ImageMagick *ahem*

That would be better for C, though.

That's one of the libraries I tried (and failed) to compile. It uses another third party zip lib which the compiler kept complaining about... I gave up after a few hour of trying to figure out what was wrong with my dependencies. Oh and the project was a make file which made it impossible to figure where the problem was. And hard to convert to a dll project.

Edited by icuurd12b42, 11 May 2009 - 10:56 PM.

  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#14 PickleMan

PickleMan

    Programmer

  • New Member
  • 995 posts
  • Version:Unknown

Posted 11 May 2009 - 11:05 PM

That happened to me, except with the urlmon lib...score_under solved it...
  • 0

#15 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 13 May 2009 - 10:08 PM

Uh you guys. Don't you see developing dlls for wraping other dlls is futile, especially in this case?
Delphi can do this sort of stuff (directly), most probably even better then C.

Edit: Minor dll fixes. Icon conversion fully supported. A transparency color value may be specified (works like GM but you specify color instead of GM's bottom-left coordinate color). Due to this, the dll call has been increased to a new parameter, which specifies this trnasparency color.
In the future this may be used for GIFs or simple trnasparency PNGs.
Example of use:
ic_convert('my_bitmap.bmp','new_icon.ico',c_fuchsia);
As to how I fixed the bug, I'm afraid it will remain my little secret :D. However, I hint in some obscure WinAPI calls.

Kind regards,
Christian Sciberras.

Edited by uuf6429, 13 May 2009 - 10:13 PM.

  • 0

#16 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 16 May 2009 - 09:44 PM

Well just what I'd expect from Covac... Brilliant software, seems to produce the most decent dlls.
  • 0

Posted Image


#17 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 17 May 2009 - 02:29 PM

Uhm. Thanks, I guess :(
  • 0

#18 sealionone

sealionone

    GMC Member

  • New Member
  • 17 posts

Posted 19 May 2009 - 01:08 AM

there seems to be a problem with the transparency part, because when i use the dll to convert, the area that should become transparent stays opaque
  • 0

#19 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 18181 posts
  • Version:GM:Studio

Posted 19 May 2009 - 02:42 AM

there seems to be a problem with the transparency part, because when i use the dll to convert, the area that should become transparent stays opaque


Are you converting a file type that supports transparency to another one that supports transparency?
  • 0

gmcbanner.pnggmcbanner_tools.png

ICU Live Tutoring Through Slack or Skype | My Tools Page follow.png

I FRANTICALLY MADE MY 18000 POST TOPIC BEFORE MIKE ANNOUNCED A DELAY...
Now I'm squirming not to hit that reply button


#20 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 19 May 2009 - 07:20 PM

there seems to be a problem with the transparency part, because when i use the dll to convert, the area that should become transparent stays opaque

Details!! :) What was the original format, and what was your desired output?
  • 0

#21 DefuzionGames

DefuzionGames

    GMC Member

  • GMC Member
  • 1460 posts
  • Version:Unknown

Posted 25 May 2009 - 09:42 PM

covac...how come youre advanced into Gm esp developing totally unique complicated addons? what do you do for a living if you dont mind me asking?
  • 0

#22 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 26 May 2009 - 04:11 PM

covac...how come youre advanced into Gm esp developing totally unique complicated addons? what do you do for a living if you dont mind me asking?

Well, actually it's just some nice Delphi coding. And secondly, I work as a web developer (not any company's CEO lol).
Glad you like this addon.

Kind regards,
Christian Sciberras.
  • 0

#23 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 28 May 2009 - 05:47 PM

Sweet!
Just What i was looking for,Thanks allot,Good thing it is not another Fake that renames the file to whatever extension.
Edit:Why Does BMP To ICO Fail?,Isn't A BMP a Renamed ICO?

Edited by Recreate, 28 May 2009 - 10:33 PM.

  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#24 uuf6429

uuf6429

    Covac Software

  • New Member
  • 2522 posts
  • Version:Unknown

Posted 28 May 2009 - 07:15 PM

Good thing it is not another Fake that renames the file to whatever extension.

Well, actually it also does that :D lol.
Glad you like it.
  • 0

#25 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 29 May 2009 - 03:59 AM

Good thing it is not another Fake that renames the file to whatever extension.

Well, actually it also does that :D lol.
Glad you like it.

Well I meant good thing that it is not a fake,that Only Renames the file.
  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#26 Recreate

Recreate

    Furry

  • GMC Member
  • 2992 posts
  • Version:GM:Studio

Posted 30 June 2009 - 02:51 AM

Brilliant just what i was looking for!(yet again for another project :P )
EDIT:XD I did not notice that i replied to this, and i already said the same thing XD

Edited by Recreate, 30 June 2009 - 02:51 AM.

  • 0

If the post that you are reading was created prior to 2011. For the safety of the general public, It is not to be regarded under any circumstances.
Please don't ask me to join your group at anything.


#27 BlueMoonProductions

BlueMoonProductions

    BlueMoonProductions

  • GMC Member
  • 241 posts
  • Version:GM:Studio

Posted 20 October 2010 - 06:08 PM

Does someone have the DLL? (in his Downloads-directory or whatever?)
  • 0

#28 Armisticdoom

Armisticdoom

    GMC Member

  • New Member
  • 73 posts

Posted 02 January 2011 - 09:21 PM

Does someone have the DLL? (in his Downloads-directory or whatever?)


Yeah! I need this dll! please re-upload becuase the link is dead :(
  • 0

#29 OMGCarlos

OMGCarlos

    GMC Member

  • GMC Member
  • 329 posts
  • Version:GM:HTML5

Posted 15 January 2011 - 06:58 PM

Bump...I could really use this as well.
  • 0

#30 blendman

blendman

    GMC Member

  • GMC Member
  • 43 posts

Posted 22 January 2011 - 04:56 PM

Hi

I think it's the DLL that you're looking for :
http://www.host-a.ne...man/ImgConv.dll

Hope it can help ;).
  • 1

#31 jack1993jack

jack1993jack

    GMC Member

  • New Member
  • 231 posts

Posted 22 January 2011 - 11:10 PM

Useful and nice file size!
  • 0
Testing can be used to show the presence of bugs, but never to show their absence

#32 littleradatz

littleradatz

    GMC Member

  • New Member
  • 9 posts

Posted 24 January 2011 - 03:45 AM

Does anyone happen to have the GML scripts that go with this DLL?
  • 2

#33 Fat Kid In Your Fridge

Fat Kid In Your Fridge

    GMC Member

  • GMC Member
  • 85 posts
  • Version:GM:Studio

Posted 08 May 2011 - 03:18 PM

Yeah! All links R dead :angry: ! I need this DLL :( ! Can u plz reupload? :wacko:
  • 0

Wow.


#34 Razon

Razon

    GMC Member

  • GMC Member
  • 268 posts
  • Version:GM:Studio

Posted 10 May 2011 - 05:06 PM

Here's a mirror for all of the original files.

http://www.mediafire...w5w5pa23gbt3ogd


Edited by Razon, 26 May 2013 - 04:49 PM.

  • 1

#35 Fat Kid In Your Fridge

Fat Kid In Your Fridge

    GMC Member

  • GMC Member
  • 85 posts
  • Version:GM:Studio

Posted 11 May 2011 - 02:53 PM

@Razon
Thanks alot! :D
  • 0

Wow.


#36 Yevez

Yevez

    GMC Member

  • GMC Member
  • 36 posts
  • Version:GM8

Posted 11 August 2012 - 01:30 PM

LOL.You can convert photos without using DLL like this..GML is all u need.Believe ME....
  • 0

#37 eejin

eejin

    GMC Member

  • GMC Member
  • 82 posts
  • Version:GM8

Posted 24 May 2013 - 09:45 PM

Razon his link is dead. Does anyone still have the package?


  • 0

#38 Razon

Razon

    GMC Member

  • GMC Member
  • 268 posts
  • Version:GM:Studio

Posted 26 May 2013 - 04:51 PM

Here's a new mirror link for it.

 

http://www.mediafire...w5w5pa23gbt3ogd


  • 0

#39 eejin

eejin

    GMC Member

  • GMC Member
  • 82 posts
  • Version:GM8

Posted 27 May 2013 - 05:09 PM

Thank you :D. In case this might happen again, here is a direct link to another host: http://g2f.nl/0susd66


  • 0

#40 Needle

Needle

    GMC Member

  • GMC Member
  • 41 posts
  • Version:GM:Studio

Posted 07 June 2013 - 11:18 AM

download link doesn't work:

Server not found
        
          Firefox can't find the server at www.covac-software.com.

  Check the address for typing errors such as
    ww.example.com instead of
    www.example.com
  If you are unable to load any pages, check your computer's network
    connection.
  If your computer or network is protected by a firewall or proxy, make sure
    that Firefox is permitted to access the Web.

 


  • 0

:banana:NeedleGames's website! :banana:

 A few new games every month!


#41 eejin

eejin

    GMC Member

  • GMC Member
  • 82 posts
  • Version:GM8

Posted 07 June 2013 - 01:58 PM

There are two posts above you that contain links for the dll. 2? Yes 2. Please read a topic before posting. You can usually find new download links at the end of the topic.

Did I already mention there are two links above your post?


  • 0