SDL加载和缩放图片小例子

  • Post author:
  • Post category:其他


借助于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



版权声明:本文为fghjkldf原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。