1. 程式人生 > >SDL之讀取bmp圖片

SDL之讀取bmp圖片

SDL的程式碼不難理解,看下這個基本的SDL的流程,就明白了個大概
在這裡插入圖片描述在這裡插入圖片描述在這裡插入圖片描述見程式碼

	#include "SDL.h"
    int main(int argc, char* argv[])
    {
    	SDL_Init(SDL_INIT_VIDEO);
    	SDL_Window* window = SDL_CreateWindow("Tutorial", 100, 100,
    		600, 600, SDL_WINDOW_SHOWN);
    	
    	SDL_Surface* surface = SDL_GetWindowSurface(window);
    	SDL_Surface* picture = SDL_LoadBMP("C:\\Users\\xxxx\\Desktop\\1.bmp");
    
    	SDL_BlitSurface(picture, NULL, surface,NULL);
    	SDL_UpdateWindowSurface(window);
    	
    	SDL_Delay(4000);
    	SDL_FreeSurface(picture);
    	SDL_FreeSurface(surface);
    	SDL_DestroyWindow(window);
    	SDL_Quit();
    }