HIDIHO!

giving something back to the Flash community

Scale2x, scale3x AS3

Tags: , , , , , , ,

cover
Having been sick for the whole week, my fellow boss (and nonetheless friend) Aurélien MSNed me yesterday something like:
“As you’re not doing much those days (I was at home) why don’t you try to port the Hq4x algorithm?” which I interpreted as “you dumb fuck!” he then sent me a couple of links…

Hereunder are the links he sent me:

 

so off I went reading, and tthe more I read, the less I could get the point & technique. Until the third link (scale2x) where the guy explains clearly what it’s all about plus gives an optimized C code to perform the operation which is very nice of him.

So this class is merely a porting of the Scale2x and scale3x algorithms. I don’t got much to say other than what is said in the articles of the guys above. Well just that a scale2x will double the output image size and a scale3x will … triple it ! :)

 

here’s a couple of examples, the class is so simple ( 2 static methods ) that it’s not even worth putting a demo *.fla. it goes like:

 

 var bmpd:BitmapData = ScalerX.scale2x( originalBitmapData );

 

tricky huh?! :)

now what does it do ?

 


scale2X: processes the image on a connexity 4 model, smooth but can be better

 


scale3x: connexity 8 scheme, smoother than the 2x version yet the best is to double or combine them

 


now the ’scale4x’ treaterously called so is in fact a double scale2x ^^, it starts giving pretty nice results =)

the blond guy picture comes from HiEnd3d, “original agrandi” means “stretched original” and “la vieille ruse” means “the old trick”, the word ‘trick’ being feminine in french

 


scale9x: “harder, faster, better, stronger” a double scale3x, you can see that from a 25*25 pix pattern, you can get a very detailed map

 

now here’s the class:

 

As far as perspectives are concerned, I’d say there’s a lot to do with it; rescaling of course it’s the basic purpose of the algorithm. But also, while testing I couldn’t help thinking of Worms 1, the terrain generator (check scaler9x result). It could be a way to store minimaps and magnify them at runtime. as it’s quite a demanding process, using it on moving pictures is suicidal, yet on a very small animation, it could give nice results ;).

 

indeed that script loves indexed colors, previously I did a color reducer and recently optimized it by 30% using thresholds instead of palettemaps (soon to be blogged). I guess this could be a nice preprocessing for jpg pictures :)

 

now that was it, I think we should all be thanksful to Aurélien for having highlighted the script and taken me to port it to AS

Tags: , , , , , , ,

© 2009 HIDIHO!. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.