Image(x,y) = image(x*2, y*2) ?

Just wondering why created images are actually twice the resolution specified?

Is this for the retina displays?

@Kirl On a non retina device, a 20x20 pixel image is just that, 20 pixels by 20 pixels. On a retina device, a 20x20 pixel image is 40 pixels by 40 pixels because a retina device also has pixels at the 1/2 pixel positions. A non retina screen goes in pixel increments of 1. That is 1,2,3,4, etc. A retina device goes in 1/2 pixel increments. That’s .5, 1, 1.5, 2, 2.5, 3, 3.5, 4 . If you save an image, there are 2 images that get saved.

@Kirl Here’s an example. The image on the screen is 100x100 pixels. If you look in the touched function, you see 2 for loops that go from 1 to 200 in steps of 2 which is twice the size. When you tap the screen, every other pixel in the image is set to black. To get to the 1/2 pixels with rawSet and rawGet, you use double the size.

EDIT: Updated the code below to read back a line thru the image.

function setup()
    img=image(100,100)
    setContext(img)
    background(255,0,0)
    fill(255)
    ellipse(50,50,20)
    setContext()
    saveImage("Dropbox:eee",img)
    rd=false
end

function draw()
    background(40, 40, 50)
    fill(255)
    if not rd then
        text("tap screen to set each .5 pixel in the image below to 0's",WIDTH/2,HEIGHT-100)
    else
        text("tap screen to read a single line of the pixel values thru the image",WIDTH/2,HEIGHT-100)
    end
    sprite(img,300,300)
end

function touched(t)
    if t.state==BEGAN then
        if not rd then
            rd=true
            for x=1,200,2 do
                for y=1,200,2 do
                    img:rawSet(x,y,0,0,0,0)
                end
            end
        else
            for x=1,200 do
                r,g,b,a=img:rawGet(x,51)
                print(string.format("%.1f = %3d  %3d  %3d  %3d",x/2,r,g,b,a))
            end
        end
    end
end



Awesome, thanks dave! =)