From: Marcus <li...@wo...> - 2002-04-25 23:15:55
|
I'm trying to save a drawing to a file. The only Perl sample with drawing I found was splitter.pl. I then translated the C++ code from image.cpp which saves a bitmap. Below is the code. It outputs: "Undefined subroutine &Wx::Image::newBitmap called at J:/Perl/site/lib/Wx/Image.pm line 24." ...then crashes with an exception error. I've tried placing "use Wx::Image" in several places. Note: I changed $dc to $xdc, and $dc became the new MemoryDC one. sub OnDraw { my( $this, $xdc ) = @_; my ($bitmap) = Wx::Bitmap->new(100,100,-1); my ($dc) = Wx::MemoryDC::new($xdc); $dc->SelectObject( $bitmap ); $dc->SetBackgroundMode( wxTRANSPARENT ); $dc->DrawText( 'Testing', 50,50 ); $dc->SetPen( wxBLACK_PEN ); $dc->DrawLine(0,0,100,100); $dc->SetPen( wxNullPen ); $dc->SetBrush( wxNullBrush ); $dc->SelectObject( wxNullBitmap ); my ($image) = Wx::Image->new( $bitmap ); $image->SaveFile("test.png", wxBITMAP_TYPE_PNG ) or Wx::LogError("Can't save file"); $image->Destroy(); } ---------------------------------- I also tried using Blit(), but that was confusing. I couldn't figure out how you get the copied data and save it to a file. Btw, Is there a very simple example of how to create a canvas for drawing, without all the splitter code? Thanks, Marcus |