I've found this exact same bug. Let me restate it in different terms
if you have an image of width W and height H and are using image:draw() to draw the whole image at x,y the following should draw the exact same thing
-- draw the full image with no sourceRect at an offset
img:draw(x,y)
--- draw the full image at an offset specifying the full sourceRect bounds
img:draw(x,y,kImageUnflipped,0,0,W,H)
-- draw the full image at (0,0) with a drawOffset and no sourceRect
gfx.setDrawOffset(x,y)
img:draw(0,0)
-- draw the full image at (0,0) with a drawOffset and a sourceRect of the full image bounds
gfx.setDrawOffset(x,y)
img:draw(0,0,kImageUnflipped,0,0,W,H)
however that last one clips x off the width and y off the height. This is incorrect, the sourceRect should be relative ONLY to the image bounds and not where it's being drawn and the full image should be drawn
as @mossprescott notes you can 'hack' this by adding the current drawOffset to the width and height of the sourceRect which undoes the transformation going on in draw()
-- specify an incorrect huge sourceRect drawing at (0,0) with a drawOffset() set
gfx.setDrawOffset(x,y)
img:draw(0,0,kImageUnflipped, 0, 0, width + x, height + y) -- ugh!
This is a pretty bad bug as it affects blitting images to the dirty rect of a sprite in their draw methods as setDrawOffset() is always set before sprite:draw() is called. eg the code below which should draw a piece of background image into the sprite's dirty rect does not draw a ( w x h) piece of image as it should and doesn't cover the dirty rect.
function mySpite.draw(self, x,y,w,h)
-- blit the background image into the dirty rect - this fails as too little image is drawn
backgroundImage:draw(x,y,kImageUnflipped,x,y,w,h)
-- do the rest of your drawing here
end
Next post has a small main.lua which illustrates the bug (don't know why I can't just upload the source but I can't). Run the code and hit 'A' to cycle through the draw modes.