Documentation ¶
Index ¶
- Variables
- func AdjustBrightness(img image.Image, percentage float64) *image.NRGBA
- func AdjustContrast(img image.Image, percentage float64) *image.NRGBA
- func AdjustFunc(img image.Image, fn func(c color.NRGBA) color.NRGBA) *image.NRGBA
- func AdjustGamma(img image.Image, gamma float64) *image.NRGBA
- func AdjustSigmoid(img image.Image, midpoint, factor float64) *image.NRGBA
- func Blur(img image.Image, radius int, sigma float64) *image.NRGBA
- func Clone(img image.Image) *image.NRGBA
- func Decode(r io.Reader) (image.Image, error)
- func Encode(w io.Writer, img image.Image, format Format) error
- func Grayscale(img image.Image) *image.NRGBA
- func Int26_6ToString(x fixed.Int26_6) string
- func Invert(img image.Image) *image.NRGBA
- func IsTooBright(img image.Image) bool
- func NewNRGBA(width, height int, fillColor color.Color) *image.NRGBA
- func Open(filename string) (image.Image, error)
- func ParseFont(b []byte) (*truetype.Font, error)
- func Pt(x, y int) fixed.Point26_6
- func Save(img image.Image, filename string) (err error)
- func Sharpen(img image.Image, radius int, sigma float64) *image.NRGBA
- type Context
- func (c *Context) DrawString(s string, p fixed.Point26_6) (fixed.Point26_6, error)
- func (c *Context) FontBox(s string, p fixed.Point26_6) (fixed.Point26_6, error)
- func (c *Context) PointToFixed(x float64) fixed.Int26_6
- func (c *Context) SetClip(clip image.Rectangle)
- func (c *Context) SetDPI(dpi float64)
- func (c *Context) SetDst(dst draw.Image)
- func (c *Context) SetFont(f *truetype.Font)
- func (c *Context) SetFontSize(fontSize float64)
- func (c *Context) SetHinting(hinting font.Hinting)
- func (c *Context) SetSrc(src image.Image)
- type Dao
- type DrawImg
- type Format
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedFormat means the given image format (or file extension) is unsupported. ErrUnsupportedFormat = errors.New("imaging: unsupported image format") )
Functions ¶
func AdjustBrightness ¶
AdjustBrightness changes the brightness of the image using the percentage parameter and returns the adjusted image. The percentage must be in range (-100, 100). The percentage = 0 gives the original image. The percentage = -100 gives solid black image. The percentage = 100 gives solid white image.
Examples:
dstImage = imaging.AdjustBrightness(srcImage, -15) // decrease image brightness by 15% dstImage = imaging.AdjustBrightness(srcImage, 10) // increase image brightness by 10%
func AdjustContrast ¶
AdjustContrast changes the contrast of the image using the percentage parameter and returns the adjusted image. The percentage must be in range (-100, 100). The percentage = 0 gives the original image. The percentage = -100 gives solid grey image.
Examples:
dstImage = imaging.AdjustContrast(srcImage, -10) // decrease image contrast by 10% dstImage = imaging.AdjustContrast(srcImage, 20) // increase image contrast by 20%
func AdjustFunc ¶
AdjustFunc performs a gamma correction on the image and returns the adjusted image.
func AdjustGamma ¶
AdjustGamma performs a gamma correction on the image and returns the adjusted image. Gamma parameter must be positive. Gamma = 1.0 gives the original image. Gamma less than 1.0 darkens the image and gamma greater than 1.0 lightens it.
Example:
dstImage = imaging.AdjustGamma(srcImage, 0.7)
func AdjustSigmoid ¶
AdjustSigmoid changes the contrast of the image using a sigmoidal function and returns the adjusted image. It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail. The midpoint parameter is the midpoint of contrast that must be between 0 and 1, typically 0.5. The factor parameter indicates how much to increase or decrease the contrast, typically in range (-10, 10). If the factor parameter is positive the image contrast is increased otherwise the contrast is decreased.
Examples:
dstImage = imaging.AdjustSigmoid(srcImage, 0.5, 3.0) // increase the contrast dstImage = imaging.AdjustSigmoid(srcImage, 0.5, -3.0) // decrease the contrast
func Encode ¶
Encode writes the image img to w in the specified format (JPEG, PNG, GIF, TIFF or BMP).
func Int26_6ToString ¶
Int26_6ToString convert Int26_6 to string.
func IsTooBright ¶
IsTooBright assume that average brightness higher than 100 is too bright.
func NewNRGBA ¶
NewNRGBA creates a new image with the specified width and height, and fills it with the specified color.
func Pt ¶
Pt converts from a co-ordinate pair measured in pixels to a fixed.Point26_6 co-ordinate pair measured in fixed.Int26_6 units.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context holds the state for drawing text in a given font and size.
func (*Context) DrawString ¶
DrawString draws s at p and returns p advanced by the text extent.
func (*Context) PointToFixed ¶
PointToFixed converts the given number of points (as in "a 12 point font") into a 26.6 fixed point number of pixels.
func (*Context) SetFontSize ¶
SetFontSize sets the font size in points (as in "a 12 point font").
func (*Context) SetHinting ¶
SetHinting sets the hinting policy.