megaimage(n) 1.0 "megaimage image manipulation extension"

NAME

megaimage - megaimage image manipulation extension

TABLE OF CONTENTS

    TABLE OF CONTENTS
    SYNOPSIS
    DESCRIPTION
    API
    COPYRIGHT

SYNOPSIS

package require Tcl 8.4

megaimage megaimage-buffer
megaimage-blank ? width height ?
instance blend x y megaimage-buffer
instance blendobj destx desty ?x ?y x2 y2? obj
instance blendrow y RGBA-list
instance clipcopy x y x2 y2 megaimage-buffer
instance clipcopyobj x y x2 y2 obj
instance crop x1 y1 x2 y2
instance fillcircle centerx centery radius RGBA-list
instance getdata
instance getrow y
instance getsize
instance line x y x2 y2 ?width? RGBA-list
instance pixel x y
instance pixel x y RGBA-list
instance polygon RGBA-list x1 y1 x2 y2 x3 y3 ...
instance putrow y RGBA-list
instance rectangle x y width height RGBA-list
instance rotate degrees
instance scale int-xratio int-yratio
instance scaleto newwidth newheight
instance setall RGBA-list
instance setdata megaimage-buffer
instance setsize width height
instance tile megaimage-buffer

DESCRIPTION

Megaimage is an image manipulation extension. Each megaimage consists of an RGBA buffer, and every manipulation uses RGBA. The pixel components are all between 0 and 255.

API

megaimage megaimage-buffer
megaimage returns a megaimage instance command handle. megaimage-buffer is a buffer from jpegext2:decode, pngext2:decode, or from the getdata subcommand of a megaimage.

megaimage-blank ? width height ?
megaimage-blank returns a megaimage instance with the specified width and height. The initial pixel values will be 0 0 0 0 in RGBA for the entire image.

 
 set fd [open file.jpg r]
 fconfigure $fd -translation binary
 set jpegdata [read $fd]
 close $fd
 set obj [megaimageobj [jpegext2:decode $jpegdata]]
 set obj [megaimage-blank 200 300]

All megaimage objects have a set of instance subcommands or methods that manipulate the internal RGBA buffer. For full alpha transparency use the value 0, for fully visible colors without any blending use 255. A megaimage-buffer in this documentation refers to a buffer that is not associated with an instance command. Such intermediate buffers are generated by the getdata instance subcommand, jpegext2:decode, pngext2:decode, and the freetypeext.

instance blend x y megaimage-buffer
This blends the megaimage buffer with the current pixel at x,y.

instance blendobj destx desty ?x ?y x2 y2? obj
This is used to blend 2 megaimage objects together.

instance blendrow y RGBA-list
This is used to blend a row of pixels together. The row is considered 1 list.

instance clipcopy x y x2 y2 megaimage-buffer
This is used to copy the pixels in the megaimage-buffer to the instance. No blending is performed.

instance clipcopyobj x y x2 y2 obj
This is a faster version of clipcopy, because it doesn't create a intermediate buffer. It copies directly from one object to another without an intermediate buffer.

instance crop x1 y1 x2 y2
This is a method for cropping an existing image. It replaces the current megaimage area with the cropped area. If for some reason the cropped area is out of bounds, it replaces the image with a 1x1 image with RGBA values 0 0 0 0.

instance fillcircle centerx centery radius RGBA-list
This creates a circle with the specified radius and color, at centerx,centery.

instance getdata
This returns a megaimage-buffer.

instance getrow y
This returns the pixels in the instance for the row y in a list. The list consists of a format like {R G B A R G B A ...}

instance getsize
This returns a list of the width and height of the image. It can be used like this with Tcl >= 8.5:

 
lassign [$mobj getsize] width height



instance line x y x2 y2 ?width? RGBA-list
This draws a line on the instance using the 4 element RGBA-list of colors. The default line width is 1. The line is antialiased using Wu's algorithm if the line width is 1. Larger line widths are not antialiased.

instance pixel x y
This returns the pixel as an RGBA list.

instance pixel x y RGBA-list
This takes a 4 element list and sets the pixel values for instance.

instance polygon RGBA-list x1 y1 x2 y2 x3 y3 ...
Draw a filled polygon on the instance using the 4 element RGBA-list. You must specify at least 6 integer arguments for each polygon. There is no limit on the total number of arguments for the polygon coordinates.

instance putrow y RGBA-list
This replaces the row y with the RGBA-list of llength width * 4. It's thus in a different format than the pixel subcommand (for efficiency).

instance rectangle x y width height RGBA-list
This creates a rectangle in the instance.

instance rotate degrees
This rotates the instance. degrees is expected to be between -360-0-360.

instance scale int-xratio int-yratio
This scales an image using integer values. If the ratio is 1000 for an x or y ratio then the size is unchanged.

instance scaleto newwidth newheight
This scales to an absolute new width and height.

instance setall RGBA-list
This sets all pixels in the instance to the value of the 4 element RGBA-list.

instance setdata megaimage-buffer
This replaces the data for an instance with the megaimage-buffer data.

instance setsize width height
This sets the size of the instance image. The data for the image will be set to the RGBA values 0 0 0 0.

instance tile megaimage-buffer
This tiles a megaimage buffer over the entire width and height of the megaimage specified by instance.

To destroy a megaimage instance you must destroy its instance command.

 
rename $instance {}

COPYRIGHT

Copyright © 2008 George Peter Staplin