image

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Change this if you want to load larger images from the web. Default max size is 10M.
	MaxDownloadSize = 1024 * 1024 * 10

	// Timeout for http request.
	DownloadTimeout = time.Second * 10
)

Functions

This section is empty.

Types

type HttpClient added in v0.2.0

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

Because of network anti crawler policies applied by sites, we have to disguising out http client as browsers, see below link for details: https://req.cool/blog/supported-http-fingerprint-impersonation-to-bypass-anti-crawler-detection-effortlessly/

func (*HttpClient) Download added in v0.2.0

func (c *HttpClient) Download(location string) (string, io.ReadCloser, error)

type ImageSource

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

ImageSource wraps a local or remote image. Only jpeg and png format for is supported. When displaying, image scaled by the specified size and cached.

func ImageFromBuf added in v0.2.0

func ImageFromBuf(src []byte) *ImageSource

ImageFromBuf loads an image from bytes buffer.

func ImageFromFile

func ImageFromFile(src string) *ImageSource

ImageFromFile load an image from local filesystem or from network.

func (*ImageSource) Error added in v0.2.0

func (img *ImageSource) Error() error

func (*ImageSource) ImageOp

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

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) IsNetworkImg added in v0.2.0

func (img *ImageSource) IsNetworkImg() bool

IsNetworkImg check if this image is loaded/to be loaded from network.

func (*ImageSource) ScaleByRatio

func (img *ImageSource) ScaleByRatio(ratio float32) (*paint.ImageOp, error)

func (*ImageSource) ScaleBySize

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

func (*ImageSource) Size

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

type ImageStyle added in v0.2.0

type ImageStyle struct {

	//Size   image.Point
	Radius   unit.Dp
	Fit      widget.Fit
	Position layout.Direction
	// contains filtered or unexported fields
}

ImageStyle is a widget displaying an image from an ImageSource. Styling parameters can be set after construction. Displayed size is specified by the max constraints of the widget.

func NewImage added in v0.2.0

func NewImage(src *ImageSource) *ImageStyle

func (*ImageStyle) Layout added in v0.2.0

func (img *ImageStyle) Layout(gtx layout.Context) layout.Dimensions

Jump to

Keyboard shortcuts

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