.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05) .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Base 3pm" .TH Base 3pm "2000-05-26" "perl v5.10.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Image::Base \- base class for loading, manipulating and saving images. .SH "SYNOPSIS" .IX Header "SYNOPSIS" This class should not be used directly. Known inheritors are Image::Xbm and Image::Xpm. .PP .Vb 1 \& use Image::Xpm ; \& \& my $i = Image::Xpm\->new( \-file => \*(Aqtest.xpm\*(Aq ) ; \& $i\->line( 1, 1, 3, 7, \*(Aqred\*(Aq ) ; \& $i\->ellipse( 3, 3, 6, 7, \*(Aq#ff00cc\*(Aq ) ; \& $i\->rectangle( 4, 2, 9, 8, \*(Aqblue\*(Aq ) ; .Ve .PP If you want to create your own algorithms to manipulate images in terms of (x,y,colour) then you could extend this class (without changing the file), like this: .PP .Vb 2 \& # Filename: mylibrary.pl \& package Image::Base ; # Switch to this class to build on it. \& \& sub mytransform { \& my $self = shift ; \& my $class = ref( $self ) || $self ; \& \& # Perform your transformation here; might be drawing a line or filling \& # a rectangle or whatever... getting/setting pixels using $self\->xy(). \& } \& \& package main ; # Switch back to the default package. .Ve .PP Now if you \f(CW\*(C`require\*(C'\fR mylibrary.pl after you've \f(CW\*(C`use\*(C'\fRd Image::Xpm or any other Image::Base inheriting classes then all these classes will inherit your \&\f(CW\*(C`mytransform()\*(C'\fR method. .SH "DESCRIPTION" .IX Header "DESCRIPTION" .Sh "\fInew_from_image()\fP" .IX Subsection "new_from_image()" .Vb 3 \& my $bitmap = Image::Xbm\->new( \-file => \*(Aqbitmap.xbm\*(Aq ) ; \& my $pixmap = $bitmap\->new_from_image( \*(AqImage::Xpm\*(Aq, \-cpp => 1 ) ; \& $pixmap\->save( \*(Aqpixmap.xpm\*(Aq ) ; .Ve .PP Note that the above will only work if you've installed Image::Xbm and Image::Xpm, but will work correctly for any image object that inherits from Image::Base and respects its \s-1API\s0. .PP You can use this method to transform an image to another image of the same type but with some different characteristics, e.g. .PP .Vb 3 \& my $p = Image::Xpm\->new( \-file => \*(Aqtest1.xpm\*(Aq ) ; \& my $q = $p\->new_from_image( ref $p, \-cpp => 2, \-file => \*(Aqtest2.xpm\*(Aq ) ; \& $q\->save ; .Ve .Sh "\fIline()\fP" .IX Subsection "line()" .Vb 1 \& $i\->line( $x0, $y0, $x1, $y1, $colour ) ; .Ve .PP Draw a line from point ($x0,$y0) to point ($x1,$y1) in colour \f(CW$colour\fR. .Sh "\fIellipse()\fP" .IX Subsection "ellipse()" .Vb 1 \& $i\->ellipse( $x0, $y0, $x1, $y1, $colour ) ; .Ve .PP Draw an oval enclosed by the rectangle whose top left is ($x0,$y0) and bottom right is ($x1,$y1) using a line colour of \f(CW$colour\fR. .Sh "\fIrectangle()\fP" .IX Subsection "rectangle()" .Vb 1 \& $i\->rectangle( $x0, $y0, $x1, $y1, $colour, $fill ) ; .Ve .PP Draw a rectangle whose top left is ($x0,$y0) and bottom right is ($x1,$y1) using a line colour of \f(CW$colour\fR. If \f(CW$fill\fR is true then the rectangle will be filled. .Sh "\fInew()\fP" .IX Subsection "new()" Virtual \- must be overridden. .PP Recommend that it at least supports \f(CW\*(C`\-file\*(C'\fR (filename), \f(CW\*(C`\-width\*(C'\fR and \&\f(CW\*(C`\-height\*(C'\fR. .Sh "\fInew_from_serialised()\fP" .IX Subsection "new_from_serialised()" Not implemented. Recommended for inheritors. Should accept a string serialised using \fIserialise()\fR and return an object (reference). .Sh "\fIserialise()\fP" .IX Subsection "serialise()" Not implemented. Recommended for inheritors. Should return a string representation (ideally compressed). .Sh "\fIget()\fP" .IX Subsection "get()" .Vb 2 \& my $width = $i\->get( \-width ) ; \& my( $hotx, $hoty ) = $i\->get( \-hotx, \-hoty ) ; .Ve .PP Get any of the object's attributes. Multiple attributes may be requested in a single call. .PP See \f(CW\*(C`xy\*(C'\fR get/set colours of the image itself. .Sh "\fIset()\fP" .IX Subsection "set()" Virtual \- must be overridden. .PP Set any of the object's attributes. Multiple attributes may be set in a single call; some attributes are read-only. .PP See \f(CW\*(C`xy\*(C'\fR get/set colours of the image itself. .Sh "\fIxy()\fP" .IX Subsection "xy()" Virtual \- must be overridden. Expected to provide the following functionality: .PP .Vb 2 \& $i\->xy( 4, 11, \*(Aq#123454\*(Aq ) ; # Set the colour at point 4,11 \& my $v = $i\->xy( 9, 17 ) ; # Get the colour at point 9,17 .Ve .PP Get/set colours using x, y coordinates; coordinates start at 0. .PP When called to set the colour the value returned is class specific; when called to get the colour the value returned is the colour name, e.g. 'blue' or \&'#f0f0f0', etc, e.g. .PP .Vb 2 \& $colour = xy( $x, $y ) ; # e.g. #123456 \& xy( $x, $y, $colour ) ; # Return value is class specific .Ve .PP We don't normally pick up the return value when setting the colour. .Sh "\fIload()\fP" .IX Subsection "load()" Virtual \- must be overridden. Expected to provide the following functionality: .PP .Vb 2 \& $i\->load ; \& $i\->load( \*(Aqtest.xpm\*(Aq ) ; .Ve .PP Load the image whose name is given, or if none is given load the image whose name is in the \f(CW\*(C`\-file\*(C'\fR attribute. .Sh "\fIsave()\fP" .IX Subsection "save()" Virtual \- must be overridden. Expected to provide the following functionality: .PP .Vb 2 \& $i\->save ; \& $i\->save( \*(Aqtest.xpm\*(Aq ) ; .Ve .PP Save the image using the name given, or if none is given save the image using the name in the \f(CW\*(C`\-file\*(C'\fR attribute. The image is saved in xpm format. .SH "CHANGES" .IX Header "CHANGES" 2000/05/05 .PP Added some basic drawing methods. Minor documentation changes. .PP 2000/05/04 .PP Created. .SH "AUTHOR" .IX Header "AUTHOR" Mark Summerfield. I can be contacted as \- please include the word 'imagebase' in the subject line. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) Mark Summerfield 2000. All Rights Reserved. .PP This module may be used/distributed/modified under the \s-1LGPL\s0.