Flavio Poletti > Graphics-Potrace-0.1.0_03 > Graphics::Potrace::Raster

Download:
Graphics-Potrace-0.1.0_03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.1.0_03   Source   Latest Release: Graphics-Potrace-0.73

NAME ^

Graphics::Potrace::Raster - raster representation for Graphics::Potrace

VERSION ^

version 0.1.0_03

SYNOPSIS ^

   use Graphics::Potrace::Raster;
   my $bitmap = Graphics::Potrace::Raster->new();
   $bitmap->load(Ascii => filename => '/path/to/ascii.txt');
   my $vectorial = $bitmap->trace();

DESCRIPTION ^

INTERFACE ^

bitmap

   my $raw_bitmap = $raster->bitmap();

Returns the raw bitmap as an array of integers whose bits have been properly arranged for being used by Potrace (the library).

clear

   $raster->clear();

Clear the raster to all blank pixels.

create_loader

   my $loader = Graphics::Potrace::Raster->create_loader($type, @params);

Creates a loader for the specific $type, i.e. a class that is searched under Graphics::Potrace::Raster::$type (see e.g. Graphics::Potrace::Raster::Ascii). See Graphics::Potrace::Raster::Importer for further information about what you can do with these importers.

dwim_load

   my $bitmap = Graphics::Potrace->dwim_load($source);

Tries to do the Right Thing (TM), which currently boils down to analysing the provided parameters like this:

dy

   my $dy = $raster->dy();
   $raster->dy($dy);

Get (or set) the dy parameter, needed by Potrace library.

get

   my $value = $raster->get($x, $y);

Get the value associated to the specified pixel.

height

   my $height = $raster->height();
   $raster->height($new_height);

Accessor for raster's height. It performs trimming or enlargement where necessary.

load

   $bitmap->load($type, $flavour, $info);

Load the bitmap. $type is the name of a helper loader type that is searched as class Graphics::Potrace::Raster::$type (see e.g. Graphics::Potrace::Raster::Ascii). $flavour is an indication of what info contains, see Graphics::Potrace::Raster::Importer for details about the possible $flavour/$info possible associations.

mirror_vertical

   $raster->mirror_vertical();

Flip bitmap vertically.

new

   my $raster = Graphics::Potrace::Raster->new();

Constructor.

packed

   my $hash = $raster->packed();

Returns a packed representation of the raster, consisting of an anonymous hash containing fields useful for calling the proper tracing function from Potrace's library.

packed_bitmap

   my $sequence = $raster->packed_bitmap();

Returns a packed representation of the bitmap section of the whole raster, i.e. the binary representation used by Potrace's library.

real_bitmap

   my $sequence = $raster->real_bitmap();

Accessor to the low-level representation of the bitmap.

reset

   $raster->reset();

Reset the bitmap to an empty one.

reverse

   $raster->reverse();

Reverse the bitmap: all blanks will be turned to full and vice-versa.

set

   $raster->set($x, $y);
   $raster->set($x, $y, 1); # equivalent to the above, but explicit
   $raster->set($x, $y, 0); # equivalent to $raster->unset(...)

Set the value of the specific pixel to the provided value (or to 1 if no value is provided).

trace

   my $vectorial = $raster->trace(%options);
   my $vectorial = $raster->trace($options);

Get a vectorial representation of the raster image. This works in terms of "raster2vectorial" in Graphics::Potrace, see there for additional info.

trim

   $raster->trim();
   $raster->trim($width);
   $raster->trim($width, $height);
   $raster->trim(undef, $height);

Trim the bitmap according to the available data. A trimming width or height can be provided, otherwise the one already known for the raster will be used.

unset

   $raster->unset($x, $y);

Set the specific pixel to empty. Equivalent to calling:

   $raster->set($x, $y, 0);

width

   my $width = $raster->width();
   $raster->width($width);

Get/set the width of the raster. If explicitly set, it will be kept and trimming will happen, otherwise the raster will grow as necessary.

AUTHOR ^

Flavio Poletti <polettix@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2011 by Flavio Poletti polettix@cpan.org.

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program 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.

syntax highlighting: