Implement all arguments to BitmapData.draw

Bug #987456 reported by Niel Drummond
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
jeash
Fix Committed
Undecided
Unassigned

Bug Description

Hello I am wanting to use a scale9grid method to resize images. Is this part of the nme api not yet implemented in jeash?

For example this works with flash and cpp but not the html5;

public static function scale9Bitmap (w:Int,h:Int,_scale9Grid:Rectangle,originalBitmap:BitmapData):BitmapData {
  var bmpData:BitmapData = new BitmapData (w,h,true,0x00000000);

  var rows:Array<Float> = [0,_scale9Grid.top,_scale9Grid.bottom,originalBitmap.height] ;
  var cols:Array<Float> = [0,_scale9Grid.left,_scale9Grid.right,originalBitmap.width];

  var dRows:Array<Float> = [0,_scale9Grid.top,h - (originalBitmap.height - _scale9Grid.bottom),h];
  var dCols:Array<Float> = [0,_scale9Grid.left,w - (originalBitmap.width - _scale9Grid.right),w];

  var origin:Rectangle;
  var draw:Rectangle;
  var mat:Matrix = new Matrix ();

  var cx:Int = 0;
  while (cx < 3) {

   var cy:Int = 0;
   while (cy < 3) {
    origin = new Rectangle (cols[cx],rows[cy],cols[cx + 1] - cols[cx],rows[cy + 1] - rows[cy]);
    draw = new Rectangle (dCols[cx],dRows[cy],dCols[cx + 1] - dCols[cx],dRows[cy + 1] - dRows[cy]);
    mat.identity ();
    mat.a = draw.width / origin.width;
    mat.d = draw.height / origin.height;
    mat.tx = draw.x - origin.x * mat.a;
    mat.ty = draw.y - origin.y * mat.d;
    bmpData.draw (originalBitmap,mat,null,null,draw,true);
    cy ++;

   }

   cx ++;
  }

  return bmpData;
 }

Revision history for this message
Niel Drummond (niel-drummond) wrote :

I've been meaning to fix this, but haven't yet had the time.

Changed in jeash:
status: New → Confirmed
Revision history for this message
chris (impaler777) wrote :

oh yes thanks for confirming it, the only other way I can think of to do 9 slice scaling is to have 9 bitmap objects and that is kind of messy. Every other target in nme supports BitmapData.draw it would be nice to see it here if its possible. There are other useful things you can do with it besides this.

Revision history for this message
Niel Drummond (niel-drummond) wrote :

clipRect is implemented. Smoothing is always enabled due to limitations with the canvas implementation on browsers.

Changed in jeash:
status: Confirmed → Fix Committed
Revision history for this message
Philippe (philippe-elsass) wrote :

ColorTransform argument doesn't seem to work.

// colorize a white (+alpha) image
var bmp = new BitmapData(image.width, image.height, true, 0);
var ct = new nme.geom.ColorTransform();
ct.redMultiplier = (color >> 16) / 256.0;
ct.greenMultiplier = ((color & 0xff00) >> 8) / 256.0;
ct.blueMultiplier = (color & 0xff) / 256.0;
bmp.draw(source, null, ct);

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related questions

Remote bug watches

Bug watches keep track of this bug in other bug trackers.