Weird behavior when trying to draw image to canvas

I’ve been getting this weird “bug” when I try to draw an image object to a canvas and then have the canvas shown on screen. Not sure if this is a bug or if I’m just using the API incorrectly.
 

Here’s the result:

  Mm3yDuV.png

And here’s what it’s suppose to look like (without drawing to canvas):  1gMLvN5.png

local canvas=graphics.newTexture({ type="canvas"; width=thread.platform.screen\_resolution.value.x; height=thread.platform.screen\_resolution.value.y; }) local texture=graphics.newTexture({type="image",filename="assets/textures/256\_palette.png"}) local canvas\_object=display.newImageRect( canvas.filename,canvas.baseDir, thread.platform.screen\_resolution.value.x,thread.platform.screen\_resolution.value.y ) local image\_object=display.newImageRect( texture.filename,texture.baseDir, 100,100 ) canvas:draw(image\_object) image\_object:removeSelf() --Won't need the object once drawn to canvas

Edit: I should also note that the image is different every time I relaunch the simulator.

Can you put together a project that demos this problem in a .zip file and share it with us?

Rob

@ShoesForClues  Have you tried this without removeSelf()'ing the image object? The canvas is designed around having the objects there, e.g. to recover when Android suspends.

I think the other issue is just the canvas not bothering with a potentially expensive clear when you create it (since a perfectly reasonable first action would be to fill it up anyway). Try a setBackground() to black and see if it’s better.

Yeah I already tested it before without the removeSelf(), the bug would still occur. I also tried to set the background of the canvas before drawing anything else to it, same result.

Here’s a zip file which reproduces this bug.

Sorry but I gotta bump this since it’s been months now…

Tried it just now. My changes, toward the end:

-- stuff before draw() canvas:draw(image\_object) canvas:invalidate() --image\_object:removeSelf()

hey there… Whats up?

I am having issues in creating a mobile 2d game. I have a “key” image and next to ita text that shows how many keys you have got.

When your key amount increases, the text goes increasing step left. Here is an image addressing my problem showing Problem.png. Mobdro What should I do???

Can you put together a project that demos this problem in a .zip file and share it with us?

Rob

@ShoesForClues  Have you tried this without removeSelf()'ing the image object? The canvas is designed around having the objects there, e.g. to recover when Android suspends.

I think the other issue is just the canvas not bothering with a potentially expensive clear when you create it (since a perfectly reasonable first action would be to fill it up anyway). Try a setBackground() to black and see if it’s better.

Yeah I already tested it before without the removeSelf(), the bug would still occur. I also tried to set the background of the canvas before drawing anything else to it, same result.

Here’s a zip file which reproduces this bug.

Sorry but I gotta bump this since it’s been months now…

Tried it just now. My changes, toward the end:

-- stuff before draw() canvas:draw(image\_object) canvas:invalidate() --image\_object:removeSelf()

hey there… Whats up?

I am having issues in creating a mobile 2d game. I have a “key” image and next to ita text that shows how many keys you have got.

When your key amount increases, the text goes increasing step left. Here is an image addressing my problem showing Problem.png. Mobdro What should I do???