Hi,
I have a couple of related questions about reading from
in memory images, that might be obtained from a network
connection, or other means, that are stored in scalar
variables( not written to file).
First Question, what is $brect ?
I know about PDL::IO::GD, and I was trying to make
some images with it, that would be directly converted to
piddles without writing to file. I ran into this $brect thing,
and can't figure it out.
#########################################################
#!/usr/bin/perl
use PDL::IO::GD;
use strict;
use warnings;
my $im = PDL::IO::GD->new( { x => 50, y => 50, true_color=>1 } );
my $black = $im->ColorAllocate( 0, 0, 0 );
my $white = $im->ColorAllocate( 255, 255, 255 );
# Draw a rectangle:
$im->FilledRectangle( 0, 0, 50, 50, $white );
# Add some text:
#$im->String( gdFontGetLarge(), 20, 20, 'Z', $black ); #works
my $brect; # assuming it contains the returned bounds of the string?
$im->StringFT($brect, $black,"./Generic.ttf",12,0,25,25,'Z'); #seg faults
$im->write_Png( "$0.png" );
###########################################################
Second Question:
I gave up on PDL::IO::GD and went back to GD.
I can output to a scalar, but how do I convert that to a piddle?
#############################################################
#!/usr/bin/perl
use GD;
use strict;
use warnings;
GD::Image->trueColor(1);
my ($w, $h) = (50, 50);
my $img = GD::Image->new($w, $h);
my $white = $img->colorAllocate(255,255,255);
my $black = $img->colorAllocate(0,0,0);
$img->filledRectangle(0,0,50,50,$white);
$img->stringFT($black,"./Generic.ttf",12,0,25,25,'Z');
my $out;
open (IMG, ">", \$out);
print IMG $img->png;
close IMG;
#############################################################
So $out now contains the binary png, and it may have come from the net,
or wherever. How do I read that into a piddle?
It seems all the IO methods take filenames only.
The PDL::IO::FlexRaw module seems closet, but it
seems it should be easier. :-)
If anyone can share some pointers, I would be grateful.
Thanks,
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl