jpeg

package
v0.0.0-...-6d4da9f Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: BSD-3-Clause Imports: 4 Imported by: 2

Documentation

Overview

Package jpeg implements reading and writing JPEG files as planar YUV data.

Package jpeg implements reading and writing JPEG files as planar YUV data.

Index

Constants

View Source
const (
	Y = 0
	U = 1
	V = 2
)

Planes

View Source
const AlignSize int = 16

The dimension multiple to which data buffers should be aligned.

Variables

This section is empty.

Functions

func WriteJPEG

func WriteJPEG(img *YUVImage, dest io.Writer, params CompressionParameters) (err error)

WriteJPEG writes a YUVImage as a JPEG into dest.

Types

type CompressionParameters

type CompressionParameters struct {
	Quality  int  // Desired JPEG quality, 0-99
	Optimize bool // Whether to optimize the Huffman tables (slower)
	FastDCT  bool // Use a faster, less accurate DCT (note: do not use for Quality > 90)
}

CompressionParameters specifies which settings to use during Compression.

type DecompressionParameters

type DecompressionParameters struct {
	TargetWidth  int  // Desired output width
	TargetHeight int  // Desired output height
	FastDCT      bool // Use a faster, less accurate DCT (note: do not use for Quality > 90)
}

DecompressionParameters specifies which settings to use during decompression. TargetWidth, TargetHeight specify the minimum image dimensions required. The image will be downsampled if applicable.

type PixelFormat

type PixelFormat int

PixelFormat represents a JPEG pixel format (either YUVxxx or Grayscale).

const (
	Grayscale PixelFormat = iota
	YUV444                // 1x1 subsampling
	YUV422                // 2x2 subsampling
	YUV440                // 1x2 subsampling
	YUV420                // 2x2 subsampling
)

Valid PixelFormats

type YUVImage

type YUVImage struct {
	Width, Height int
	Format        PixelFormat
	Data          [3][]byte
	Stride        [3]int
}

YUVImage represents a planar image. Data is stored in a raw array of bytes for each plane, with an explicit stride (instead of a multidimensional array). This should probably be replaced with image.YCbCr (which I didn't know existed...)

func ReadJPEG

func ReadJPEG(src io.Reader, params DecompressionParameters) (img *YUVImage, err error)

ReadJPEG reads a JPEG file and returns a planar YUV image.

func (*YUVImage) PlaneHeight

func (i *YUVImage) PlaneHeight(plane int) int

func (*YUVImage) PlaneWidth

func (i *YUVImage) PlaneWidth(plane int) int

Jump to

Keyboard shortcuts

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