gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Charas-project for PAGfx

#174352 - padnoter - Wed Jun 02, 2010 6:30 pm

Hi,

I've recently found http://www.charas-project.net/charas2 which is excellent, but only seems to produce a 3x4 sheet of 24x32 sprites. I'm using palib/PAGfx which (as far as I can see) requires 32x32 sprites in a one column sheet.

Does anyone know how to either get charas to save as a 1x12 sheet in 32x32 or does anyone have an easy way to convert the 3x4 sheet into a PAGfx friendly format? I can do it in GIMP, but it takes me a while of cutting & pasting (fiddly pixel line up etc).

Any ideas/help appreciated?

Thanks
pn.

#174447 - padnoter - Sun Jun 13, 2010 10:48 am

Scripted it in PHP in the end. Code is here, just in case it helps anyone;

Code:

<?php
echo "start conversion\n";
$fileext='.png';
$filein='/opt/devkitpro/PAlib/pl_development_area/LargeMaps2d/gfx/soldier';
$fileout=$filein."out2".$fileext;
$filein.=$fileext;
echo $filein."\n=>\n".$fileout."\n";
$im = imagecreate(32, 288)
    or die("Cannot Initialize new GD image stream");
$magenta_background = imagecolorallocate($im, 255, 0, 248);
$imin = imagecreatefrompng($filein);
$dsty=0;
if (imagecopy($im,$imin,4,$dsty,24,0,24,32))
   echo "sprite 2 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,0,0,24,32))
   echo "sprite 1 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,48,0,24,32))
   echo "sprite 3 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,24,32,24,32))
   echo "sprite 5 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,0,32,24,32))
   echo "sprite 4 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,48,32,24,32))
   echo "sprite 6 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,24,64,24,32))
   echo "sprite 8 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,0,64,24,32))
   echo "sprite 7 copied\n";
$dsty+=32;
if (imagecopy($im,$imin,4,$dsty,48,64,24,32))
   echo "sprite 9 copied\n";
$green = imagecolorclosest ( $im,  32, 156,0 ); // get green colour
imagecolorset($im,$green,255, 0, 248); // change green to MAGENTA
echo "change green background to magenta\n";
if (imagepng($im,$fileout))
   echo "created\n";
?>


Couldn't see how to attach example graphic files.


cheers