poko imageprocessor transparency

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

poko imageprocessor transparency

postite
Hello list , hello poko users 
is there a way to preserve png transparency when using poko.ImageProcessor ?

thx

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

Re: poko imageprocessor transparency

Tony Polinelli
looks like a GD.imageSaveAlpha(newResource,true) might need to be added into the process somewhere needed. As per:


i'll take a look at it tomor, but if your in a hurry - just add those lines where it creates the new resources. (or read that post better than i did ;P )





On Tue, Dec 14, 2010 at 10:28 PM, dav kert <[hidden email]> wrote:
Hello list , hello poko users 
is there a way to preserve png transparency when using poko.ImageProcessor ?

thx

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



--
Tony Polinelli
http://touchmypixel.com

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

Re: poko imageprocessor transparency

victor / tokiop
In reply to this post by postite
Hi Dav and Tony,

maybe not efficient but should work (don't remember when i used this),
added a few lines in each method like this :

     public function applyFitSize(maxWidth:Int, maxHeight:Int)
     {
         var ow:Int = GD.imageSX(resource);
         var oh:Int = GD.imageSY(resource);

         var scale:Float = 1;

         if (ow > maxWidth) scale = maxWidth / ow;
         if (oh*scale > maxHeight) scale *= maxHeight/(oh*scale);

         var nw:Int = Std.int(ow * scale);
         var nh:Int = Std.int(oh * scale);
         if (nw < 1) nw = 1;
         if (nh < 1) nh = 1;

         var newResource:ImageResource = GD.imageCreateTrueColor(nw, nh);

         // use alpha
         GD.imageAlphaBlending(newResource, false);
         GD.imageSaveAlpha(newResource,true);
         var transparent = GD.imageColorAllocateAlpha(newResource, 255,
255, 255, 127);
         GD.imageFilledRectangle(newResource, 0, 0, nw, nh, transparent);

         var success = GD.imageCopyResampled(newResource, resource, 0,
0, 0, 0, nw, nh, ow, oh);
         if (!success) throw("There was an error resizing the image");

         resource = newResource;
     }

have a nice day ;)

Victor

Le 14/12/10 12:28, dav kert a écrit :
> Hello list , hello poko users
> is there a way to preserve png transparency when using
> poko.ImageProcessor ?
>
> thx


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

Re: poko imageprocessor transparency

Tarwin Stroh-Spijer
Thanks Victor.

I was so excited to see people using Poko I added support for transparent PNGs. The easiest way to check it out is on the latest repo - there's an example under "Image Processing" that uses the new feature.

Also added paging and tabulation to data lists! Yay!


Tarwin Stroh-Spijer
_______________________

Touch My Pixel
http://www.touchmypixel.com/
phone: +61 3 8060 5321
_______________________


On Tue, Dec 14, 2010 at 11:33 PM, Victor / tokiop <[hidden email]> wrote:
Hi Dav and Tony,

maybe not efficient but should work (don't remember when i used this), added a few lines in each method like this :

   public function applyFitSize(maxWidth:Int, maxHeight:Int)
   {
       var ow:Int = GD.imageSX(resource);
       var oh:Int = GD.imageSY(resource);

       var scale:Float = 1;

       if (ow > maxWidth) scale = maxWidth / ow;
       if (oh*scale > maxHeight) scale *= maxHeight/(oh*scale);

       var nw:Int = Std.int(ow * scale);
       var nh:Int = Std.int(oh * scale);
       if (nw < 1) nw = 1;
       if (nh < 1) nh = 1;

       var newResource:ImageResource = GD.imageCreateTrueColor(nw, nh);

       // use alpha
       GD.imageAlphaBlending(newResource, false);
       GD.imageSaveAlpha(newResource,true);
       var transparent = GD.imageColorAllocateAlpha(newResource, 255, 255, 255, 127);
       GD.imageFilledRectangle(newResource, 0, 0, nw, nh, transparent);

       var success = GD.imageCopyResampled(newResource, resource, 0, 0, 0, 0, nw, nh, ow, oh);
       if (!success) throw("There was an error resizing the image");

       resource = newResource;
   }

have a nice day ;)

Victor

Le 14/12/10 12:28, dav kert a écrit :

Hello list , hello poko users
is there a way to preserve png transparency when using poko.ImageProcessor ?

thx


--
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: poko imageprocessor transparency

victor / tokiop
Nice, paging is definately a nice addition ! Have to catch back with
latest version and port a few modifications ! Poko is a great tool !

Le 14/12/10 13:52, Tarwin Stroh-Spijer a écrit :

> Thanks Victor.
>
> I was so excited to see people using Poko I added support for
> transparent PNGs. The easiest way to check it out is on the latest
> repo - there's an example under "Image Processing" that uses the new
> feature.
>
> Also added paging and tabulation to data lists! Yay!
>
>
> Tarwin Stroh-Spijer
> _______________________
>
> Touch My Pixel
> http://www.touchmypixel.com/
> phone: +61 3 8060 5321
> _______________________


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

Re: poko imageprocessor transparency

Tarwin Stroh-Spijer
Please send the modifications over if you want them integrated into the trunk. Would love to see what you've been doing with it!

Is there anything other than URL re-writing that you'd love in there? That's the main thing we think that's missing (and some kind of optional structured controller that has a function that takes params automatically from the URL?)

Regards,


Tarwin Stroh-Spijer
_______________________

Touch My Pixel
http://www.touchmypixel.com/
phone: +61 3 8060 5321
_______________________


On Wed, Dec 15, 2010 at 8:00 PM, Victor / tokiop <[hidden email]> wrote:
Nice, paging is definately a nice addition ! Have to catch back with latest version and port a few modifications ! Poko is a great tool !

Le 14/12/10 13:52, Tarwin Stroh-Spijer a écrit :

Thanks Victor.

I was so excited to see people using Poko I added support for transparent PNGs. The easiest way to check it out is on the latest repo - there's an example under "Image Processing" that uses the new feature.

Also added paging and tabulation to data lists! Yay!


Tarwin Stroh-Spijer
_______________________

Touch My Pixel
http://www.touchmypixel.com/
phone: +61 3 8060 5321
_______________________


--
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: poko imageprocessor transparency

postite
In reply to this post by Tarwin Stroh-Spijer
wow thanks tarwin & victor 

i surely will implement those new feature in my project 
thank you so much for your quick answers and solution 

hey victor .
j'ai regardé ton portfolio (tu fais de chouettes trucs ) y'en a un que tu a fait avec poko ?

dav


On Tue, Dec 14, 2010 at 1:52 PM, Tarwin Stroh-Spijer <[hidden email]> wrote:
Thanks Victor.

I was so excited to see people using Poko I added support for transparent PNGs. The easiest way to check it out is on the latest repo - there's an example under "Image Processing" that uses the new feature.

Also added paging and tabulation to data lists! Yay!


Tarwin Stroh-Spijer
_______________________

Touch My Pixel
http://www.touchmypixel.com/
phone: +61 3 8060 5321
_______________________



On Tue, Dec 14, 2010 at 11:33 PM, Victor / tokiop <[hidden email]> wrote:
Hi Dav and Tony,

maybe not efficient but should work (don't remember when i used this), added a few lines in each method like this :

   public function applyFitSize(maxWidth:Int, maxHeight:Int)
   {
       var ow:Int = GD.imageSX(resource);
       var oh:Int = GD.imageSY(resource);

       var scale:Float = 1;

       if (ow > maxWidth) scale = maxWidth / ow;
       if (oh*scale > maxHeight) scale *= maxHeight/(oh*scale);

       var nw:Int = Std.int(ow * scale);
       var nh:Int = Std.int(oh * scale);
       if (nw < 1) nw = 1;
       if (nh < 1) nh = 1;

       var newResource:ImageResource = GD.imageCreateTrueColor(nw, nh);

       // use alpha
       GD.imageAlphaBlending(newResource, false);
       GD.imageSaveAlpha(newResource,true);
       var transparent = GD.imageColorAllocateAlpha(newResource, 255, 255, 255, 127);
       GD.imageFilledRectangle(newResource, 0, 0, nw, nh, transparent);

       var success = GD.imageCopyResampled(newResource, resource, 0, 0, 0, 0, nw, nh, ow, oh);
       if (!success) throw("There was an error resizing the image");

       resource = newResource;
   }

have a nice day ;)

Victor

Le 14/12/10 12:28, dav kert a écrit :

Hello list , hello poko users
is there a way to preserve png transparency when using poko.ImageProcessor ?

thx


--
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