resize.h

00001 //resize.c - has all you need to get high-quality interpolated image scaling - up & down!
00002 //please see resize.c for more information about who has contributed to this library
00003 
00004 #ifndef __RESIZE_FILTERS__
00005 #define __RESIZE_FILTERS__
00006 
00007 #include <SDL/SDL.h>
00008 
00009 //Here are the only 2 functions you need:
00010 //NULL will be returned if the passed in surface "image" is invalid
00011 SDL_Surface* SDL_ResizeFactor(SDL_Surface *image, float scalefactor,    int filter);
00012 SDL_Surface* SDL_ResizeXY    (SDL_Surface *image, int new_w, int new_h, int filter);
00013 
00014 //Here are overloaded C++ versions, with filter default as high quality.
00015 #ifdef __cplusplus
00016 SDL_Surface* SDL_Resize(SDL_Surface *image, float scalefactor,    int filter = 7);
00017 SDL_Surface* SDL_Resize(SDL_Surface *image, int new_w, int new_h, int filter = 7);
00018 #endif
00019 
00020 /*The passed-in surface is freed by SDL_Resize, so it works nicely to pass in surfaces
00021   as themselves:
00022   e.g. pic = SDL_ResizeFactor(pic, 0.75, 7); (or pic = SDL_Resize(pic, 0.75);)
00023   This will shrink pic to 75% of original size. No other cleanup necessary.
00024   Another good way to use it is on initialization:
00025   e.g. SDL_Surface *pic = SDL_ResizeXY(SDL_LoadBMP("mypic.bmp"),50,50,7);
00026   This will give you mypic.png at size 50x50(regardless of original dimensions)
00027   if mypic.bmp did not load correctly, pic will be NULL.
00028 */
00029 
00030 /*
00031 Filters are as follows:
00032 1 = box filter - fastest/ugliest.
00033 2 =        triangle filter - possible visual anomalies
00034 3 = bell filter - possible visual anomalies
00035 4 = B_spline filter - here is where it starts to get good.
00036 5 =        hermite filter - relatively fast, good quality
00037 6 =        Mitchell filter - also speedy, good quality
00038 7 = Lanczos3 filter - slowest, but by far best quality. Very sharp!
00039 If filter is not specified, Lanczos3 will be selected by default
00040 */
00041 
00042 /*The code should compile as either C or C++, without any fuss, except maybe you specifying
00043   which kind to compile it as... -Dave Olsen
00044 */
00045 
00046 #endif
00047 
00048 
00049 
Generated on Sun May 8 08:04:47 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3