SDL 显示图片

#include "SDL.h"

#define MAX_YUV_SURFACE_SIZE(W, H, P) (H * 4 * (W + P + 1) / 2)

int main(int argc, char *argv[]) {

	const char *filename = "testyuv.bmp";

	SDL_Surface *bmp = SDL_LoadBMP(filename);

	SDL_Window *window = SDL_CreateWindow("YUV_test",
											SDL_WINDOWPOS_UNDEFINED,
											SDL_WINDOWPOS_UNDEFINED,
											200, 100, 
											SDL_WINDOW_RESIZABLE);

	SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, 0);
	SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, bmp);

	int done = 0;
	while (done == 0) {
		SDL_Event event;

		while (SDL_PollEvent(&event) > 0) {

			if (event.type == SDL_QUIT) {
				done = 1;
			}
		}

		SDL_RenderCopy(renderer, texture, NULL, NULL);
		SDL_RenderPresent(renderer);
	}

	SDL_DestroyTexture(texture);
	SDL_FreeSurface(bmp);
	SDL_DestroyRenderer(renderer);
	SDL_DestroyWindow(window);
	SDL_Quit();

	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值