Added and tested map_RGB[A] to SDL::Video
Kartik Thakore [Fri, 30 Oct 2009 16:04:02 +0000 (12:04 -0400)]
src/Core/Video.xs
t/core_video.t

index a8a9a1e..d3b3608 100644 (file)
@@ -16,21 +16,15 @@ static Uint16* av_to_uint16 (AV* av)
        {
        int i;
        Uint16* table = (Uint16 *)safemalloc(sizeof(Uint16)*(len));
-               //fprintf( stderr, "Expecting 1,2,5,6 \n Length is %d \n", len);
        for ( i = 0; i < len+1 ; i++ ){ 
                SV ** temp = av_fetch(av,i,0);
              if( temp != NULL)
                {
-               table[i] =  (Uint16 *) SvIV(  *temp   )  ;
-               /* fprintf( stderr, "table[%d] = ", i);
-                if (table[i] == NULL) { fprintf ( stderr, " NULL\n"); }
-               else{ fprintf(stderr, " %d \n", table[i]); } */
+                       table[i] =  (Uint16 *) SvIV(  *temp   );
                }
                else { table[i] =0; }
 
        }
-//             warn("Got %d %d %d %d \n", table[0], table[1], table[2], table[3] );
-
        return table;
        }
        return NULL;
@@ -247,3 +241,28 @@ video_set_gamma_ramp( rt, gt, bt )
        OUTPUT:
                RETVAL 
 
+
+
+Uint32
+video_map_RGB ( pixel_format, r, g, b )
+       SDL_PixelFormat *pixel_format
+       Uint8 r
+       Uint8 g
+       Uint8 b
+       CODE:
+               RETVAL = SDL_MapRGB(pixel_format,r,g,b);
+       OUTPUT:
+               RETVAL
+
+Uint32
+video_map_RGBA ( pixel_format, r, g, b, a )
+       SDL_PixelFormat *pixel_format
+       Uint8 r
+       Uint8 g
+       Uint8 b 
+       Uint8 a
+       CODE:
+               RETVAL = SDL_MapRGB(pixel_format,r,g,b);
+       OUTPUT:
+               RETVAL
+
index 5a19ad8..445492c 100644 (file)
@@ -28,6 +28,8 @@ my @done =
        set_palette
        set_gamma
        set_gamma_ramp
+       map_RGB
+       map_RGBA
        /;
 
 can_ok ('SDL::Video', @done); 
@@ -109,12 +111,11 @@ $value = SDL::Video::set_palette($hwdisplay, SDL_LOGPAL|SDL_PHYSPAL, 0, @b_w_col
 is(  $value , 1,  '[set_palette] returns 1'  );
 
 
-
-
+is( SDL::Video::map_RGB($hwdisplay->format, 10, 10 ,10) > 0, 1, '[map_RGB] maps correctly to 8-bit surface');
+is( SDL::Video::map_RGBA($hwdisplay->format, 10, 10 ,10, 10) > 0, 1, '[map_RGBA] maps correctly to 8-bit surface');
 
 my @left = qw/
        get_gamma_ramp
-       map_RGB
        map_RGBA
        get_RGB
        get_RGBA