Image resolution and raw width/height

Hi, the resolution of my image is 10 x 6, but output displays raw width/height.
Is there a way to actually define the resolution you want? If I define the image as 5 x 3, i can’t use img:set on the pixels outside that range.

function setup()
    spriteMode(CORNER)
    noSmooth()
    img=image(10,6)
    setContext(img)
    background(255, 255, 255, 255)
    fill(0, 255, 0, 255)
    ellipse(5,3,6)
    setContext()
    print(img)
end

function draw()
    background(255, 0, 0, 255)
    sprite(img,0,0,img.width*50,img.height*50)
end

On retina displays, you have half pixels. So the 1024 x 768 screen is actually 2048 x 1536. That’s why an image of 10,6 reports a width and height of 10,6 but a raw width and height of 20, 12.

image.set is limited in the sense that on retina, it doesn’t give you access to these half coordinates, effectively setting a 2x2 “block”.

@yojimbo2000 @MMGames You can get to the half values, but they’re actually whole number values. As mentioned above, a 10,6 image has raw values of 20,12. To get to the raw pixels, use rawGet(x,y). See the example below.

function setup()
    img=image(10,6)

    print(img)   -- shows raw sizes as 20,12

    setContext(img)
    background(255,0,0)
    setContext()

    r,g,b,a=img:rawGet(20,12)   -- get raw values at 20,12

    print(r,g,b,a)
end

function draw()
    background(40, 40, 50)
    sprite(img,300,300)
end

Oh wow, I never heard of rawGet. There’s a rawSet too. They’re not in the docs, so I guess someone should file a documentation update request ticket.

@yojimbo2000 See this link, section Codea 1.3.5 Enhancements.

https://codea.io/talk/discussion/98/codea-roadmap-current-2-3-2

Thank you!!! (: