1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
import mx.utils.Delegate;
btn2.onRelease = Delegate.create(this,export);
function export() {
var lv:LoadVars = new LoadVars();
// dÈtermine la zone de pixels envoyer
lv.largeur = zone._width;
lv.hauteur = zone._height
var xmin = Math.floor(zone._x);
var ymin = Math.floor(zone._y);
// on crÈe un bitmap la bonne taille
var bitmap1:BitmapData = new BitmapData(800, 500);
bitmap1.draw(this, new Matrix(), new ColorTransform() , "normal", new Rectangle(0, 0, 800, 500), false);
var bitmap:BitmapData = new BitmapData(lv.largeur, lv.hauteur);
bitmap.copyPixels(bitmap1,new Rectangle(xmin,ymin,lv.largeur,lv.hauteur), new Point(0,0));
lv.pixels = "";
for(var y = 0; y<lv.hauteur; y++){
for(var x =0; x<lv.largeur; x++){
var hexa = bitmap.getPixel(x,y).toString(16);
switch(hexa.length){
case 5:
hexa = '0'+hexa;
break;
case 4:
hexa = '00'+hexa;
break;
case 3:
hexa = '000'+hexa;
break;
case 2:
hexa = '0000'+hexa;
break;
case 1:
hexa = '00000'+hexa;
break;
}
lv.pixels+=hexa;
}
}
lv.send("http://www.buzzfactory.fr/2009/createjpg.php", "_blank", "POST");
}; |
Partager