SFML community forums

Help => General => Topic started by: Fuv on June 03, 2010, 07:45:01 pm

Title: sf::Image is too big?
Post by: Fuv on June 03, 2010, 07:45:01 pm
I was trying to add image as a background, but I noticed some images couldnt be loaded even I have the same code. Is it possible to load big image? I have code:

Code: [Select]
sf::Image Background;
if(!Background.LoadFromFile("back.jpg"))
return 1;


And its working for some images and for others not. Is the reason that they are too big(i mean too heavy - over 2MB for example)? If so how to load such a image?

Kind Regards
Fuv
Title: sf::Image is too big?
Post by: Spodi on June 03, 2010, 08:21:41 pm
You are restricted by the support of your graphics card. What are the dimensions of the image? The file size shouldn't matter, but the dimensions of the image will.
Title: sf::Image is too big?
Post by: Fuv on June 03, 2010, 09:29:47 pm
Ah, it could be.
My image is: 1842x1161.
Could You tell me what the limit is?

Kind Regards
Fuv


//edit:
Now I tried to load .png file. 57x105. And it also doesnt work. Why? What are possible problems?
Title: sf::Image is too big?
Post by: Spodi on June 03, 2010, 11:28:15 pm
Texture requirements come in powers of 2, so with that size, your graphics card will have to support 2048x2048. Unless you have a very old graphics card, you most likely can support that.

First off, make sure the file exists and that the casing is correct. Whatever program you used to save the file may have saved it in a nonstandard format. Unlikely, but it does happen. In which case, you can try saving it as a simple bitmap (*.bmp).
Title: sf::Image is too big?
Post by: Ashenwraith on June 04, 2010, 07:24:02 am
If you're loading lots of pixel data with your images it's possible to run out of vram too.
Title: sf::Image is too big?
Post by: Fuv on June 04, 2010, 12:50:46 pm
Thanks for advices. It was image fault - too many colors.

Kind Regards
Fuv
Title: sf::Image is too big?
Post by: Spodi on June 04, 2010, 07:19:05 pm
Quote from: "Fuv"
Thanks for advices. It was image fault - too many colors.

Kind Regards
Fuv


Oh? Interesting. I wouldn't think that would be a problem, unless maybe your buffer is 16-bit color but image 32-bit. But even then, it should downsample to 16-bit.