Bug: setContext and image size

Here is a bug. Wen using setContext, you suddenly get the double amount of pixels in the image, i. The example 4x4 pixels even though the runtime reports 2x2.

function setup()
    noSmooth()
    spriteMode(CORNER)
    img = image(2,2)
    setContext(img)
    sprite("SpaceCute:Background",0,0,2,2)
    setContext()
    print(spriteSize(img))
end
function draw()
    background(40, 40, 50)
    scale(100)
    sprite(img,0,0)
end

@tnlogy I wonder if it has something to do with the retina display. I know those are 2 times the size. I ran the above code on my iPad1 which doesn’t have a retina display and it showed a 2x2 image.

@tnlogy Maybe this will explain it. You’re drawing a 2x2 square with a scale(100) which will result in a 200x200 square. In this example code I’m drawing a dot at x=200 and y=200 which shows at the upper right corner of the sprite. So that tells me the image is 2x2 (200x200) but the retina display is drawing at 1/2 increments making it look like it’s a 4x4 image.


function setup()
    noSmooth()
    spriteMode(CORNER)
    img = image(2,2)
    setContext(img)
    sprite("SpaceCute:Background",0,0,2,2)
    setContext()
    print(spriteSize(img))
end
function draw()
    background(40, 40, 50)
    
    -- draw 2x2 square scale(100) = 200x200
    pushMatrix()
    scale(100)
    sprite(img,0,0)
    popMatrix()
    
    -- normal scale
    fill(255,0,0)
    ellipse(200,200,8)
end

Yes, I guess the bug has to do with retina. I use a ipad mini retina. It doesnt just look like itm it is a 4x4, unless the noSmooth is bugging out for retina?

Thanks for the investigation :slight_smile: