image

package
v0.0.0-...-46e758b Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

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 BannerByte2Str(banner []byte) string

func ColorDraw

func ColorDraw(dy, dx int, image *image.NRGBA)

彩色绘制

func CreateFontImage

func CreateFontImage(opt *ContextWrapper, args ...interface{}) error

创建

func CreateImage

func CreateImage(text string, opts ...*ContextWrapper) (string, bool)

创建image

func GetError

func GetError() error

获取异常

func GetImageContext

func GetImageContext(file string) image.Image

获取图片文件上下文

func GetImageIndexToType

func GetImageIndexToType(id int) string

通过文件类枚举值 获取文件类型名 @param id int : 类型枚举

func GetImageType

func GetImageType(file string) string

获取文件类型

func GetImageTypeToIndex

func GetImageTypeToIndex(ty string) int

获取文件类型 枚举值 @param ty string : 文件类型名

func IsImageType

func IsImageType(ty string) bool

是否图片类型 @param ty string : 文件类型名

func NewImage

func NewImage(option *ContextWrapper) *image.NRGBA

创建image

func OpenImage

func OpenImage(file string) (image.Image, error)

获取图片资源

func Reader

func Reader(data []byte) ([]byte, error)

func SaveImageHandler

func SaveImageHandler(opt *ContextWrapper, file *os.File, img *image.NRGBA) error

保存图片

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

Jump to

Keyboard shortcuts

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