png

package
v0.0.0-...-4c07360 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Critical Chunks
	IHDR string = "IHDR"
	PLTE string = "PLTE"
	IDAT string = "IDAT"
	IEND string = "IEND"

	Byte         uint32 = 1
	Kibibyte            = 1024 * Byte
	Mebibyte            = 1024 * Kibibyte
	Gibibyte            = 1024 * Mebibyte
	MaxChunkSize        = 100 * Mebibyte

	Greyscale          = byte(0)
	TrueColor          = byte(2)
	IndexedColor       = byte(3)
	GreyscaleWithAlpha = byte(4)
	TrueColorWithAlpha = byte(6)
)
View Source
const (
	None    = byte(0)
	Sub     = byte(1)
	Up      = byte(2)
	Average = byte(3)
	Paeth   = byte(4)
)

Variables

This section is empty.

Functions

func Decompress

func Decompress(chunk_map ChunkMap) ([]byte, error)

func Unfilter

func Unfilter(filtered_bytes []byte, ihdr *IHDRChunk) ([][]byte, error)

Types

type Chunk

type Chunk struct {
	// contains filtered or unexported fields
}

func (*Chunk) Iscritical

func (self *Chunk) Iscritical() bool

func (*Chunk) Reader

func (self *Chunk) Reader() io.Reader

type ChunkMap

type ChunkMap map[string][]Chunk

func ReadChunks

func ReadChunks(file *os.File) (ChunkMap, error)

func (ChunkMap) IHDR

func (self ChunkMap) IHDR() (*IHDRChunk, error)

func (ChunkMap) PLTE

func (self ChunkMap) PLTE() (*Palette, error)

type Filter

type Filter interface {
	Process([]byte, [][]byte) ([]byte, error)
}

type GrayScaleImageBuilder

type GrayScaleImageBuilder[T Uint] struct {
	IHDR *IHDRChunk
}

func (*GrayScaleImageBuilder[T]) BuildPixels

func (self *GrayScaleImageBuilder[T]) BuildPixels(data [][]byte) (*ImageData, error)

type GrayscalePixel

type GrayscalePixel[T Uint] struct {
	// contains filtered or unexported fields
}

func CreateGrayscalePixel

func CreateGrayscalePixel[T Uint](g T) *GrayscalePixel[T]

func CreateGrayscaleWithAlphaPixel

func CreateGrayscaleWithAlphaPixel[T Uint](g T, a T) *GrayscalePixel[T]

func (*GrayscalePixel[T]) Uint16

func (self *GrayscalePixel[T]) Uint16() []uint16

type GrayscaleReader

type GrayscaleReader[T Uint] struct {
	HasAlpha bool
	Bits     uint
}

func (*GrayscaleReader[T]) ReadPixels

func (self *GrayscaleReader[T]) ReadPixels(reader *bytes.Reader, n uint32) ([]Pixel, error)

type Histogram

type Histogram map[uint16]uint64

type IByteBuffer

type IByteBuffer interface {
	GetRawData() []byte
	GetReader() *bytes.Reader
}

Abstract chunk data to handle big chunks in the future

type IDatMemoryReader

type IDatMemoryReader struct {
	// contains filtered or unexported fields
}

func (*IDatMemoryReader) Reader

func (idat *IDatMemoryReader) Reader() io.Reader

type IHDRChunk

type IHDRChunk struct {
	Width       uint32
	Height      uint32
	Bitdepth    byte
	Colortype   byte
	Compression byte
	Filter      byte
	Interlace   byte
}

func (*IHDRChunk) FilterStep

func (ihdr *IHDRChunk) FilterStep() uint32

func (*IHDRChunk) GetBytesPerLine

func (self *IHDRChunk) GetBytesPerLine() (uint32, error)

func (*IHDRChunk) GetSamples

func (self *IHDRChunk) GetSamples() (uint32, error)

func (*IHDRChunk) HasAlpha

func (self *IHDRChunk) HasAlpha() bool

type IdentityFilter

type IdentityFilter struct{}

func (*IdentityFilter) Process

func (f *IdentityFilter) Process(data []byte, processed [][]byte) ([]byte, error)

type ImageBuilder

type ImageBuilder interface {
	BuildPixels([][]byte) (*ImageData, error)
}

type ImageData

type ImageData struct {
	Metadata *IHDRChunk
	Pixels   [][]Pixel
}

func ReadPng

func ReadPng(filename string) (*ImageData, error)

func (*ImageData) Mean

func (self *ImageData) Mean() []uint64

type MemoryBuffer

type MemoryBuffer struct {
	// contains filtered or unexported fields
}

func (*MemoryBuffer) GetRawData

func (memoryData *MemoryBuffer) GetRawData() []byte

func (*MemoryBuffer) GetReader

func (self *MemoryBuffer) GetReader() *bytes.Reader

type Palette

type Palette struct{}

type PaletteImageBuilder

type PaletteImageBuilder struct {
	IHDR *IHDRChunk
	PLTE *Palette
}

func (*PaletteImageBuilder) BuildPixels

func (self *PaletteImageBuilder) BuildPixels(data [][]byte) (*ImageData, error)

type Pixel

type Pixel interface {
	Uint16() []uint16
}

type PixelReader

type PixelReader[T Uint] interface {
	ReadPixels(reader *bytes.Buffer, n uint32) ([]Pixel, error)
}

type PixelValue

type PixelValue []uint32

type RGBImageBuilder

type RGBImageBuilder[T Uint] struct {
	IHDR *IHDRChunk
}

func (*RGBImageBuilder[T]) BuildPixels

func (self *RGBImageBuilder[T]) BuildPixels(data [][]byte) (*ImageData, error)

type RGBPixel

type RGBPixel[T Uint] struct {
	// contains filtered or unexported fields
}

func CreateRGB

func CreateRGB[T Uint](r T, g T, b T) *RGBPixel[T]

func CreateRGBA

func CreateRGBA[T Uint](r T, g T, b T, a T) *RGBPixel[T]

func (*RGBPixel[T]) Uint16

func (self *RGBPixel[T]) Uint16() []uint16

type RgbReader

type RgbReader[T Uint] struct {
	HasAlpha bool
	Bits     uint
}

func (*RgbReader[T]) ReadPixels

func (self *RgbReader[T]) ReadPixels(reader *bytes.Reader, n uint32) ([]Pixel, error)

type Uint

type Uint interface {
	uint | uint8 | uint16 | uint32 | uint64
}

type UndoAverageFilter

type UndoAverageFilter struct {
	// contains filtered or unexported fields
}

func (*UndoAverageFilter) Process

func (self *UndoAverageFilter) Process(data []byte, processed [][]byte) ([]byte, error)

type UndoPaethFilter

type UndoPaethFilter struct {
	// contains filtered or unexported fields
}

func (*UndoPaethFilter) PaethPredictor

func (self *UndoPaethFilter) PaethPredictor(a byte, b byte, c byte) byte

func (*UndoPaethFilter) Process

func (self *UndoPaethFilter) Process(data []byte, processed [][]byte) ([]byte, error)

type UndoSubFilter

type UndoSubFilter struct {
	// contains filtered or unexported fields
}

func (*UndoSubFilter) Process

func (f *UndoSubFilter) Process(data []byte, processed [][]byte) ([]byte, error)

type UndoUpFilter

type UndoUpFilter struct {
	// contains filtered or unexported fields
}

func (*UndoUpFilter) Process

func (self *UndoUpFilter) Process(data []byte, processed [][]byte) ([]byte, error)

Jump to

Keyboard shortcuts

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