Howdy, Stranger!

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

High Resolution Images

edited July 2013 in General Posts: 2,042

Hi, so I have an image that is 3200 x 2000 and I imported it into documents, but when I try to use it as a sprite, Codea crashes. I was wondering if this is because it is so high res. I am using an iPad 1

Comments

  • Posts: 2,820

    @JakAttak - Can you post some code please?
    Thanks!

  • Posts: 2,042

    @Zoyt, here is the URL

    http://gdeluxe.com/wp-content/uploads/2011/08/osx-lion-wallpaper-andromeda.jpg

    I use http.request to download it and save it

    Then when I try to draw it it is either black or Codea crashes

  • Posts: 2,042

    @Zoyt, here is some example code


    --# Main -- badImage -- Use this function to perform your initial setup function setup() getImage() end function getImage() http.request("http://gdeluxe.com/wp-content/uploads/2011/08/osx-lion-wallpaper-andromeda.jpg", gotImage) end function gotImage(img) saveImage("Documents:Galaxy",img) sound(SOUND_PICKUP, 16598) end -- This function gets called once every frame function draw() -- This sets a dark background color background(40, 40, 50) -- This sets the line thickness strokeWidth(5) -- Do your drawing here sprite("Documents:Galaxy", WIDTH/2, HEIGHT/2, WIDTH, HEIGHT) end

    Run it once for the image to download (you'll hear a beep) and then a second time to see the error

  • Posts: 391

    As per v1.5.3, Maximum imported image size increased to 2048px. So you are over the image size that Codea can handle.

  • Try this for see if it's the size of image, or the fact that you try to access an image not load when draw function begin :

    --# Main
    -- badImage
     
    -- Use this function to perform your initial setup
    function setup()
        image = false
        getImage()
    end
     
    function getImage()
        http.request("http://gdeluxe.com/wp-content/uploads/2011/08/osx-lion-wallpaper-andromeda.jpg";, gotImage)
    end
     
    function gotImage(img)
        saveImage("Documents:Galaxy",img)
        sound(SOUND_PICKUP, 16598)
        image = true
    end
     
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
        background(40, 40, 50)
     
        -- This sets the line thickness
        strokeWidth(5)
     
        -- Do your drawing here
        if (image) then
            sprite("Documents:Galaxy", WIDTH/2, HEIGHT/2, WIDTH, HEIGHT)
        end
    end
  • edited July 2013 Posts: 391

    The image definitely downloads correctly. It is simply too big. Check out the roadmap thread and you can see the documentation for v1.5.3 says Codea only supports images up to 2048px.

  • I think there is an other way to display big image... that's to split it with a mesh and texCoords.

  • SimeonSimeon Admin Mod
    Posts: 4,956

    @Slashin8r that only applies to those imported via the photo library.

    However it does sound like your iPad 1 is simply running out of memory due to downloading and attempting to render the image (this would probably end up making about 3 copies of the image to get it into the GPU, and you have 256mb ram, of which Codea can probably use 40)

  • Posts: 437

    I would like to know if Codea can read PNG 8bits, I have a lot of images of that type but it wont appear in the Sprite explorer when I copy them

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Simeon - the 2048 pixel limit also applies to images created by Codea itself, because I ran into that wall recently. Exceeding the limit produces a black result.

  • edited July 2013 Posts: 2,042

    @Simeon, I have tried it also on my iPad Mini and simply get a black screen. I believe that @Ignatz is correct

    Update: Saved it to my Camera Roll and added to Codea through there. It automatically made it 2048. Now everything works as it should.

  • SimeonSimeon Admin Mod
    Posts: 4,956

    @Ignatz I imagine that is hardware dependent. A 2048px image (i.e., image(2048,2048)) on a retina device is really 4096 pixels — which happens to be the upper limit on texture resolution for iPad 3 and iPad 4. (2048 pixels is the limit for other models of iPad.)

  • Posts: 391

    @Simeon, ah I see, I assumed imported meant any image we add other than those supplied by Codea.

    I'm running this with the Ipad4 and it crashes every time. I can manually save the image to my Dropbox and the same result. When I use Codea to paste it into Documents or Dropbox it automatically converts it to 2048x1280 non-retina and 1024x640 retina. Only then the image works.

  • edited July 2013 Posts: 391

    @JakAttak, ok I found the true culprit. It is the sprite call in draw() causing all the problems. Store the image first and then call that stored image in draw() using sprite. Now the original 3200x2000 image is working.

    --# Main
    -- badImage
    
    -- Use this function to perform your initial setup
    function setup()
        done = false
        image = image(3200,2000)
        getImage()
    end
    
    function storeImage()
        image = readImage("Documents:Galaxy")
    end
    
    function getImage()
        http.request("http://gdeluxe.com/wp-content/uploads/2011/08/osx-lion-wallpaper-andromeda.jpg", gotImage)
    end
    
    function gotImage(img)
        saveImage("Documents:Galaxy",img)
        sound(SOUND_PICKUP, 16598)
        done = true
    end
    
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
        background(40, 40, 50)
    
        -- This sets the line thickness
        strokeWidth(5)
    
        -- Do your drawing here
        if (done) then
            storeImage()
        end
    
        sprite(image, WIDTH/2, HEIGHT/2, WIDTH, HEIGHT)
    end
    

    Edit: let me know if this is also working on older devices. I think I will definitely start storing every image from now on, hehe.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    Crashes ipad1, ios5.1

Sign In or Register to comment.