simage

package
v0.0.0-...-6304ce7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SippGray

type SippGray struct {
	*image.Gray
}

A SippGray wraps a Go Gray image and implements the SippImage interface.

func (*SippGray) Bpp

func (sg *SippGray) Bpp() int

Bpp returns the pixel depth of this image, i.e. 8

func (*SippGray) IntVal

func (sg *SippGray) IntVal(x, y int) int32

IntVal returns the grayscale value at x, y as an int32

func (*SippGray) Pix

func (sg *SippGray) Pix() []uint8

Pix returns the slice of underlying image data, for efficient access.

func (*SippGray) Thumbnail

func (img *SippGray) Thumbnail() SippImage

func (*SippGray) Val

func (sg *SippGray) Val(x, y int) float64

Val returns the grayscale value at x, y as a float64.

func (*SippGray) Write

func (img *SippGray) Write(out *string) error

Write encodes the image into a PNG of the given name.

type SippGray16

type SippGray16 struct {
	*image.Gray16
}

A SippGray16 wraps a Go Gray16 image and implements the SippImage interface.

func (*SippGray16) Bpp

func (sg *SippGray16) Bpp() int

Bpp returns the pixel depth of this image, i.e. 16

func (*SippGray16) IntVal

func (sg16 *SippGray16) IntVal(x, y int) int32

IntVal returns the grayscale value at x, y as an int32.

func (*SippGray16) Pix

func (sg16 *SippGray16) Pix() []uint8

Pix returns the slice of underlying image data, for efficient access.

func (*SippGray16) Thumbnail

func (img *SippGray16) Thumbnail() SippImage

func (*SippGray16) Val

func (sg16 *SippGray16) Val(x, y int) float64

Val returns the grayscale value at x, y as a float64.

func (*SippGray16) Write

func (img *SippGray16) Write(out *string) error

Write encodes the image into a PNG of the given name.

type SippImage

type SippImage interface {
	// Embed the Go image interface to allow reading and writing using the Go
	// PNG decoder and encoder.
	image.Image
	// Bounded Go images all implement PixOffset, though it's not part of the
	// Image interface, so it's included here.
	PixOffset(x, y int) int
	// Pix returns the slice of underlying image data, for efficient access.
	Pix() []uint8
	// Val returns the grayscale value at x, y as a float64.
	Val(x, y int) float64
	// IntVal returns the grayscale value at x, y as an int32.
	IntVal(x, y int) int32
	// Bpp returns the pixel depth of this image, either 8 or 16.
	Bpp() int
	// Write encodes the image into a PNG of the given name.
	Write(out *string) error
	// Thumbnail returns a small version of the image. Thumbnails are always
	// 8-bit Gray images. TODO: If the original is smaller than the thumbnail,
	// the returned image will contain the original, centered.
	Thumbnail() SippImage
}

SippImage embeds the Image interface from the Go standard library and adds a few methods to enable polymorphism.

func Read

func Read(in string) (SippImage, error)

Read decodes the file named by the given string, returning a SippImage. Returns an Error if the image is not grayscale, either 8 or 16 bit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL