Sign in to follow this  
ministromayor

SDL: rescale jpeg surface.

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this