The 'easily' may be challenged by the really strange pixel order
It's not a problem at all - just use getPixel and everything is handled behind the scenes for you - it only becomes an issue if you try and access the buffer itself directly.
Errors
Sorry, I should have checked my code. It's because Graphics.buffer is a plain (untyped) ArrayBuffer, not a Typed Array. The following should work:
// save
new Uint8Array(mCopy.buffer).set(m.buffer);
// restore
new Uint8Array(m.buffer).set(mCopy.buffer);
One more thing - you'll probably want to do m.setRotation(1) and mCopy.setRotation(1), or when (if) you do operations on mCopy everything will be 90 degrees out.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
It's not a problem at all - just use
getPixel
and everything is handled behind the scenes for you - it only becomes an issue if you try and access the buffer itself directly.Sorry, I should have checked my code. It's because
Graphics.buffer
is a plain (untyped) ArrayBuffer, not a Typed Array. The following should work:One more thing - you'll probably want to do
m.setRotation(1)
andmCopy.setRotation(1)
, or when (if) you do operations onmCopy
everything will be 90 degrees out.