[C con Clase] SDL2 Salvar pantalla como bmp

Hl3 halowin3 en gmail.com
Mar Nov 19 09:39:25 CET 2013


Lo tengo, al menos en WXP(32bits), tengo que probarlo en W8(64)

//**************************************
SDL_Window *win = SDL_CreateWindow("Salvando pantalla", 100,100, SCREEN_WIDTH, SCREEN_HEIGHT, 0);
		
SDL_Renderer *ren = SDL_CreateRenderer(win, -1,	0 );

SDL_Surface *img = SDL_CreateRGBSurface(0,SCREEN_WIDTH,SCREEN_HEIGHT,32,0,0,0,0);
img = IMG_Load("imagen.png");

//textura para la imagen
SDL_Texture *tex2 = SDL_CreateTextureFromSurface(ren, img);

//textura del rendertarget
SDL_Texture *tex = SDL_CreateTexture(ren, 0 , SDL_TEXTUREACCESS_TARGET, 800, 600);

SDL_Rect des  ={ 75,75,img->w, img->h };

//esto me fallaba pq lo ponia detras y es justo aqui
SDL_RenderCopy( ren, tex2, NULL, &des );
SDL_RenderPresent(ren);

// ************* SALVANDO EL RESULTADO *************************  	
int r = SDL_SetRenderTarget( ren,tex );
SDL_Surface* salvapantalla = SDL_GetWindowSurface( win );
SDL_SaveBMP( salvapantalla, "salvado.bmp");	
SDL_FreeSurface(salvapantalla);
SDL_SetRenderTarget( ren , NULL );
//****************************************************************	
...
...
...
Lo tengo que probar a la tarde en W8-64bits, pero tiene buena pinta.

Saludos


Más información sobre la lista de distribución Cconclase