@pazos: The second hunk does make sense, but it's missing getting the width/height from buffer, too, because right now it uses the image buffer but with the framebuffer's dimensions

.
(Which I realize may be the point, but then what happens if image buffer's dimension != framebuffer's dimension?)