Documentation
¶
Index ¶
- Constants
- Variables
- func BannerByte2Str(banner []byte) string
- func ColorDraw(dy, dx int, image *image.NRGBA)
- func CreateFontImage(opt *ContextWrapper, args ...interface{}) error
- func CreateImage(text string, opts ...*ContextWrapper) (string, bool)
- func GetError() error
- func GetImageContext(file string) image.Image
- func GetImageIndexToType(id int) string
- func GetImageType(file string) string
- func GetImageTypeToIndex(ty string) int
- func IsImageType(ty string) bool
- func NewImage(option *ContextWrapper) *image.NRGBA
- func OpenImage(file string) (image.Image, error)
- func Reader(data []byte) ([]byte, error)
- func SaveImageHandler(opt *ContextWrapper, file *os.File, img *image.NRGBA) error
- type ContextWrapper
- func (this *ContextWrapper) Content() string
- func (this *ContextWrapper) Dto() *OptionsDto
- func (this *ContextWrapper) File(text string) string
- func (this *ContextWrapper) GetContentOffsetY(c *freetype.Context) int
- func (this *ContextWrapper) GetDpi() float64
- func (this *ContextWrapper) GetEnd() int
- func (this *ContextWrapper) GetFileContext() *os.File
- func (this *ContextWrapper) GetFont() *truetype.Font
- func (this *ContextWrapper) GetFontByte() []byte
- func (this *ContextWrapper) GetFontFile() string
- func (this *ContextWrapper) GetFontSize() float64
- func (this *ContextWrapper) GetFontStartFixed() int
- func (this *ContextWrapper) GetFontXOffset() int
- func (this *ContextWrapper) GetFontYBit() int
- func (this *ContextWrapper) GetFontYOffset() int
- func (this *ContextWrapper) GetGifOption() *gif.Options
- func (this *ContextWrapper) GetHigh() int
- func (this *ContextWrapper) GetImageContext() *image.NRGBA
- func (this *ContextWrapper) GetImageFile(text string) *os.File
- func (this *ContextWrapper) GetImageType() string
- func (this *ContextWrapper) GetJpegOption() *jpeg.Options
- func (this *ContextWrapper) GetStart() int
- func (this *ContextWrapper) GetWidth() int
- func (this *ContextWrapper) GetX() int
- func (this *ContextWrapper) GetY() int
- func (this *ContextWrapper) Json() string
- func (this *ContextWrapper) Map() map[string]interface{}
- func (this *ContextWrapper) Release()
- func (this *ContextWrapper) SavePath() string
- func (this *ContextWrapper) String() string
- type OptionsDto
Constants ¶
View Source
const ( NumX1 = 100 // 长 NumY1 = 40 // 宽 Ext = ".png" // 文件后缀 FontFile = "resources/DejaVuSansMono/DejaVuSansCondensed-15.ttf" // 文字 ImgPNG = "png" // 文件类型 png ImgJPEG = "jpeg" // 文件类型 jpeg ImgGIF = "gif" // 文件类型 gif )
View Source
const ( UNKNOWN = iota GIF JPEG PNG SWF PSD BMP TiffIi TiffMm JPC JP2 JPX JB2 SWC IFF WBmp XBM ICO COUNT )
Variables ¶
View Source
var TypeMap = map[int]string{ UNKNOWN: "unknown", GIF: "gif", JPEG: "jpeg,jpg", PNG: "png", SWF: "swf", PSD: "psd", BMP: "bmp", TiffIi: "tiff_ti", TiffMm: "tiff_mm", JPC: "jpc", JP2: "jp2", JPX: "jpx", JB2: "jb2", SWC: "swc", IFF: "iff", WBmp: "wbmp", XBM: "xbm", ICO: "ico", COUNT: "count", }
Functions ¶
func BannerByte2Str ¶
func GetImageIndexToType ¶
通过文件类枚举值 获取文件类型名 @param id int : 类型枚举
func GetImageTypeToIndex ¶
获取文件类型 枚举值 @param ty string : 文件类型名
func SaveImageHandler ¶
保存图片
Types ¶
type ContextWrapper ¶
type ContextWrapper struct {
FontByte []byte // 字体信息
ColorDrawer func(dy, dx int, image *image.NRGBA) // 彩色绘制处理
JpegOptions *jpeg.Options // jpeg 可选参数
GifOptions *gif.Options // gif 可选参数
FileContext *os.File // file
ImageContext *image.NRGBA // image
OptionsDto
}
参数封装器
func NewContextWrapper ¶
func NewContextWrapper() *ContextWrapper
func (*ContextWrapper) Content ¶
func (this *ContextWrapper) Content() string
func (*ContextWrapper) Dto ¶
func (this *ContextWrapper) Dto() *OptionsDto
func (*ContextWrapper) File ¶
func (this *ContextWrapper) File(text string) string
func (*ContextWrapper) GetContentOffsetY ¶
func (this *ContextWrapper) GetContentOffsetY(c *freetype.Context) int
func (*ContextWrapper) GetDpi ¶
func (this *ContextWrapper) GetDpi() float64
func (*ContextWrapper) GetEnd ¶
func (this *ContextWrapper) GetEnd() int
func (*ContextWrapper) GetFileContext ¶
func (this *ContextWrapper) GetFileContext() *os.File
func (*ContextWrapper) GetFont ¶
func (this *ContextWrapper) GetFont() *truetype.Font
func (*ContextWrapper) GetFontByte ¶
func (this *ContextWrapper) GetFontByte() []byte
func (*ContextWrapper) GetFontFile ¶
func (this *ContextWrapper) GetFontFile() string
func (*ContextWrapper) GetFontSize ¶
func (this *ContextWrapper) GetFontSize() float64
func (*ContextWrapper) GetFontStartFixed ¶
func (this *ContextWrapper) GetFontStartFixed() int
func (*ContextWrapper) GetFontXOffset ¶
func (this *ContextWrapper) GetFontXOffset() int
func (*ContextWrapper) GetFontYBit ¶
func (this *ContextWrapper) GetFontYBit() int
func (*ContextWrapper) GetFontYOffset ¶
func (this *ContextWrapper) GetFontYOffset() int
func (*ContextWrapper) GetGifOption ¶
func (this *ContextWrapper) GetGifOption() *gif.Options
func (*ContextWrapper) GetHigh ¶
func (this *ContextWrapper) GetHigh() int
func (*ContextWrapper) GetImageContext ¶
func (this *ContextWrapper) GetImageContext() *image.NRGBA
func (*ContextWrapper) GetImageFile ¶
func (this *ContextWrapper) GetImageFile(text string) *os.File
func (*ContextWrapper) GetImageType ¶
func (this *ContextWrapper) GetImageType() string
func (*ContextWrapper) GetJpegOption ¶
func (this *ContextWrapper) GetJpegOption() *jpeg.Options
func (*ContextWrapper) GetStart ¶
func (this *ContextWrapper) GetStart() int
func (*ContextWrapper) GetWidth ¶
func (this *ContextWrapper) GetWidth() int
func (*ContextWrapper) GetX ¶
func (this *ContextWrapper) GetX() int
func (*ContextWrapper) GetY ¶
func (this *ContextWrapper) GetY() int
func (*ContextWrapper) Json ¶
func (this *ContextWrapper) Json() string
func (*ContextWrapper) Map ¶
func (this *ContextWrapper) Map() map[string]interface{}
func (*ContextWrapper) Release ¶
func (this *ContextWrapper) Release()
func (*ContextWrapper) SavePath ¶
func (this *ContextWrapper) SavePath() string
func (*ContextWrapper) String ¶
func (this *ContextWrapper) String() string
type OptionsDto ¶
type OptionsDto struct {
Width int // x1 宽
High int // y1 长
Start int // x0 长
End int // y0 长
Path string // 存储目录
ColorAble bool // 是否彩色绘制
FontFile string // 字体文件
SaveFile string // 保存文件名
AutoCreatePath bool // 自动创建保存目录
FontSize float64 // 字体大小
FontDpi float64 // 字体dpi
FontXOffset int // 文字x 轴偏移量 ptx
FontYOffset int // 文字y 轴偏移量 pty
FontYBit int // 文字y 位置
SaveImageType string // 图片保存类型 png,jpeg,gif
FontYOffsetWithOutContent int // 外表计算所得 y轴偏移量
// contains filtered or unexported fields
}
绘制参数
func NewOptionsDto ¶
func NewOptionsDto() *OptionsDto
Click to show internal directories.
Click to hide internal directories.