BitmapData.setPixels() doesn't work in HTML5?


#1

I tried in OpenFL 2.1.7 & Lime 2.0.1, it seems setPixels() and setVector() don’t work in HTML5. Will this be fixed?


#2

It should work, please let me know if there’s a simple test I could use to reproduce the problem you’re seeing


#3

My code:

package;

import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Rectangle;
import flash.utils.ByteArray;
import openfl.Lib;

class Main extends Sprite 
{

    public function new() 
    {
        super();

        var myBD = new BitmapData(256, 256, false, 0xff0000);
        addChild(new Bitmap(myBD));
        var myBA = new ByteArray();
        
        for (i in 0...(128 * 128))
        {
            myBA.writeUnsignedInt(0xffccccff);
        }
        
        myBA.position = 0;
        myBD.setPixels(new Rectangle(0, 0, 128, 128), myBA);
    }
}

The flash target has no problem:

But for HTML5, I got this:


#4

Thanks, just posted a fix: https://github.com/openfl/lime/commit/9ec7737de2fe76d6071ca6c250abce4db08c6538