Jump to content


Photo

How to convert 32-bits to 24-bits PNG


  • Please log in to reply
9 replies to this topic

#1 William Lima

William Lima

    GMC Member

  • GMC Member
  • 10 posts
  • Version:Unknown

Posted 26 October 2012 - 01:44 AM

I wanna convert a 32-bits PNG image from GM into a 24-bits PNG image.
Script, DLL, Extension?

I have saved a image into a file_bin, at first I wrote the dimensions on 6 bytes, 3 for the image height and 3 for the image width, so the pixel color I wrote on 3 bytes, 1 for red, 1 for green and 1 for blue (RGB).
I read it in the same mode.

I want to make it read a 32 bit PNG , convert it into a file_bin and import the image from the file bin in 24-bit PNG.

Link of my project!

Thanks.

Edited by _259817, 26 October 2012 - 02:35 AM.

  • 1

#2 icuurd12b42

icuurd12b42

    Self Formed Sentient

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

Posted 26 October 2012 - 02:41 AM

Why?
  • 0

#3 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2736 posts
  • Version:Mac

Posted 26 October 2012 - 02:46 AM

I don't understand what you're trying to do. You just want to discard the alpha channel when you load it into GameMaker? Doesn't sprite_add() already do that? Or is that not what you mean by "import the image"?

Edited by dannyjenn, 26 October 2012 - 02:47 AM.

  • 0

#4 William Lima

William Lima

    GMC Member

  • GMC Member
  • 10 posts
  • Version:Unknown

Posted 26 October 2012 - 11:48 AM

Because my friend is making a map editor for another game that only reads png 24-bits.
And I think my program could make the convertion. :S
Someone have a way to do that?

I said "import " the image from the binary file that I've created. you can see it on the project.

I have the 3 channels on rgb, when I load the image from the file_bin. Can I make the image 24-bits?
Another friend told me that its hard...

Edited by _259817, 26 October 2012 - 12:56 PM.

  • 0

#5 TheSpocker

TheSpocker

    GMC Member

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

Posted 26 October 2012 - 04:00 PM

Gimp can do this.

http://www.gimp.org/downloads/

I just tried to export an image to .png and that one was 24 bits so I think that program should work.
  • 0

#6 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2736 posts
  • Version:Mac

Posted 26 October 2012 - 04:27 PM

If you want to make this in GameMaker, it can be done. Look into the file format of the PNG ( http://www.fileforma.../png/corion.htm ) and use the bin file functions to load in each byte, decompress it manually, then re-write it without the alpha channel. I can't help you further as I haven't really looked into the PNG compression algorithm.
  • 2

#7 William Lima

William Lima

    GMC Member

  • GMC Member
  • 10 posts
  • Version:Unknown

Posted 26 October 2012 - 05:37 PM

Thanks everyone. I will try to re-write the chunk in Game Maker with file_bin functions!
http://www.libpng.or...PNG-Chunks.html
http://www.w3.org/TR/PNG-Chunks.html

I found this!
  • 0

#8 icuurd12b42

icuurd12b42

    Self Formed Sentient

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

Posted 26 October 2012 - 08:36 PM

save as BMP
use this code to load the map
http://gmc.yoyogames...howtopic=488086
  • 1

#9 William Lima

William Lima

    GMC Member

  • GMC Member
  • 10 posts
  • Version:Unknown

Posted 26 October 2012 - 11:36 PM

save as BMP
use this code to load the map
http://gmc.yoyogames...howtopic=488086

The game only reads png-24 bits :/
Anyway thanks!
  • 0

#10 icuurd12b42

icuurd12b42

    Self Formed Sentient

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

Posted 27 October 2012 - 01:37 AM


save as BMP
use this code to load the map
http://gmc.yoyogames...howtopic=488086

The game only reads png-24 bits :/
Anyway thanks!



You know GM loads PNG files... you can save as BMP to a temp file. Pretty sure that will be faster than trying to decode a png file in gml. the BMP script does not care if it's 24 or 32 bits.

Anyway, if you figure it out please share
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users