- CLASS HIERARCHY
- SEE ALSO
- HOME PAGE
Image::Base::Wx::Image -- draw into a Wx::Image
use Image::Base::Wx::Image; my $image = Image::Base::Wx::Image->new (-width => 200, -height => 100); $image->line (0,0, 99,99, '#FF00FF'); $image->rectangle (10,10, 20,15, 'white');
Image::Base::Wx::Image is a subclass of
Image::Base to draw into a
Wx::Image is platform-independent 24-bit RGB image. Drawing is done with
SetRGB() of pixels and rectangles. A
Wx::Image cannot be drawn with
Wx::DC or displayed directly, though it can be converted to a platform-dependent
Wx::Bitmap for display.
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
Each format has a
save() creates a handler for the target
-file_format as necessary.
load() attempts all the globally registered handlers. All formats can be registered with
Or just selected ones with for example
Colour names are 1 to 4 digit hex and anything recognised by
"pink" etc wxColourDatabase "#RGB" 1 to 4 digit hex "#RRGGBB" "#RRRGGGBBB" "#RRRRGGGGBBB" "None" transparent
Special colour "None" means transparent, which is applied by
SetAlpha() on the drawn pixels. The way it's done here is slightly experimental yet. In the current code drawing a colour doesn't turn pixels back to opaque. The intention would be that it should, but don't really want to do a
SetAlpha call on top of
SetRGB for every pixel.
See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.
$image = Image::Base::Wx::Image->new (key=>value,...)
Create and return a new image object. It can read a file,
$image = Image::Base::Wx::Image->new (-file => '/my/file/name.bmp');
Or start a new image created with width and height,
$image = Image::Base::Wx::Image->new (-width => 200, -height => 100);
Or be pointed at an existing wxImage object,
my $wximage = Wx::Image->new (200, 100); my $image = Image::Base::Wx::Image->new (-wximage => $wximage);
Further parameters are applied per
set(see "ATTRIBUTES" below).
$image->xy ($x, $y, $colour)
Get or set the pixel at
Getting a pixel is per
GetPixel(). In the current code colours are returned in "#RRGGBB" form.
-file, or set
$filenameand then read.
The file format is detected by attempting each of the globally added image format handlers.
Currently the possible formats are a hard-coded list, but the intention would be to use
Wx::Image::GetHandlersif/when available. The repeated load attempts probably means a seekable file is required, so some special devices are no good. Perhaps could be improved by automatically copying to a tempfile if necessary.
Write to the
-file, or set
$filenameand then write.
-file_formatis the saved format.
An existing handler for the
FindHandleris used if registered. Otherwise a handler is created for the purpose with
Wx::PNGHandleretc (but not added to the globals with
-file_formatis not set then the current code doesn't look at the
$filenameextension such as ".png" etc the way the underlying
$wximage->SaveFile()does. Perhaps it could do so in the future.
-file_format(string, default undef)
The file format from the last
load()and the format to use in
save(). This is one of the
wxBITMAP_TYPE_XXXnames such as "PNG" or "JPEG".
The size of the image. These are per
Setting these resizes the image with
$wximage->Resize(), filling any expanded area with black.
-quality_percent(0 to 100 or
The image quality when saving to JPEG format. JPEG compresses by reducing colours and resolution in ways that are not too noticeable to the human eye. 100 means full quality, no such reductions.
undefmeans the Wx default.
This is the
-hotx(integer or undef, default undef)
-hoty(integer or undef, default undef)
The cursor hotspot in CUR images.
(XPM format has an optional hotspot too, but Wx circa 2.8.12 doesn't seem to read it.)
Copyright 2012, 2019 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/>.