Microsoft MakeCode

Is there any way to crop an image in code?

What the title says.

1 Like

Nevermind! found it!

1 Like

The way I do it causes LOTS of lag. Can you give me other ways?

Well, can you show us your way? You might have a memory bug in your code or something, which might be why it’s slowing down massively.

Calling set pixel on individual pixels would be slow, but if you do fillRect 4 times (one for each side) it will probably be a lot faster.

something like

image.fillRect(0, 0, screen.width, minCropY, 0)
image.fillRect(0, maxCropY, screen.width, screen.height - maxCropY, 0)
image.fillRect(0, 0, minCropX, screen.height, 0)
image.fillRect(maxCropX, 0, screen.width - maxCropX, screen.height, 0)