Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed problem with get_pixels

  • Loading branch information...
commit 7212404f60d391b1389ad45b7c32258a7d0e31f2 1 parent 564c0a9
@kthakore kthakore authored
Showing with 8 additions and 10 deletions.
  1. +3 −3 src/SDLx/Surface.xs
  2. +5 −7 t/sdlx_surface.t
View
6 src/SDLx/Surface.xs
@@ -61,10 +61,10 @@ int _calc_offset ( SDL_Surface* surface, int x, int y )
}
-int _get_pixel(SDL_Surface * surface, int offset)
+unsigned int _get_pixel(SDL_Surface * surface, int offset)
{
- int value;
+ unsigned int value;
switch(surface->format->BytesPerPixel)
{
case 1: value = ((Uint8 *)surface->pixels)[offset];
@@ -108,7 +108,7 @@ surfacex_pixel_array ( surface )
OUTPUT:
RETVAL
-int
+unsigned int
surfacex_get_pixel_xs ( surface, x, y )
SDL_Surface *surface
int x
View
12 t/sdlx_surface.t
@@ -7,6 +7,7 @@ use SDL::Rect;
use SDLx::Surface;
use SDL::PixelFormat;
use SDL::Video;
+use Data::Dumper;
use lib 't/lib';
use SDL::TestTool;
@@ -117,16 +118,13 @@ my @colors = (
foreach my $c (@colors) {
my $color = ( $c->[0] << 24 ) + ( $c->[1] << 16 ) + ( $c->[2] << 8 ) + $c->[3];
- $surfs[0]->draw_rect( [ 0, 0, 10, 20 ], $color );
+ $surfs[0]->draw_rect( [ 0, 0, 10, 20 ], $c );
- my $num = sprintf('0x%08x', $color);
+ my $num = sprintf('0x%08x', $color);
- my $rgba = SDL::Video::get_RGB( $app->format(), $surfs[0]->[0][0] );
- is( $rgba->[0], $c->[0], "draw_rect uses correct red for $num" );
- is( $rgba->[1], $c->[1], "draw_rect uses correct green for $num" );
- is( $rgba->[2], $c->[2], "draw_rect uses correct blue for $num" );
+ my $rgba = sprintf('0x%08x', $surfs[0]->[0][0] );
- #is($rgba->[3], $c->[3], "draw_rect uses correct alpha for $num");
+ is( $rgba, $num, "draw_rect uses correct color ($rgba) for $num" );
}
SKIP:
Please sign in to comment.
Something went wrong with that request. Please try again.