You are not logged in.

#1 2009-01-15 20:38:07

_CONEJO
Member

[RESOLVED] GRRLIB 1.6 Converter

yeah... i'm strange. I'm using GRRLIB 1.6, I like the way to handle every pixel on the screen directly. The thing is that i'm using it ( i wanted to access the buffer directly, and since the game doesn't use so much cpu i could do it), so the problem is that the converter doesn't work on my xp (virtualized under ubuntu) and the .PHP versión... i'm missing something, i dont know how to use it at all...


Any help?

Offline

 

#2 2009-01-15 21:46:16

Crayon
Bad Mother Fucker

Re: [RESOLVED] GRRLIB 1.6 Converter

Hi _CONEJO, are you using the latest version of GRRLIB Converter now called WiiBuilder (http://wiibrew.org/wiki/WiiBuilder)?

If yes, can you tell me what is your problem in your virtual Windows XP.

Last edited by Crayon (2009-01-15 21:46:45)

Offline

 

#3 2009-01-15 22:16:23

_CONEJO
Member

Re: [RESOLVED] GRRLIB 1.6 Converter

i was using the one with is bundle with GRRLIB1.6

I already solved the problem, the file was sended with a form or something (the PHP version)... i just "patch it" to read a dir and convert every file.

Offline

 

#4 2009-01-16 09:17:26

_CONEJO
Member

Re: [RESOLVED] GRRLIB 1.6 Converter

The resulting code is this :

<?php

function grrlib_converter($img) {
    // GRRLIB GFX convertor (png to C array)
    // This file is part of the GRRLIB package for WII
    // info : http://wiibrew.org/index.php?title=Homebrew_apps/GRRLIB

    $im = ImageCreateFromPng($img.".png");
    $img_high = imagesy($im);
    $img_width = imagesx($im);

    $file = fopen($img.".h", "w+");


    fwrite($file, "// Bitmap file from ".$img.".png\n");
    fwrite($file, "// Converted With moulinette included in GRRLIB package\n\n");
    fwrite($file, "const int ".$img."_high=".$img_high.";\n");
    fwrite($file, "const int ".$img."_width=".$img_width.";\n\n");
    fwrite($file, "const u16 ".$img."_img[]={\n");

    for($y=0;$y<$img_high;$y++){
      for($x=0;$x<$img_width;$x++){
        $cpt++;
        $rgb = ImageColorAt($im, $x, $y);
        $r = intval(((($rgb >> 16) & 0xFF)*31)/255);
        $g = intval(((($rgb >> 8) & 0xFF)*63)/255);
        $b = intval(((($rgb) & 0xFF)*31)/255);


    $toto=((($r)<<6)|$g);
    $plop=((($toto)<<5)|$b);

        $result = base_convert($plop,10,16);
        fwrite($file,"0x".$result);
        if($cpt!sad$img_high*$img_width))
        fwrite($file,",");
      }
      fwrite($file,"\n");
    }
    fwrite($file,"};\n\n");
    fclose($file);

    echo $img.".h was created!<br>";   

};




function readDirr($dir) {

    $handle = opendir($dir);

    while (false!=sad$FolderOrFile = readdir($handle))) {

        if($FolderOrFile != "." && $FolderOrFile != ".." && $FolderOrFile != "_vti_cnf") { 

            $name = str_ireplace(".png", "", $FolderOrFile);

            if(!is_dir("$dir/$FolderOrFile") && $name!=$FolderOrFile) {
                grrlib_converter($dir."/".$name);
            } else {
                // to make it recursive
                // readDirr($dir."/".$FolderOrFile);
            }
    

        } 

    }



    closedir($handle);
   

}


if(isset($_GET['dir'])) {

    readDirr($_GET['dir']);
} else {
    readDirr("./");
};




?>

you could specify a directory or it will read the actual dir. Only usefull if you run a webserver with PHP (which happen in my case)

Offline

 

Board footer

Powered by FluxBB