Documentation ¶
Index ¶
- Variables
- func ClearCache()
- type HttpClient
- type ImageSource
- func (img *ImageSource) Error() error
- func (img *ImageSource) Format() string
- func (img *ImageSource) ImageOp(size image.Point) *paint.ImageOp
- func (img *ImageSource) IsNetworkImg() bool
- func (img *ImageSource) Location() string
- func (img *ImageSource) OnLoaded(callback func())
- func (img *ImageSource) ScaleByRatio(ratio float32) (*paint.ImageOp, error)
- func (img *ImageSource) ScaleBySize(size image.Point) (*paint.ImageOp, error)
- func (img *ImageSource) ScaleRatio() float32
- func (img *ImageSource) Size() image.Point
- type ImageStyle
- type Quality
Constants ¶
This section is empty.
Variables ¶
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 )
var CacheCapacity int = 100
CacheCapacity set how many network images can be cached. Set
Functions ¶
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/
type ImageSource ¶
type ImageSource struct { // Select the quality of the scaled image. ScaleQuality Quality // Choose whether to buffer src image or not. Buffering reduces frequent // image loading, but at the price of higher memory usage. Has no effect // for image reading from bytes. UseSrcBuf bool // contains filtered or unexported fields }
ImageSource wraps a local or remote image. Only jpeg, png and gif 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 lazily. For eager image loading, use ImageFromBuf instead.
func (*ImageSource) Error ¶ added in v0.2.0
func (img *ImageSource) Error() error
func (*ImageSource) Format ¶ added in v0.6.0
func (img *ImageSource) Format() string
func (*ImageSource) ImageOp ¶
func (img *ImageSource) ImageOp(size image.Point) *paint.ImageOp
ImageOp scales the src image dynamically or scales to the expected size if size if set. If the passed size is the 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) Location ¶ added in v0.7.0
func (img *ImageSource) Location() string
func (*ImageSource) OnLoaded ¶ added in v0.7.0
func (img *ImageSource) OnLoaded(callback func())
func (*ImageSource) ScaleByRatio ¶
func (img *ImageSource) ScaleByRatio(ratio float32) (*paint.ImageOp, error)
func (*ImageSource) ScaleBySize ¶
func (*ImageSource) ScaleRatio ¶ added in v0.6.0
func (img *ImageSource) ScaleRatio() float32
func (*ImageSource) Size ¶
func (img *ImageSource) Size() image.Point
type ImageStyle ¶ added in v0.2.0
type ImageStyle struct { Src *ImageSource //Size image.Point Radius unit.Dp Fit widget.Fit Scale float32 Position layout.Direction }
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 (ImageStyle) Layout ¶ added in v0.2.0
func (img ImageStyle) Layout(gtx layout.Context) layout.Dimensions
type Quality ¶ added in v0.6.0
type Quality uint8
const ( // scale source image using the nearest neighbor interpolator. Low Quality = iota // scale using ApproxBiLinear interpolator. Medium // scale using BiLinear interpolator. It is slow but gives high quality. High // scale using Catmull-Rom interpolator. It is very slow but gives the // best quality among the four. Highest )