Re: SDL::Surface::new_from and PLot question

[email protected] (David Mertens)
Newsgroups perl.sdl.devel
Message-ID <[email protected]>
On Mon, Nov 16, 2009 at 4:17 PM, Kartik Thakore <[email protected]>wrote:

> Hi David,
>
> Can you give a small script ( a sin function ) that is ready for me to grab
> get_dataref? Some to test SV to Surface pixels conversions.
>
> Kartik Thakore
>

If all you're looking for is a 2-d piddle with something nontrivial, try
this:

--------%<--------

use PDL;

# Allocate a 10x10 array for rgb.  I think that only the zeroes function
allows
# you to declare a piddle with a specific data type
my $pdl_memory = zeroes(byte, 3, 10, 10);

# Set values. Use in place to be sure we don't get another allocation, which
may be the wrong type.
# Note that the sequence wraps back to zero after hitting 256, because
they're bytes!
$pdl_memory->inplace->sequence;

# I believe we can get at the actual IV like so:
my $iv = $pdl_memory->get_dataref();

--------%<--------

I believe that will do it.  PDL wizards please correct me if I'm wrong.

David
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.