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
|
private function chargementTermine(evt:Event):void
{
var objLoaderInfo:LoaderInfo = evt.currentTarget as LoaderInfo;
//trace('loaderinfo:',objLoaderInfo.bytesTotal, int(objLoaderInfo.bytesTotal / 1024), objLoaderInfo.width, objLoaderInfo.height, objLoaderInfo.url, objLoaderInfo.contentType);
// image chargée
var image:Bitmap = evt.currentTarget.content as Bitmap;
// on garde la taille de l'image
dpFiles[_ind].w = image.width;
dpFiles[_ind].h = image.height;
//voir si l'on doit ou pas créer la vignette
var maVignette:File = _appDir.resolvePath("monappli/projets/aux_vignettes/" + dpFiles[_ind].nom_vignette );
// nouveau bitmapdata de la taille de la vignette
bitmapData = new BitmapData(100,100);
var rate:Number;
var _tx:Number, _ty:Number = 0;
if (image.width > image.height) {
rate = (image.width / 100);
_tx=0;
_ty = ((image.width - image.height)/2);
}
else {
rate = (image.height / 100);
_ty=0;
_tx = ((image.height - image.width)/2);
}
//trace('rate',rate)
ma = image.transform.matrix;
ma.tx = _tx;
ma.ty = _ty;
ma.scale(1/rate,1/rate);
bitmapData.draw(image, ma);
var ba:ByteArray = new ByteArray();
try {
ba = PNGEncoder.encode(bitmapData);
}
catch (e:Error) {
Alert.show("Attention nous rencontrons de problèmes de mémoire lors de la création des vignettes. Fermez tous vos applicatifs lourds et relancez lisxpert. Merci","Erreur d'encodage");
ba = PNGEncoder.encode(bitmapData);
}
savePicture( ba, _nomVignette );
image = null;
ba.clear();
ba = null;
btn3.visible = true;
} |
Partager