Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / JPG support
- By bestguigui Date 2009-08-01 06:58
Hello everyone !

I'm currently working on a game project, a QIX like one. The one I'm creating this game for wants to use pictures in jpg format, and I have to convert these to png to be able to display them on a Gosu Window...

In this game, the player has to discover what the picture is, because at the begining it's hidden and to reveal it gives him a gift : the full picture. So, when the level is finished, the player gets the full image in proper jpg format.

I'm programming this for a person who wants to use personnal pictures as a gift for another one, to personnalize the engine I'm making. What I don't want is to force him to make two versions of the pictures, one as the gift in jpg format and one for gosu, a png one.

I want to give him the game as an exe file, using rubyscript2exe, so Rmagick is not useable, because it doesn't seem to work with rubyscript2exe. Would you know another way to convert a jpg file to a png file, with a fixed size, like 800*600 ?

It's not necessary to display the full jpg file, the gift when a level is finished with success, I'll only display a message like "Cool ! You displayed picture # 1 ! Go watch it on #{path} !", but I really need to get a png file without creating it under Photoshop or another graphic program.

Can anyone help me ?
P.S. : sorry for my very bad english, but I'm french and school is so far away now...
- By bestguigui Date 2009-08-01 07:20
I'm auto-replying because I kinda find a pretty way to do this ! I'm using WxRuby, which is useable width rubyscript2exe. I made a very simple function to achieve my goal :

require "wx"

def ConvertImage(filename, width, height) + ".jpg", Wx::BITMAP_TYPE_JPEG).scale(width, height).save_file(filename + ".png", Wx::BITMAP_TYPE_PNG)

ConvertImage("test_file", 640, 480)

this code will produce a 640 * 480 png file called test_file.png, from another file : test_file.jpg, which was for example 1024 * 768.
Maybe it can help someone, so I posted it :)
Up Topic Gosu / Gosu Exchange / JPG support

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill