Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Image size bug?

edited September 2012 in Bugs Posts: 66

IN the following code (running on an iPad1) the page1 image is only 500 pixels wide

function setup()



page1 = image(WIDTH,HEIGHT)    




-- besht1 is a 798x1024 image


function draw()

-- using the page1 image shows the error


-- loading the image directly as a sprite works

-- sprite("Documents:besht2",0,0,WIDTH)


Any ideas why?


  • What is the error you are seeing? Only speculating, but are you ever setting the context back to to the screen before you attempt to draw page1?

  • Posts: 66

    The image displayed is full screen height, but only 500 pixels wide

  • edited September 2012 Posts: 580

    EDIT: incidentally, it looks like others have had this problem before too, and there is a bug with setContext()/displayMode() in some cases:

  • edited September 2012 Posts: 580

    A couple of workarounds: you either need to move your displayMode(FULLSCREEN) out of the setup() function and into the global scope, or you need to wait until draw() to render to an image using setContext().

    workaround 1:

    displayMode(FULLSCREEN) function setup()     spriteMode(CORNER)     page1 = image(WIDTH,HEIGHT)     setContext(page1)     sprite("Documents:besht1")     setContext() end function draw()     sprite(page1,0,0) end

    and workaround 2:

    function setup()     spriteMode(CORNER)     displayMode(FULLSCREEN) end doOnce = true function draw()          if doOnce then         doOnce = false         page1 = image(WIDTH,HEIGHT)         setContext(page1)         sprite("Documents:test3")                 setContext()     end          sprite(page1,0,0) end

    I'm not sure why this is happening though. Maybe someone at TLL might have an explanation?

  • Posts: 66

    Thanks for the help -- works great now.

  • SimeonSimeon Admin Mod
    Posts: 5,778

    .@toadkick this is due to the fact that calling displayMode() while in setup() will animate the sidebar out (this is intentional behaviour). The canvas is not resized until animation is complete.

    Calling displayMode() while outside of setup() explicitly does not animate the display change (so users can launch in fullscreen without any artefacts at startup).

    One way we might be able to resolve this is to block the thread until animation completes. Thanks for providing the workarounds.

  • Interesting. Does calling displayMode() during draw() cause the output window to animate as well?

  • SimeonSimeon Admin Mod
    Posts: 5,778

    .@toadkick it should, though I wouldn't recommend calling it rapidly (i.e. it should be part of a conditional, or triggered by user interaction).

Sign In or Register to comment.