2

I am working with large bitmapdata that I need to resize, doing some test I realized that the same code runs tooooo slow in AIR.

This is the code:

import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.display.Bitmap;
import flash.geom.Point;

var MAX_BITMAP_SIZE:Point = new Point( 596, 842 );

var bitmapdata:BitmapData = new MyBitmap();
var sc:Number = Math.min( MAX_BITMAP_SIZE.x / bitmapdata.width, MAX_BITMAP_SIZE.y /     bitmapdata.height );
var outBitmap:BitmapData = new BitmapData( bitmapdata.width >> 1, bitmapdata.height >> 1, false, 0x0 );
var bitmap:Bitmap = new Bitmap();
addChild( bitmap );
var scaleMatrix:Matrix = new Matrix();
scaleMatrix.scale(sc,sc);

var time:Number = new Date().getTime();
outBitmap.draw( bitmapdata, scaleMatrix, null,null,null,true );
trace( new Date().getTime()-time );
bitmap.bitmapData = outBitmap;

The same code tests:

Publish as flash 11.4 -> 1ms Publish as AIR 3.4 ->62ms

Anyone?

5
  • Have you tried drawWithQuality, setting a lower quality than the default one?
    – Kodiak
    Aug 28, 2012 at 12:09
  • Yes, I have test with StageQuality.LOW but the results are the same.
    – xperiments
    Aug 28, 2012 at 12:46
  • and isn't scaling the Bitmap (DisplayObject) itself faster and smoother?
    – Kodiak
    Aug 28, 2012 at 12:51
  • No, really is a strange behaviour. Why publish to flash player gives me 1ms and the same code compiled to Desktop Air gets 63ms.
    – xperiments
    Aug 28, 2012 at 13:05
  • Ummm, figured out why... I was testing inside Flash IDE, but testing in browser gives me 46ms... anyway it gets 62ms in AIR app... strange anyway...
    – xperiments
    Aug 28, 2012 at 13:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.