Search the Community
Showing results for tags 'imagedata'.
-
I had made a codePen demo to show this case(and 2 screen-capture-images below) https://codepen.io/tomleader/pen/jOmNWJG There are 3 buttons(click to see the result) 1. use img: The most common way , sprite.from(imgUrl), everything is ok! 2. use buffer: a little tricky.. the process is [new a Image obj and set src=url, draw Image to another canvas, getImageData from canvas, make a texture from imgData buffer, sprite.from(texture)], and the result seems weird! 3. use dataUrl: the process is [new a Image obj and set src=url, draw Image to another canvas, canvas.toDataURL, make a texture from dataURL, sprite.from(texture)], and the result seems ok! So I think maybe the fromBuffer(imgdata) lost some pixels opacity data? OR I have some mistakes in my code? Any suggestions? Thanks ..
-
var bmd = game.add.bitmapData(400, 400);var imageData = bmd.imageData;var d = imageData.data;for (var i = 0; i < d.length; i += 4) { d[i] = 0; d[i+1] = 255; d[i+2] = 0; d[i+3] = 255;}bmd.ctx.putImageData(imageData, 0, 0);green screen does not show! WHY??
-
How do I go about adding a sprite to bitmap data? I can use bmd.draw('sprite');and that seems like it works but apparently the sprites pixels don't get added to the bitmap data so I can do things with it? I've also tried bmd.copy('sprite');And the image shows up initially but doing anything with bmd.processPixelRGB makes the added image disappear and evidently it's the pixels aren't actually added to bitmapdata?