SDL_image and memory

Hi, I wanted to ask about SDL_image. Currently my application didn’t use
SDL_image so the image were loaded from a bmp file. I’m just wondering if
I used png and loaded it with SDL_image, would the memory allocated for
the surfaces be much fewer than if I used bmp? The reason I’m trying to
switch to SDL_image is because my images now are more than 600 megs in bmp
format. So, if all were to be loaded into the memory, I think it’s not too
efficient.

Thanks in advance.

Hi 2u,

I’m also new, newetheless I think I can answer to your question:
NO.

It’s a great thing to try using png, I also looked for a format that permits
me freedom, no licence stuff… but:

regardless of your picture format, you will want in the end to have a plain
uncompresed picture in memory in order to work with it. So, you wil gain a
lot of space economy, but on HDD.
not on RAM.

If you want, you may load them into memory and afterwards when you need to
work on one of them, decompres it with reading the PNG file from memory.

You could read as many png pics into memory as you want (or have) with
SDL_RWFromFile() and afterwars, use IMG_LoadPNG_RW() when you need it
decompresed.

So, as a summary: If you want all your pics in memory, available to work on
them, then you gain nothing, just lower hdd space for your program.

However, if you process one at a time, read them how they are in memory,
compresed… and just before using/working on one/each of them,
decompres(IMG_LoadPNG_RW) it before and release the memory(or reuse it for
another png…)

Hope it helps.

george.On 9/19/06, benang at cs.its.ac.id wrote:

Hi, I wanted to ask about SDL_image. Currently my application didn’t use
SDL_image so the image were loaded from a bmp file. I’m just wondering if
I used png and loaded it with SDL_image, would the memory allocated for
the surfaces be much fewer than if I used bmp? The reason I’m trying to
switch to SDL_image is because my images now are more than 600 megs in bmp
format. So, if all were to be loaded into the memory, I think it’s not too
efficient.

Thanks in advance.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


george

Thanks for the reply. Okay what if I change my question. If I load the
resources into RWops pointers, and convert them to SDL_Surface only when
needed, would the cost of conversion be more efficient than if the
SDL_Surface were all (or partially) be read from the swap pagefile
(obviously it will happen because the total of the bitmap files are 6-700
megs whereas my memory is only 512 megs)?

Thanks in advance.> Hi 2u,

I’m also new, newetheless I think I can answer to your question:
NO.

It’s a great thing to try using png, I also looked for a format that
permits
me freedom, no licence stuff… but:

regardless of your picture format, you will want in the end to have a
plain
uncompresed picture in memory in order to work with it. So, you wil gain a
lot of space economy, but on HDD.
not on RAM.

If you want, you may load them into memory and afterwards when you need to
work on one of them, decompres it with reading the PNG file from memory.

You could read as many png pics into memory as you want (or have) with
SDL_RWFromFile() and afterwars, use IMG_LoadPNG_RW() when you need it
decompresed.

So, as a summary: If you want all your pics in memory, available to work
on
them, then you gain nothing, just lower hdd space for your program.

However, if you process one at a time, read them how they are in memory,
compresed… and just before using/working on one/each of them,
decompres(IMG_LoadPNG_RW) it before and release the memory(or reuse it for
another png…)

Hope it helps.

george.

On 9/19/06, @benang_at_cs.its.ac <@benang_at_cs.its.ac> wrote:

Hi, I wanted to ask about SDL_image. Currently my application didn’t use
SDL_image so the image were loaded from a bmp file. I’m just wondering
if
I used png and loaded it with SDL_image, would the memory allocated for
the surfaces be much fewer than if I used bmp? The reason I’m trying to
switch to SDL_image is because my images now are more than 600 megs in
bmp
format. So, if all were to be loaded into the memory, I think it’s not
too
efficient.

Thanks in advance.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


george


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

As far as performance is concerned, that depends on the speed of the
disk the swap is on, in relation to the speed of the CPU. Also, if
your application already needs a lot of CPU time, adding
decompression overhead might be worse than streaming from disk, even
if the disk is relatively slow.

There is another problem, however: Timing. Disk access is rather
"random" in nature; sometimes it’s very quick (data already cached or
in the read-ahead buffers), and sometimes very slow (data needs to be
read from the physical disk before your application can continue). To
keep the disk access from making animation unsmooth, you’d need to do
the disk access in a background thread or similar.

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Wednesday 20 September 2006 06:15, benang at cs.its.ac.id wrote:

Thanks for the reply. Okay what if I change my question. If I load
the resources into RWops pointers, and convert them to SDL_Surface
only when needed, would the cost of conversion be more efficient
than if the SDL_Surface were all (or partially) be read from the
swap pagefile (obviously it will happen because the total of the
bitmap files are 6-700 megs whereas my memory is only 512 megs)?

Okay, now I get the big picture. Anyway, the bitmaps were overwhelming and
made the application crash. So, I intend to do it in the SDL_image’s way.
One more question though, is there any library for playing avi or mpg
files with SDL?

Thanks alot.> On Wednesday 20 September 2006 06:15, @benang_at_cs.its.ac wrote:

Thanks for the reply. Okay what if I change my question. If I load
the resources into RWops pointers, and convert them to SDL_Surface
only when needed, would the cost of conversion be more efficient
than if the SDL_Surface were all (or partially) be read from the
swap pagefile (obviously it will happen because the total of the
bitmap files are 6-700 megs whereas my memory is only 512 megs)?

As far as performance is concerned, that depends on the speed of the
disk the swap is on, in relation to the speed of the CPU. Also, if
your application already needs a lot of CPU time, adding
decompression overhead might be worse than streaming from disk, even
if the disk is relatively slow.

There is another problem, however: Timing. Disk access is rather
"random" in nature; sometimes it’s very quick (data already cached or
in the read-ahead buffers), and sometimes very slow (data needs to be
read from the physical disk before your application can continue). To
keep the disk access from making animation unsmooth, you’d need to do
the disk access in a background thread or similar.

//David Olofson - Programmer, Composer, Open Source Advocate

Hello benang,

Wednesday, September 20, 2006, 11:40:48 AM, you wrote:

Okay, now I get the big picture. Anyway, the bitmaps were overwhelming and
made the application crash. So, I intend to do it in the SDL_image’s way.
One more question though, is there any library for playing avi or mpg
files with SDL?

SMPEG for playing mpg files. In all honesty though it’s a bit rickety
and should probably be left alone. You could use ffmpeg with SDL to
play avi/mpg/lots of others.–
Best regards,
Peter mailto:@Peter_Mulholland

Hello benang,

Wednesday, September 20, 2006, 11:40:48 AM, you wrote:

Okay, now I get the big picture. Anyway, the bitmaps were overwhelming
and
made the application crash. So, I intend to do it in the SDL_image’s
way.
One more question though, is there any library for playing avi or mpg
files with SDL?

SMPEG for playing mpg files. In all honesty though it’s a bit rickety
and should probably be left alone. You could use ffmpeg with SDL to
play avi/mpg/lots of others.


Best regards,
Peter mailto:darkmatter at freeuk.com

Thanks alot. I guess that’s one more task to do, learning ffmpeg.

please start a new thread for a new topic

benang at cs.its.ac.id wrote:> Okay, now I get the big picture. Anyway, the bitmaps were overwhelming and

made the application crash. So, I intend to do it in the SDL_image’s way.
One more question though, is there any library for playing avi or mpg
files with SDL?

Thanks alot.

On Wednesday 20 September 2006 06:15, benang at cs.its.ac.id wrote:

Thanks for the reply. Okay what if I change my question. If I load
the resources into RWops pointers, and convert them to SDL_Surface
only when needed, would the cost of conversion be more efficient
than if the SDL_Surface were all (or partially) be read from the
swap pagefile (obviously it will happen because the total of the
bitmap files are 6-700 megs whereas my memory is only 512 megs)?

As far as performance is concerned, that depends on the speed of the
disk the swap is on, in relation to the speed of the CPU. Also, if
your application already needs a lot of CPU time, adding
decompression overhead might be worse than streaming from disk, even
if the disk is relatively slow.

There is another problem, however: Timing. Disk access is rather
"random" in nature; sometimes it’s very quick (data already cached or
in the read-ahead buffers), and sometimes very slow (data needs to be
read from the physical disk before your application can continue). To
keep the disk access from making animation unsmooth, you’d need to do
the disk access in a background thread or similar.

//David Olofson - Programmer, Composer, Open Source Advocate


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

please start a new thread for a new topic

@benang_at_cs.its.ac wrote:

Okay, now I get the big picture. Anyway, the bitmaps were overwhelming
and
made the application crash. So, I intend to do it in the SDL_image’s
way.
One more question though, is there any library for playing avi or mpg
files with SDL?

Thanks alot.

Thanks for the reply. Okay what if I change my question. If I load
the resources into RWops pointers, and convert them to SDL_Surface
only when needed, would the cost of conversion be more efficient
than if the SDL_Surface were all (or partially) be read from the
swap pagefile (obviously it will happen because the total of the
bitmap files are 6-700 megs whereas my memory is only 512 megs)?

As far as performance is concerned, that depends on the speed of the
disk the swap is on, in relation to the speed of the CPU. Also, if
your application already needs a lot of CPU time, adding
decompression overhead might be worse than streaming from disk, even
if the disk is relatively slow.

There is another problem, however: Timing. Disk access is rather
"random" in nature; sometimes it’s very quick (data already cached or
in the read-ahead buffers), and sometimes very slow (data needs to be
read from the physical disk before your application can continue). To
keep the disk access from making animation unsmooth, you’d need to do
the disk access in a background thread or similar.

//David Olofson - Programmer, Composer, Open Source Advocate

No need. I’ve put an end of the thread with my last reply.>>> On Wednesday 20 September 2006 06:15, @benang_at_cs.its.ac wrote: