Help: with create a surface from my own RGBA data
[email protected] (agraham) Tue, 03 Apr 2012 21:12:13 +0100
| Newsgroups | perl.sdl.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Guys, I am a complete Perl-SDL "newbie" and have spent a few days reading the docs on CPAN perl-SDL. I'm using version 2.536. I would like to create a surface from my own RGBA data and there seems to be no way to do that unless you do it a pixel at a time :( I am trying to hack Net::VNC so that it uses SDL:: instead of Image::Imlib2, so for example: The "raw encoding" from Net::VNC does this: $socket->read( my $data, $w * $h * 4 ); my $raw = Image::Imlib2->new_using_data( $w, $h, $data ); $raw->has_alpha(0); $image->blend( $raw, 0, 0, 0, $w, $h, $x, $y, $w, $h ); I need to replicate the above in perl-SDL There is an map_RGBA function which maps 1 pixel, but not a bunch of them, so you can do: $dpixel=SDL::Video::map_RGBA( $display->format, 0, 0, 255); but not this: $dpixel=SDL::Video::map_RGBA( $display->format, $data); SDL::Video::fill_rect( $surface, $srect, $dpixel ); I tried using SDL::RWOps as follows: $rw = SDL::RWOps->new_const_mem( $data); but I don't know how to get $rw into the surface! and $surface = SDL::Image::load( $rw ); does not work. Any help would be much appreciated. Albert