image

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxSize = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GioImg

type GioImg struct {

	//Size   image.Point
	Radius unit.Dp
	// contains filtered or unexported fields
}

Avatar is a widget displaying a square image. If radius is specified, the image is cropped with an outer rounded rectangle.

func NewGioImg

func NewGioImg(src *ImageSource) *GioImg

func (*GioImg) Layout

func (gi *GioImg) Layout(gtx layout.Context) layout.Dimensions

type ImageSource

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

ImageSource wraps a local or remote image, and handle things like scaling and converting. Only jpeg and png format for the source image is supported.

func ImageFromFile

func ImageFromFile(src string) (*ImageSource, error)

ImageFromFile load an image from local filesystem or from network.

func ImageFromReader

func ImageFromReader(src []byte) (*ImageSource, error)

ImageFromReader loads an image from a io.Reader. Image bytes buffer can be wrapped using a bytes.Reader to get an ImageSource.

func (*ImageSource) ImageOp

func (img *ImageSource) ImageOp(size image.Point) (paint.ImageOp, error)

ImageOp scales the src image to make it fit within the constraint specified by size and convert it to Gio ImageOp. If size has zero value of image Point, image is not scaled.

func (*ImageSource) Save

func (img *ImageSource) Save(out io.Writer, format string, size image.Point) error

Save scale the image if required, and encode image.Image to PNG/JPEG image, finally write to the provided writer. Format must be value of "jpeg" or "png".

func (*ImageSource) ScaleByRatio

func (img *ImageSource) ScaleByRatio(ratio float32) (image.Image, error)

func (*ImageSource) ScaleBySize

func (img *ImageSource) ScaleBySize(size image.Point) (image.Image, error)

func (*ImageSource) Size

func (img *ImageSource) Size() image.Point

Jump to

Keyboard shortcuts

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