comparison test/automated/render/render.c @ 3432:116f74112e8a

Work in progress: SDL_RenderReadPixels() should be implemented soon.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Nov 2009 08:01:07 +0000
parents 22ac66da0765
children 9f62f47d989b
comparison
equal deleted inserted replaced
3431:c8fbb27627d9 3432:116f74112e8a
65 pix = malloc( 4*80*60 ); 65 pix = malloc( 4*80*60 );
66 if (SDL_ATassert( "malloc", pix!=NULL )) 66 if (SDL_ATassert( "malloc", pix!=NULL ))
67 return 1; 67 return 1;
68 68
69 /* Read pixels. */ 69 /* Read pixels. */
70 #if 0
71 ret = SDL_RenderReadPixels( NULL, pix, 80*4 ); 70 ret = SDL_RenderReadPixels( NULL, pix, 80*4 );
72 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) ) 71 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
73 return 1; 72 return 1;
74 #else
75 int i, j;
76 Uint8 *buf = pix;
77 const Uint8 *read_pix;
78 Uint8 *write_pix;
79 for (j=0; j<s->height; j++) {
80 for (i=0; i<s->width; i++) {
81 read_pix = &s->pixel_data[ (j*80 + i) * s->bytes_per_pixel ];
82 write_pix = &buf[ (j*80 + i) * 4 ];
83 write_pix[0] = read_pix[0];
84 write_pix[1] = read_pix[1];
85 write_pix[2] = read_pix[2];
86 write_pix[3] = SDL_ALPHA_OPAQUE;
87 }
88 }
89 #endif
90 73
91 /* Create surface. */ 74 /* Create surface. */
92 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4, 75 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4,
93 RMASK, GMASK, BMASK, AMASK ); 76 RMASK, GMASK, BMASK, AMASK );
94 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL )) 77 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL ))