Page 1 of 1

Any hardcoded limit on image size?

Posted: Wed Apr 18, 2012 11:42 am
by IQuit
It seems to me that an image with 513x768 or 1024x768 draws fine but not 1025x768.
Tried love.graphics.newImage with ImageData as well as reading from a file.
I use v0.8.0 so should not be power of 2 syndrome. Is it just me having this problem?

Re: Any hardcoded limit on image size?

Posted: Wed Apr 18, 2012 12:58 pm
by vrld
It's more than hardcoded, it is hardwired into your graphics card. With 0.8 the PO2 syndrome is not magically gone, it is just cleverly worked around by reserving memory for a PO2 image behind your back, if this is necessary (i.e. when your graphic card cannot handle non PO2 images). So the 1025x768px image will reserve 2048x1024px to prevent any issues.

Now, making the assumption that one pixel takes up 4 Byte (32 bit), this will allocate 2048 * 1024 * 4 Byte = 8 MB of graphics memory just for the image (without PO2 correction this would still take up 1025 * 768 * 4 Byte = ~3MB). Some graphic cards (especially older ones) don't have that amount of memory. Thus, they cannot load or show the image.

Re: Any hardcoded limit on image size?

Posted: Wed Apr 18, 2012 2:30 pm
by IQuit
Thanks!
I am not quite sure, but it does not look like a memory limit, however.
Here is a short code to demonstrate the problem:

Code: Select all

local j,k={},{}
function love.load()
        table.insert(j,love.image.newImageData(2,1024))
        table.insert(j,love.image.newImageData(2,1025))
        table.insert(j,love.image.newImageData(1024,2))
        table.insert(j,love.image.newImageData(1025,2))
        table.insert(j,love.image.newImageData(1024,1024))
        for z=1,#j do
                for y=0,j[z]:getHeight()-1 do
                        for x=0,j[z]:getWidth()-1 do
                                j[z]:setPixel(x,y,222,44,111,255)
                        end
                end
                k[z]=love.graphics.newImage(j[z])
        end
end
function love.draw()
        for z=1,#k do
                love.graphics.draw(k[z],z*80+20,z*80+20)
        end
end
On my system, second and forth image show up as white while the rest are in pink.

Re: Any hardcoded limit on image size?

Posted: Wed Apr 18, 2012 4:53 pm
by Boolsheet
It looks like your graphics card/driver can't load textures with a width or height equal or higher than 2048. What graphics card and driver do you have? Can you try to update the driver?

Re: Any hardcoded limit on image size?

Posted: Wed Apr 18, 2012 5:14 pm
by Ensayia
I remember having this issue when I made a screensaver for my mother using LOVE. You don't really think about the differences in older versus newer tech until it bites you. I made a large static image for a background and her laptop's puny Intel chip completely choked. Turns out it can't handle large sizes well at all! I really had to butcher the nice screensaver I made to get it to work at all on her machine.

Re: Any hardcoded limit on image size?

Posted: Wed Apr 18, 2012 10:31 pm
by Jasoco
For safety reasons I like to keep my images to 1024x1024 at most just in case. But you could play it safe at 512x512. If you need images bigger, you'd just use pieces and draw them tiled, but at least you'd be safe from cards that can't do really big images.

We;ve done a few polls before to see who can support what. My MacBook Air's integrated HD3000 card can support a large amount of large images, but a better full dedicated card might be more limited. It seems to depend on what the card maker decided to support at the time. It's silly I know. But there's nothing you can do except prepare and use smaller images.

Re: Any hardcoded limit on image size?

Posted: Thu Apr 19, 2012 12:39 am
by IQuit
Thanks everyone for replying!
Yeah, I am using GMA950.
The problem is I cannot break up the image of a spritebatch or there will be issues with drawing sequence ...
I guess I will have to give up!
Wonder how other software handle this issue ...

Re: Any hardcoded limit on image size?

Posted: Thu Apr 19, 2012 6:02 am
by Jasoco
IQuit wrote:Thanks everyone for replying!
Yeah, I am using GMA950.
The problem is I cannot break up the image of a spritebatch or there will be issues with drawing sequence ...
I guess I will have to give up!
Wonder how other software handle this issue ...
They handle it by breaking up the images. Just break up the image. You'll have to do it anyway. Instead of having one large image in the spritebatch you might have 4 or so. But at least it would be compatible with more graphics cards.