NAME
Image::Base::Wx::Bitmap -- draw into a Wx::Bitmap
SYNOPSIS
use Image::Base::Wx::Bitmap;
my $image = Image::Base::Wx::Bitmap->new
(-wxbitmap => $wxbitmap);
$image->line (0,0, 99,99, '#FF00FF');
$image->rectangle (10,10, 20,15, 'white');
CLASS HIERARCHY
Image::Base::Wx::Bitmap
is a subclass of Image::Base::Wx::DC
,
Image::Base
Image::Base::Wx::DC
Image::Base::Wx::Bitmap
DESCRIPTION
Image::Base::Wx::Bitmap
extends Image::Base
to draw into a Wx::Bitmap
.
Wx::Bitmap
is a platform-dependent colour image with a specified bits-per-pixel depth. The supported depths depend on the platform but include at least the screen depth and 1-bit monochrome.
Drawing is done with a wxMemoryDC as per the Image::Base::Wx::DC
. This subclass adds file load and save for the Wx::Bitmap
.
File Formats
The file formats supported in Wx 2.8 include the following, perhaps depending which supporting libraries it was built with.
BMP always available
PNG
JPEG
GIF load-only
PCX
PNM
TIFF
TGA load-only
IFF load-only
XPM
ICO
CUR
ANI load-only
load()
detects the format, but a handler for the format must have been registered globally. All formats can be registered with
Wx::InitAllImageHandlers();
This is suggested since otherwise load XPM seems to behave as an "ANY" which might trick the detection attempts. The Wx::Image
handlers are used by Wx::Bitmap
so registering desired formats there might be enough.
Colour Names
Colour names are anything recognised by Wx::Colour->new()
, as described in "Colour Names" in Image::Base::Wx::DC.
FUNCTIONS
See "FUNCTIONS" in Image::Base for behaviour common to all Image-Base classes.
$image = Image::Base::Wx::Bitmap->new (key=>value,...)
-
Create and return a new image object. It can read a file,
$image = Image::Base::Wx::Bitmap->new (-file => '/my/file/name.bmp');
Or create a new bitmap with width and height. The default
-depth
is the bits-per-pixel of the screen, or something else can be given.$image = Image::Base::Wx::Bitmap->new (-width => 200, -height => 100, -depth => 1); # monochrome
Or a new image can be pointed at an existing
Wx::Bitmap
,my $wxbitmap = Wx::Bitmap->new (200, 100); my $image = Image::Base::Wx::Bitmap->new (-wxbitmap => $wxbitmap);
Further parameters are applied per
set
(see "ATTRIBUTES" below).
ATTRIBUTES
-wxbitmap
(Wx::Bitmap
object)-
The target bitmap object.
-dc
(Wx::MemoryDC
object)-
The
Wx::DC
used to draw into the bitmap. A suitable DC is created for the bitmap automatically, but it can be set explicitly if desired. -file_format
(string, default undef)-
The file format from the last
load()
and the format to use insave()
. This is one of thewxBITMAP_TYPE_XXX
names such as "PNG" or "JPEG". -width
(integer, read-only)-height
(integer, read-only)-
The size of the bitmap, per
$wxbitmap->GetWidth()
and$wxbitmap->GetHeight()
. Currently these are read-only. Can a bitmap be resized dynamically? -depth
(integer, read-only)-
The number of bits per pixel in the bitmap, per
$wxbitmap->GetDepth()
. Currently this is read-only. Can a bitmap be reformatted dynamically?
BUGS
Wx circa 2.8.12 on Gtk prints g_log()
warnings on attempting to load an unknown file format, including an empty file or garbage. This is apparently from attempting it as an XPM. Is that a Wx bug?
SEE ALSO
Wx, Image::Base, Image::Base::Wx::DC, Image::Base::Wx::Image
HOME PAGE
http://user42.tuxfamily.org/image-base-wx/index.html
LICENSE
Copyright 2012 Kevin Ryde
Image-Base-Wx is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Image-Base-Wx is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Image-Base-Wx. If not, see <http://www.gnu.org/licenses/>.