Hi:

I didn't find BitmapFromImage either, but by interpreting the hieroglyphics of the wxBook, the following works for me. You'll have to reset the image filename to your test jpg file. Note also that the StaticBitmap documentation lists a 64x64 size limit under Windows 9x that I don't see here on Ubuntu, but you might. YMMV.

The hint was:

// Load an Image wxImage image(wxT("image.png"), wxBITMAP_TYPE_PNG); // Convert it to a bitmap wxBitmap bitmap(image);
#! /home/xxxx/CitrusPerl/perl/bin/perl # Note I prefer to point to my CitrusPerl install rather than running +a shell script everytime I want to run perl. # Image test - image manipulation use strict; use warnings; use 5.014; package MyForm; # ----------------------------------------- packag +e MyForm:: use strict; use warnings; use Wx qw[:everything]; use Wx::Event qw(EVT_BUTTON ); use parent -norequire, 'Wx::Frame'; use Wx qw(:id :toolbar :statictext wxNullBitmap wxDefaultPosition wxDe +faultSize wxNullBitmap wxTB_VERTICAL wxSIZE wxBITMAP_TYPE_ANY wxBITMAP_TY +PE_BMP); sub new { #1 --------------------------- new MyForm:: my $class = shift; my %parms = @_; my $self = $class->SUPER::new( undef, -1, 'Image test', wxDefaultPosition, # position wxDefaultSize, # size ); my ( $img, $sb, $sizer); my $panel = Wx::Panel->new( $self, -1, # parent window, ID wxDefaultPosition, wxDefaultSize); $panel->SetBackgroundColour(Wx::Colour->new('light blue')); my $welcome = Wx::StaticText->new($panel, -1, 'Welcome to Image test', + [150, 250], [-1, -1], wxALIGN_CENTER); $sizer = Wx::BoxSizer->new(wxVERTICAL); Wx::InitAllImageHandlers; # Added $img = Wx::Image->new($parms{image_fname}, wxBITMAP_TYPE_ANY); my $bmp = Wx::Bitmap->new($img); # Added $sb = Wx::StaticBitmap->new($panel, -1, $bmp); # change +d $sizer->Add( $welcome, 0, wxALL | wxEXPAND, 5 ); $sizer->Add( $sb, 0, wxALL | wxEXPAND, 5 ); $panel->SetSizer($sizer); $panel->Fit; return $self; } #1 end sub new MyForm:: 1; # end package MyForm package main; # ----------------------------- package main +:: use strict; use warnings; use 5.014; my $image_file = '/home/xxxx/CitrusPerl/perl/citrus/lib/Wx/DemoModules +/files/splash/logo.jpg'; # Changed my $app = Wx::SimpleApp->new; my $frame = MyForm->new( image_fname => $image_file); $frame->Show(1); $app->MainLoop; 1;

James

There's never enough time to do it right, but always enough time to do it over...


In reply to Re: wxPerl: is BitmapFromImage implemented? by jmlynesjr
in thread wxPerl: is BitmapFromImage implemented? by HelenCr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.