Showing 1 - 1 of 1 total. RSS Feed WordPress RSS Feed

On This Page:

  1. 1  Center image content

    Center image content

    If you get a bitmap data as source of an image component and you want to center it you have to create a new bitmap, create a new matrix, apply a transformation (in the snippet the translation is done accordingly to the component with) and then use again the BitmapData class to draw the new data accordingly to the transoformation
    var imageData:BitmapData = BitmapData(someRawBitmapData);

    var bmp:Bitmap = new Bitmap(imageData);

    var matrix:Matrix = new Matrix();
    matrix.translate(-((imageData.width - this.width) / 2), -((imageData.height - this.height) / 2));

    var matriximage:BitmapData = new BitmapData(bmp.height, bmp.width, false, 0x00000000);
    matriximage.draw(bmp, matrix);

    // Suppose imgThumbnail is the ID of your component
    imgThumbnail.source = new Bitmap(matriximage);
    Showing 1 - 1 of 1 total. RSS Feed WordPress RSS Feed

    On This Page:

    1. 1  Center image content