Jump to content
  • Advertisement
Sign in to follow this  
ministromayor

SDL: rescale jpeg surface.

This topic is 3648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to rescale a surface obtained via IMG_LoadJPG_RW with zoomSurface with and whithout smooting and mi app crash with segmentation fault. I'm sure my stack is fine, at least with my code.

Share this post


Link to post
Share on other sites
Advertisement
The code involved with the problem:

Sorry: Class & object & method names in spanish. ;-)

imgmgr.h :

SDL_Surface *imagen;
SDL_RWops *rwop;

imgmgr.cpp :

AdministradorImagenes::
AdministradorImagenes()
{
imagen = NULL;
rwop = NULL;
}

SDL_Surface *AdministradorImagenes::
cargaImagen(char *ruta)
{
rwop = SDL_RWFromFile(ruta, "rb");
imagen = IMG_LoadJPG_RW(rwop);
return imagen;
}

SDL_Surface *AdministradorImagenes::
cargaQImagen(char *ruta)
{
SDL_Surface *orig = cargaImagen(ruta);
double w = orig->w/4;
double h = orig->h/4;
SDL_Surface *resc = zoomSurface(orig, w, h, SMOOTHING_OFF);
return resc;
}

principal.cpp :

AdministradorImagenes img_adm;
foto = img_adm.cargaQImagen(argv[1]);

Share this post


Link to post
Share on other sites
Several of those functions can return NULL, such as SDL_RWFromFile or IMG_LoadJPG_RW. You should be checking for that first.

Share this post


Link to post
Share on other sites
I have already checked with debuger (gdb) I know exactly where the error ocurrs:

SDL_Surface *resc = zoomSurface(orig, w, h, SMOOTHING_OFF);

I left SDL_image and i'm using jpeglib instead. Now I have a SDL_Surface with my thumbnail but whith some problems, doesn't matters I'll deal with this errors by myself.

SDL_image creates an SDL_Surface with the jpeg image in a 1:1 scale. then I preferr to scale at loading time directly with jpeglib.

however, If somebody knows how to rescale an existing SDL_Surface with pixels within...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!