High-level changes:
[xuni.git] / src / resize.h
blob44ef3a9538900ebfbe3619ad0c3cc6c7a757eab1
1 /* resize.c - has all you need to get high-quality interpolated image scaling - up & down! */
2 /* please see resize.c for more information about who has contributed to this library */
4 #ifndef __RESIZE_FILTERS__
5 #define __RESIZE_FILTERS__
7 #include <SDL.h>
9 /* Here are the only 2 functions you need: */
10 /* NULL will be returned if the passed in surface "image" is invalid */
11 SDL_Surface* SDL_ResizeFactor(SDL_Surface *image, float scalefactor, int filter);
12 SDL_Surface* SDL_ResizeXY (SDL_Surface *image, int new_w, int new_h, int filter);
14 /* Here are overloaded C++ versions, with filter default as high quality. */
15 #ifdef __cplusplus
16 SDL_Surface* SDL_Resize(SDL_Surface *image, float scalefactor, int filter = 7);
17 SDL_Surface* SDL_Resize(SDL_Surface *image, int new_w, int new_h, int filter = 7);
18 #endif
20 /*The passed-in surface is freed by SDL_Resize, so it works nicely to pass in surfaces
21 as themselves:
22 e.g. pic = SDL_ResizeFactor(pic, 0.75, 7); (or pic = SDL_Resize(pic, 0.75);)
23 This will shrink pic to 75% of original size. No other cleanup necessary.
24 Another good way to use it is on initialization:
25 e.g. SDL_Surface *pic = SDL_ResizeXY(SDL_LoadBMP("mypic.bmp"),50,50,7);
26 This will give you mypic.png at size 50x50(regardless of original dimensions)
27 if mypic.bmp did not load correctly, pic will be NULL.
30 /*
31 Filters are as follows:
32 1 = box filter - fastest/ugliest.
33 2 = triangle filter - possible visual anomalies
34 3 = bell filter - possible visual anomalies
35 4 = B_spline filter - here is where it starts to get good.
36 5 = hermite filter - relatively fast, good quality
37 6 = Mitchell filter - also speedy, good quality
38 7 = Lanczos3 filter - slowest, but by far best quality. Very sharp!
39 If filter is not specified, Lanczos3 will be selected by default
42 /*The code should compile as either C or C++, without any fuss, except maybe you specifying
43 which kind to compile it as... -Dave Olsen
46 #endif