hxformat - save ByteArray to png

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

hxformat - save ByteArray to png

go2ghana
Hi,
is it possible to save DisplayObject.loaderInfo.ByteArray into a png
file with hxformat?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxformat - save ByteArray to png

Cameron D
I don't know about hxformat, but there's an AS3 library (as3corelib) that supports this (http://code.google.com/p/as3corelib/wiki/Main). If you look at their code for taking a ByteArray and turning it into a PNG it actually isn't very long, so you could translate it into haXe if you have to.

Just an option to keep in mind if nothing better presents itself.

Cameron

On Thu, Nov 12, 2009 at 12:26 PM, Axel Huizinga <[hidden email]> wrote:
Hi,
is it possible to save DisplayObject.loaderInfo.ByteArray into a png file with hxformat?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxformat - save ByteArray to png

gershon
If you're willing to use php5-gd:

<?php
$data 
'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl'
       
'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr'
       
'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r'
       
'8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg==';
$data base64_decode($data);

$im imagecreatefromstring($data);
if (
$im !== false) {
    
header('Content-Type: image/png');
    
imagepng($im);
    
imagedestroy($im);
}
else {
    echo 
'An error occurred.';
}
?>
(taken from http://www.php.net/manual/en/function.imagecreatefromstring.php)

hopefully sending ByteArray.toString() to the script should work...


On Fri, Nov 13, 2009 at 3:56 AM, Cameron D <[hidden email]> wrote:
I don't know about hxformat, but there's an AS3 library (as3corelib) that supports this (http://code.google.com/p/as3corelib/wiki/Main). If you look at their code for taking a ByteArray and turning it into a PNG it actually isn't very long, so you could translate it into haXe if you have to.

Just an option to keep in mind if nothing better presents itself.

Cameron


On Thu, Nov 12, 2009 at 12:26 PM, Axel Huizinga <[hidden email]> wrote:
Hi,
is it possible to save DisplayObject.loaderInfo.ByteArray into a png file with hxformat?

Cordially,
Axel

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: hxformat - save ByteArray to png

Nicolas Cannasse
In reply to this post by go2ghana
Axel Huizinga a écrit :
> Hi,
> is it possible to save DisplayObject.loaderInfo.ByteArray into a png
> file with hxformat?
>
> Cordially,
> Axel

Yes, since 1.14, hxformat have support for PNG.

You can to use this class in order to build your PNG from ByteArray :
http://lib.haxe.org/d/format/1.14/format/png/Tools

Nicolas

--
haXe - an open source web programming language
http://haxe.org