- COPYRIGHT AND LICENSE
Graphics::Potrace::Raster - raster representation for Graphics::Potrace
use Graphics::Potrace::Raster; my $bitmap = Graphics::Potrace::Raster->new(); $bitmap->load(Ascii => filename => '/path/to/ascii.txt'); my $vectorial = $bitmap->trace();
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 the raster to all blank pixels.
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.
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:
$sourceis a simple scalar, has no newlines and can be mapped to an existing file, it is considered an Ascii file (see Graphics::Potrace::Raster::Ascii) and loaded accordingly;
$sourceis a simple scalar containing newlines or that cannot be mapped onto an existing file, it is considered as straight data and loaded accordingly (again assuming an Ascii format);
$sourceis a glob it is used to load data as if they are in Ascii representation format;
$sourceis an array it is considered a sequence of parameters to be provided to
my $dy = $raster->dy(); $raster->dy($dy);
Get (or set) the
dy parameter, needed by Potrace library.
my $value = $raster->get($x, $y);
Get the value associated to the specified pixel.
my $height = $raster->height(); $raster->height($new_height);
Accessor for raster's height. It performs trimming or enlargement where necessary.
$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
$info possible associations.
Flip bitmap vertically.
my $raster = Graphics::Potrace::Raster->new();
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.
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.
my $sequence = $raster->real_bitmap();
Accessor to the low-level representation of the bitmap.
Reset the bitmap to an empty one.
Reverse the bitmap: all blanks will be turned to full and vice-versa.
$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).
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.
$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.
Set the specific pixel to empty. Equivalent to calling:
$raster->set($x, $y, 0);
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.
Flavio Poletti <firstname.lastname@example.org>
Copyright (C) 2011-2015 by Flavio Poletti email@example.com.
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.