Documentation ¶
Overview ¶
Image Library for Go
Ilib is a library (and some tools and examples) written in Go that can read, create, manipulate and save images. It is capable of using X11 BDF fonts for drawing text. That means you get lots of fonts to use. You can even create your own if you know how to create an X11 BDF font. It should be able to read any image file that the base Go image package supports. Copyright (C) 2001-2022 Craig Knudsen, craig@k5n.us http://github.com/craigk5n/ilibgo
Index ¶
- Constants
- func CopyImage(source *Image, dest *Image, gc GraphicsContext, src_x int, src_y int, ...) error
- func CopyImageScaled(source *Image, dest *Image, src_x int, src_y int, src_width int, ...) error
- func DrawLine(image *Image, gc GraphicsContext, x1 int, y1 int, x2 int, y2 int) error
- func DrawPoint(image *Image, gc GraphicsContext, x int, y int) error
- func DrawPolygon(image *Image, gc GraphicsContext, points []Point) error
- func DrawRectangle(image *Image, gc GraphicsContext, x int, y int, width int, height int) error
- func DrawString(image *Image, gc GraphicsContext, x int, y int, text string)
- func DrawStringRotated(image *Image, gc GraphicsContext, x int, y int, text string, ...)
- func DrawStringRotatedAngle(image *Image, gc GraphicsContext, x int, y int, text string, angle float64)
- func FillPolygon(image *Image, gc GraphicsContext, points []Point) error
- func FillRectangle(image *Image, gc GraphicsContext, x int, y int, width int, height int) error
- func FloodFill(image *Image, gc GraphicsContext, x int, y int) error
- func GetFontSize(font *Font) (height int, err error)
- func IDrawArc(image *Image, gc GraphicsContext, x int, y int, r1 int, r2 int, a1 float64, ...) error
- func IDrawCircle(image *Image, gc GraphicsContext, x int, y int, r int) error
- func IDrawEllipse(image *Image, gc GraphicsContext, x int, y int, r1 int, r2 int) error
- func IDrawEnclosedArc(image *Image, gc GraphicsContext, x int, y int, r1 int, r2 int, a1 float64, ...) error
- func IFillArc(image *Image, gc GraphicsContext, x int, y int, r1 int, r2 int, a1 float64, ...) error
- func IFillCircle(image *Image, gc GraphicsContext, x int, y int, r int) error
- func ImageHeight(img *Image) int
- func ImageWidth(img *Image) int
- func IsSupportedFormat(stringFormat string) bool
- func SetBackground(gc *GraphicsContext, backgroundColor Color)
- func SetFont(gc *GraphicsContext, font *Font)
- func SetForeground(gc *GraphicsContext, foregroundColor Color)
- func SetLineStyle(gc *GraphicsContext, lineStyle LineStyle)
- func SetLineWidth(gc *GraphicsContext, lineWidth int)
- func SetPoint(image *Image, gc GraphicsContext, x int, y int) error
- func SetTextStyle(gc *GraphicsContext, textStyle TextStyle)
- func TextDimensions(gc GraphicsContext, font *Font, text string) (width int, height int, err error)
- func TextHeight(gc GraphicsContext, font *Font, text string) (height int, err error)
- func TextWidth(gc GraphicsContext, font *Font, text string) (width int, err error)
- func WriteImageFile(f *os.File, img *Image, format ImageFormat) error
- type BdfChar
- type BdfFont
- type Color
- type FillStyle
- type Font
- type GraphicsContext
- type Image
- type ImageFormat
- type ImageOption
- type LineStyle
- type Point
- type TextDirection
- type TextStyle
Constants ¶
const ( DefaultFormatString = "ppm" IlibVersion = "2.0" IlibVersionDate = "11 Aug 2022" FormatGIF ImageFormat = 0 FormatPPM ImageFormat = 1 FormatPGM ImageFormat = 2 FormatPBM ImageFormat = 3 FormatXPM ImageFormat = 4 FormatXBM ImageFormat = 5 FormatPNG ImageFormat = 6 FormatJPEG ImageFormat = 7 FormatTIFF ImageFormat = 8 FormatBMP ImageFormat = 9 NumberOfFormats uint = 10 )
const BlackPixel int = 0
Default color values
const WhitePixel int = 1
Variables ¶
This section is empty.
Functions ¶
func CopyImage ¶
func CopyImage(source *Image, dest *Image, gc GraphicsContext, src_x int, src_y int, width int, height int, dest_x int, dest_y int) error
Copy a rectangle portion of a source image to a destination image
func CopyImageScaled ¶
func CopyImageScaled(source *Image, dest *Image, src_x int, src_y int, src_width int, src_height int, dest_x int, dest_y int, dest_width int, dest_height int) error
This allows the user to scale up or down the source image onto the destination image.
func DrawPoint ¶
func DrawPoint(image *Image, gc GraphicsContext, x int, y int) error
Set the point at the specified location using the foreground color of the IGC parameter. (This is an alias to ISetPoint.)
func DrawPolygon ¶
func DrawPolygon(image *Image, gc GraphicsContext, points []Point) error
func DrawRectangle ¶
Draw a rectangle
func DrawString ¶
func DrawString(image *Image, gc GraphicsContext, x int, y int, text string)
func DrawStringRotated ¶
func DrawStringRotated(image *Image, gc GraphicsContext, x int, y int, text string, direction TextDirection)
func DrawStringRotatedAngle ¶
func FillPolygon ¶
func FillPolygon(image *Image, gc GraphicsContext, points []Point) error
Fill a polygonn
func FillRectangle ¶
Draw a filled rectangle
func GetFontSize ¶
func IDrawArc ¶
func IDrawArc(image *Image, gc GraphicsContext, x int, y int, r1 int, r2 int, a1 float64, a2 float64) error
Draw an arc. Both arc1 and arc2 are in degrees from 0 to 360.
func IDrawCircle ¶
Draw a circle
func IDrawEllipse ¶
func IDrawEnclosedArc ¶
func IDrawEnclosedArc(image *Image, gc GraphicsContext, x int, y int, r1 int, r2 int, a1 float64, a2 float64) error
Draw an arc and connect it to the center point.
func IFillArc ¶
func IFillArc(image *Image, gc GraphicsContext, x int, y int, r1 int, r2 int, a1 float64, a2 float64) error
Fill an arc
func IFillCircle ¶
Fill a circle
func ImageHeight ¶
func ImageWidth ¶
func IsSupportedFormat ¶
Check to see if the specified image format (as represented as the file suffix like "png") is supported. Some image formats
func SetBackground ¶
func SetBackground(gc *GraphicsContext, backgroundColor Color)
func SetFont ¶
func SetFont(gc *GraphicsContext, font *Font)
func SetForeground ¶
func SetForeground(gc *GraphicsContext, foregroundColor Color)
func SetLineStyle ¶
func SetLineStyle(gc *GraphicsContext, lineStyle LineStyle)
func SetLineWidth ¶
func SetLineWidth(gc *GraphicsContext, lineWidth int)
func SetPoint ¶
func SetPoint(image *Image, gc GraphicsContext, x int, y int) error
Set the point at the specified location using the foreground color of the IGC parameter.
func SetTextStyle ¶
func SetTextStyle(gc *GraphicsContext, textStyle TextStyle)
func TextDimensions ¶
func TextHeight ¶
func TextHeight(gc GraphicsContext, font *Font, text string) (height int, err error)
Get the height (in pixels) of the specified text using the font currently set in the graphics context.
func TextWidth ¶
func TextWidth(gc GraphicsContext, font *Font, text string) (width int, err error)
Get the width (in pixels) of the specified text using the font currently set in the graphics context.
func WriteImageFile ¶
func WriteImageFile(f *os.File, img *Image, format ImageFormat) error
Writes an image to a file. The file is left open for the caller to close.
Types ¶
type BdfChar ¶
type BdfChar struct {
// contains filtered or unexported fields
}
func FontBDFGetChar ¶
Get the BdfChar value for the specified letter. Note: Only tested on ASCII with English so far.
func FontBDFGetRune ¶
Get the BdfChar value for the specified letter. Note: Only tested on ASCII with English so far.
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
func AllocColor ¶
Allocate a color (with no alpha) from RGB values 0-255.
func AllocNamedColor ¶
Allocate a color (with no alpha) by its name (e.g. "red", "blue", etc)
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
func LoadFontFromData ¶
Parse the array of string lines that represent the BDF font. Example usage: LoadFontFromData("timR12", font_timR12)
type GraphicsContext ¶
type GraphicsContext struct {
// contains filtered or unexported fields
}
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
func CreateImage ¶
type ImageFormat ¶
type ImageFormat uint8
func FileType ¶
func FileType(filename string) (ImageFormat, error)
func FormatStringToType ¶
func FormatStringToType(formatString string) (ImageFormat, error)
Convert a string representation of an image format (typically the file extension like "png"), and convert it to the corresponding IImageFormat type. An error is returned if the type is not recognized or not supported.
type ImageOption ¶
type ImageOption uint8
const ( OptionNone ImageOption = 0 OptionGrayscale ImageOption = 1 OptionGreyscale ImageOption = OptionGrayscale OptionAscii ImageOption = 2 // ascii output for pbm/pgm/ppm images OptionInterlaced ImageOption = 4 // interlaced output (GIF) )
type TextDirection ¶
type TextDirection int
const ( TextLeftToRight TextDirection = 1 // default TextBottomToTop TextDirection = 2 TextTopToBottom TextDirection = 3 )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Create an go file from a BDF font file so that the BDF font can be bundled with the Go file.
|
Create an go file from a BDF font file so that the BDF font can be bundled with the Go file. |
Create a PNG file that displays the font for ASCII values up to 255.
|
Create a PNG file that displays the font for ASCII values up to 255. |
fonts
|
|
Sample app for ilibgo package.
|
Sample app for ilibgo package. |
Build an image that contains an index of a bunch of images.
|
Build an image that contains an index of a bunch of images. |
Report generator for apache2 access.log file
|
Report generator for apache2 access.log file |