Standalone avatar image generator + JavaScript Closets [Rev35]

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jul 4, 2007
Messages
96
Reaction score
140
Standalone avatar image generator [R63]

 

Is there a demand for now I do'nt know but, it was released because I almost completed.
I hope you will find it helpful.

Is not dependent on the generator of official server, I made a generator of complete standalone.
It works by using the GD library in PHP.
It is extracted from SWF of revision 63 figure image used for resource.

use image cast revision: LASTEST



* This JavaScript is one of the use cases. To use the PHP code that is distributed, must be incorporated into the code yourself.




Update

* need first run "resourse_update.php".

May.10.2015 / version 1.2.8 beta release
- supports more options for part-generator
- fixed alpha blend
- fixed renderer for large size
- fixed resource_update.php
- fixed bugs (indicated by Jer)

Apr.14.2015 / version 1.2.5 release

- support R63 casts.
- rewrite many code for processing speed. (successful to less than 100ms)
- included swf dump tool "resource_update.php".
 
Last edited:
Joined
Apr 30, 2007
Messages
2,339
Reaction score
1,547
Needed something like this for a while. Hopefully someone can extract the r63 clothes for you so we can start using our own hosted avatars.

Big ups, Tsuka - surprised you're still around. I remember using your customs and hotel views when I was 12 and 13. Being Japanese, I can see why you base your stuff around cars
 
☮TAKU????
Loyal Member
Joined
Nov 16, 2009
Messages
866
Reaction score
580
Creds for the json structures? ^^

I could extract from r63
 
Initiate Mage
Joined
Dec 27, 2006
Messages
3
Reaction score
3
Very nice project!

I have a similar script who uses SWF and XML files. Its development is not finished yet so there are still some errors, but extraction from SWF works fine. If you need help I am available

Here is the thread of my project (on a French board):
  • Original:
  • Translated:
 
Joined
Feb 22, 2012
Messages
2,103
Reaction score
1,271
Jesus Tsuka! Nice job you've maded in there! Each day we are progressing, and needing less of habbo resources!

I'll open a oldskool and I'll embed this in register/image change (and make via RCON to exec the oof command automactly)!

Thanks a lot for this man!
 
Newbie Spellweaver
Joined
Jul 4, 2007
Messages
96
Reaction score
140
Creds for the json structures? ^^

I could extract from r63

I wrote a program that automatically output unique JSON format...
and performance problems, it might change in the method to read the XML directly.

Now developing program that generates resources by automatically dump the SWF of R63.



good. similar project

my project is likely take a long time, because I don't know the figure parts structure of R63.
I'll unhurriedly analyzes...
 

PR0

Legendary Battlemage
Joined
Mar 3, 2007
Messages
690
Reaction score
85
TSUKA! Konnichiwa!

Good to see you back on here This has made my day. I have no idea what this can be used for though because I'm a junior dev.

Can anyone explain in noob-friendly detail with what this is for, what it does, and what it is used for?


Thanks! !!!
Tsuka

Hey so I check into your blogs that you have every once in a while and they always have the most unique development I can find on there! Can you give an update to some new and unique features you've made so far?

That's a cool driving simulation setup you have too btw. haha.
 
Last edited:
Initiate Mage
Joined
Dec 27, 2006
Messages
3
Reaction score
3
@Tsuka: I can send you my avatar imager for the body parts if you want.

I've written a little script to extract data from SWF files.
Maybe it can help you or someone else to understand how SWF files are structured

PHP:
<?php

/**
 * Extraction of tags from SWF file
 *
 * @author Antoinee <anb505.spam@outlook.fr>
 * [USER=316612]Version[/USER] 0.0-20150804
 * [USER=585868]Lice[/USER]nse [url]http://opensource.org/licenses/MIT[/url] MIT License
 */

define('INPUT_FILE', 'input.swf');
define('OUTPUT_DIRECTORY', './output');

chdir(__DIR__);

function swf_read_DefineBitsLossless2($raw_data) {

    // Data length
    $data_length = strlen($raw_data) - 7;

    // Assuming that BitmapFormat = 5
    $tag = unpack('vsymbol_id/Cformat/vwidth/vheight', $raw_data);
    $data = gzuncompress(substr($raw_data, 7));

    if ($tag['format'] != 5) {

        echo "BitmapFormat = {$tag['format']}\tSkip this tag\r\n";
        return [];
    }

    $im = imagecreatetruecolor($tag['width'], $tag['height']);
    
    imagefill($im, 0, 0, 0x7fffffff);

    for ($y = 0; $y < $tag['height']; $y++) {

        for ($x = 0; $x < $tag['width']; $x++) {

            list(, $color) = unpack('N', $data);
            $data = substr($data, 4);

            imagesetpixel($im, $x, $y, $color);
        }
    }

    $tag['im'] = $im;

    return $tag;
}

function swf_read_SymbolClass($raw_data) {

    // Read the number of symbols
    list(, $number_of_symbols) = unpack('v', substr($raw_data, 0, 2));

    $raw_data = substr($raw_data, 2);

    // Read all symbols
    // for ($symbols = []; count($symbols) < $number_of_symbols; ) {
    for ($symbols = []; strlen($raw_data); ) {

        extract(unpack('vsymbol_id/Z*symbol_value', $raw_data));
        $symbols[$symbol_id] = $symbol_value;

        $raw_data = substr($raw_data, 2 + strlen($symbol_value) + 1);
    }

    return $symbols;
}

function swf_read_DefineBinaryData($raw_data) {

    // Data length
    $data_length = strlen($raw_data) - 6;

    return unpack('vsymbol_id/V/Z' . $data_length . 'data', $raw_data);
}

function swf_extract($swf_file) {

    // Read SWF file
    $raw_data = file_get_contents($swf_file);

    // Uncompress SWF data
    if (substr($raw_data, 0, 3) == 'CWS') {

        $raw_data = 'F' . substr($raw_data, 1, 7) . gzuncompress(substr($raw_data, 8));
    }

    // File length
    list(, $file_length) = unpack('V', substr($raw_data, 4, 4));

    // Header length
    $header_length = 8 + 1 + ceil(((ord($raw_data[8]) >> 3) * 4 - 3) / 8) + 4;

    // Output arrays
    $pngs = [];
    $xmls = [];

    // Read tags
    for ($cursor = $header_length; $cursor < $file_length; ) {

        // Read tag header
        list(, $tag_header) = unpack('v', substr($raw_data, $cursor, 2));
        $cursor += 2;

        list($tag_code, $tag_length) = [$tag_header >> 6, $tag_header & 0x3f];

        // Read long tag header
        if ($tag_length == 0x3f) {

            list(, $tag_length) = unpack('V', substr($raw_data, $cursor, 4)); // Must be signed!
            $cursor+= 4;
        }

        // Read tag body
        switch ($tag_code) {

            // DefineBitsLossless2
            case 36:
                $tag = swf_read_DefineBitsLossless2(substr($raw_data, $cursor, $tag_length));
                $pngs[$tag['symbol_id']] = $tag['im'];
            break;

            // SymbolClass
            case 76:
                $symbols = swf_read_SymbolClass(substr($raw_data, $cursor, $tag_length));
            break;

            // DefineBinaryData
            case 87:
                $tag = swf_read_DefineBinaryData(substr($raw_data, $cursor, $tag_length));
                $xmls[$tag['symbol_id']] = $tag['data'];
            break;
        }

        // Go to the next tag
        $cursor+= $tag_length;

        // Exit loop if End tag
        // $tag_code != 0 ? : break;
    }

    foreach ($xmls as $symbol_id => $xml) {

        $name = isset($symbols[$symbol_id]) ? $symbols[$symbol_id] : 'symbol_' . $symbol_id;

        // if (file_exists(OUTPUT_DIRECTORY . '/' .$name . '.xml')) {

        //     $name.= '_' . substr(md5(microtime(true)), 0, 8);

        //     echo $name,PHP_EOL;
        // }

        file_put_contents(OUTPUT_DIRECTORY . '/' . $name . '.xml', $xml);
    }

    foreach ($pngs as $symbol_id => $png) {

        $name = isset($symbols[$symbol_id]) ? $symbols[$symbol_id] : 'symbol_' . $symbol_id;

        // if (file_exists(OUTPUT_DIRECTORY . '/' .$name . '.png')) {

        //     $name.= '_' . substr(md5(microtime(true)), 0, 8);

        //     echo $name,PHP_EOL;
        // }

        imagepng($png, OUTPUT_DIRECTORY . '/' . $name . '.png');
    }
}

swf_extract(INPUT_FILE);
 
Newbie Spellweaver
Joined
Jul 4, 2007
Messages
96
Reaction score
140

thats interesting.

I also developed process of similar dump program before, but more of your code is light.
I developing extract tool now using it.


 
☮TAKU????
Loyal Member
Joined
Nov 16, 2009
Messages
866
Reaction score
580
holy poop this is bringing it to a whole new level
 
Status
Not open for further replies.