How to create a picture using ImageData?

How to create a picture using ImageData? what’s imageType?

initWithImageFile: function (strPath, imageType) {
    var data = cc.FileUtils.getInstance().getFileData(strPath, "rb");
    var size = data.length;
    if (data != null && data.length > 0)
        return this.initWithImageData(data, data.length, imageType);
    return false;
},

The doc (http://www.cocos2d-x.org/reference/html5-js/V2.2.2/symbols/cc.Image.html#initWithImageFile) says “@param {Number} imageType the type of image, now only support tow types.”. I assume “tow” = “two”, but I don’t think that info is up to date, considering what’s done later in the code.

It seems you can pass the following imageType values: cc.FMT_PNG, cc.FMT_JPG, cc.FMT_TIFF, cc.FMT_RAWDATA. If the values is different from those, it assumes it may be a PNG or TIFF file buffer.

但是我使用了PNG图片,也传递了cc.FMT_PNG参数,还是无法创建!

Sorry, I can’t read Chinese.
If you can’t get it to work, maybe post the exact error message you get, show your code, or maybe try Canvas mode if you’re in WebGL mode.

I haven’t tried using the initWithImageData function directly, but the initWithImageFile function worked fine for me.