Screenshot returns broken image

When i try to perform operations on a screenshot I get crash or broken behaviour. I will send individual operations with code to reproduce in the following messages. @dave

invertedImage

When I try to invert screenshot - game crashes.

local gfx <const> = playdate.graphics
image = gfx.image.new(400, 240, gfx.kColorWhite)
gfx.lockFocus(image)
gfx.setColor(gfx.kColorBlack)
gfx.fillRect(175, 95, 50, 50)
gfx.unlockFocus()

local myInputHandlers = {

    AButtonDown = function()
		image = image:invertedImage()
    end,
	BButtonDown = function ()
		image = playdate.graphics.getDisplayImage()
	end,

}

playdate.inputHandlers.push(myInputHandlers)

function playdate.update()
	image:draw(0,0)
end

Steps to reproduce:

  1. Click A to be sure that inverting normal image works
  2. Click B to create screenshot
  3. Click A to invert screenshot to recieve crash

You also can change line image = image:invertedImage() to something = image:invertedImage(). In this case game will crash on second inverting

1 Like

setMaskImage

Applying mask on screenshot creates your nightmare monster. It feels like lines has offset because mask or screenshot think that it has differend width.

local gfx <const> = playdate.graphics
mask = gfx.image.new(400, 240, gfx.kColorWhite)
gfx.lockFocus(mask)
gfx.setColor(gfx.kColorBlack)
gfx.fillRect(1, 1, 398, 238)
gfx.unlockFocus()
image = mask:copy()

local myInputHandlers = {

    AButtonDown = function()
		image:setMaskImage(mask)
    end,
	BButtonDown = function ()
		image = playdate.graphics.getDisplayImage()
	end,

}

playdate.inputHandlers.push(myInputHandlers)

function playdate.update()
	gfx.clear(gfx.kColorWhite)
	image:draw(0,0)
end

Steps to reproduce:

  1. Click A to see what shound happen when mask is applied to normal image
  2. Restart game
  3. Click B to create screenshot
  4. Click A to create masterpiece

playdate-20210906-230323

playdate-20210906-215057

playdate-20210906-205249

1 Like

I didn't get a fix for this in to 1.4 (still checking whether it seems safe to change the framebuffer to 50-byte alignment), but as a workaround until this is fixed you can replace image = gfx.getDisplayImage() with

	image = gfx.image.new(400,240,gfx.kColorWhite)
	gfx.lockFocus(image)
	playdate.graphics.getDisplayImage():draw(0,0)
	gfx.unlockFocus()
1 Like