Hiya, all.

Hello Dodger,

I've had no problem building and compiling a simple standalone
application in Perl for Windows using WxWidgets and the ActiveState
PDK.

Thing is, there's more than 'simple' that I want to do and can't figure
out how.

1) I want to know how to be able to include an image embedded in the
code somehow rather than as a seperate, external file (this way
there's no pathing issue possible when compiling the thing).

I use something like this:
I convert the image to XPM with ImageMagick (eg.)

 convert image.bmp image.xpm

This is a "textbased" format so you can open it in an editor and then use it in code like so:

# ---------------------------------------------------------------------
sub img_checked {
my $img = q~
/* XPM */
static char *check[] = {
/* columns rows colors chars-per-pixel */
"16 16 5 1",
"  c black",
". c #848284",
"X c #C6C3C6",
"o c gray100",
"O c white",
/* pixels */
"oooooooooooooooo",
"oooooooooooooooo",
"oo............oo",
"oo.          Xoo",
"oo. OOOOOOOOOXoo",
"oo. OOOOOOO OXoo",
"oo. OOOOOO  OXoo",
"oo. O OOO   OXoo",
"oo. O  O   OOXoo",
"oo. O     OOOXoo",
"oo. OO   OOOOXoo",
"oo. OOO OOOOOXoo",
"oo. OOOOOOOOOXoo",
"oo.XXXXXXXXXXXoo",
"oooooooooooooooo",
"oooooooooooooooo"};
~;
my $data = [ map { m/^"(.*)"/ ? ( $1 ) : () } split /\n/, $img ];
my $xpm = Wx::Bitmap->newFromXPM( $data );
return $xpm;
}

# You can call it like this ....:
my $img_checked = Wx::StaticBitmap->new(
$self->{panel}, -1, img_checked(),
);

# or in an Imagelist:
my $img_list = Wx::ImageList->new( 16, 16, 1 );
$img_list->Add( img_checked() );

# or an icon:
my $icon = Wx::Icon->new();
$icon->CopyFromBitmap( $img_checked() );
$self->SetIcon($icon);

# ---------------------------------------------------------------------


2) I want to be able to draw directly on something.

Define "something". It's not quite clear what you mean...

Can I embed ImageMagick somehow maybe? Is there a more
efficient way, since IM is pretty hefty?

There is a module on CPAN called Wx::Perl::Imagick which replaces "Wx::Image with all functionality of Image::Magick" but like you said, IM is pretty hefty. Apart from that, ImageMagick and PDK haven't work well together in the past and the last time I tried was still problematic.

I have had very good results with Imager (also on CPAN or PPM) but it all
depends on what you want to do. Imager packs well with PDK


3) I'd REALLY like to be able to do some real-time OpenGL 3D stuff.
Totally lost on how.

No help here. Did you see Wx::GLCanvas on the wxPerl site?


Kind regards,

Huub Peters


Reply via email to