借助于SDL开发包,写的关于SDL加载和缩放图片的小例子;
#include<SDL/SDL.h>
#include<SDL/SDL_image.h>
#include <SDL/SDL_rotozoom.h>
int main(int argc,char *argv[])
{
SDL_Rect rect = {0,0,640,480};
SDL_Rect myrect={0,0,640,480};
SDL_Rect bmprect;
SDL_Surface *image;
SDL_Surface *bmp;
SDL_Event event;
bmprect.x = rect.x ;
bmprect.y = rect.y;
bmprect.w = rect.w-200 ;
bmprect.h = rect.h-200 ;
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface *screen=SDL_SetVideoMode(640,480,0,SDL_INIT_NOPARACHUTE);
if(screen==NULL) {
printf(“setVideoMode Failure”);
exit(1);
}
image=SDL_LoadBMP(“sample.bmp”);
if(image==NULL){
printf(“load Failure\n”);
exit(1);
}
int sw = image->w;
i