.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .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" '' . ds C` . ds C' '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 >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Base 3pm" .TH Base 3pm "2022-12-02" "perl v5.36.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" .SS "\fBnew_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 .SS "\fBline()\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. .SS "\fBellipse()\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. .SS "\fBrectangle()\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. .SS "\fBnew()\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. .SS "\fBnew_from_serialised()\fP" .IX Subsection "new_from_serialised()" Not implemented. Recommended for inheritors. Should accept a string serialised using \fBserialise()\fR and return an object (reference). .SS "\fBserialise()\fP" .IX Subsection "serialise()" Not implemented. Recommended for inheritors. Should return a string representation (ideally compressed). .SS "\fBget()\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. .SS "\fBset()\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. .SS "\fBxy()\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. .SS "\fBload()\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. .SS "\fBsave()\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