Skip to content

Commit

Permalink
handle load() with explicit file type for non-bmp images
Browse files Browse the repository at this point in the history
  • Loading branch information
garu committed Aug 4, 2010
1 parent 04ff7c5 commit 616637b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/SDLx/Surface.pm
Expand Up @@ -171,8 +171,17 @@ sub load {
Carp::croak 'no SDL_image support found. Can only load bitmaps'
if $@;

$surface = SDL::Image::load( $filename )
or Carp::croak "error loading image $filename: " . SDL::get_error;
if ($type) {
require SDL::RWOps;
my $file = SDL::RWOps->new_file($filename, "rb")
or Carp::croak "error loading file $filename: " . SDL::get_error;
$surface = SDL::Image::load_typed_rw($file, 1, $type)
or Carp::croak "error loading image $file: " . SDL::get_error;
}
else {
$surface = SDL::Image::load( $filename )
or Carp::croak "error loading image $filename: " . SDL::get_error;
}
}
return SDLx::Surface->new( surface => $surface);
}
Expand Down

0 comments on commit 616637b

Please sign in to comment.