gdkpixbuf

package
v0.0.0-...-17244d7 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

README

Go 图形处理库, 主要围绕 GdkPixbuf 库进行增强开发. 支持对图片进行 剪切, 翻转, 缩放, 混合, 模糊处理等操作.

API 的命名风格与 pkg.deepin.io/lib/graphic 库相同, 以 Blur 操作为例:

  • Blur 对 C.GdkPixbuf 对象进行模糊处理

  • BlurImage 对目标文件进行模糊处理

  • BlurImageCache 对目标文件进行模糊处理, 同时将处理后的文件放到缓 存目录, 下次对同一文件进行相同操作时可以大大提高速度

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Blur

func Blur(pixbuf *C.GdkPixbuf, sigma, numSteps float64) (err error)

Blur generate blur effect to pixbuf object.

func BlurImage

func BlurImage(srcFile, dstFile string, sigma, numSteps float64, f Format) (err error)

BlurImage generate blur effect to an image file.

func BlurImageCache

func BlurImageCache(srcFile string, sigma, numSteps float64, f Format) (dstFile string, useCache bool, err error)

BlurImageCache generate and save the blurred image file to cache directory, if target file already exists, just return it.

func ClipImage

func ClipImage(srcFile, destFile string, srcX, srcY, width, height int, f Format) (err error)

func ConvertImage

func ConvertImage(srcFile, destFile string, f Format) (err error)

func ConvertImageToXpixmap

func ConvertImageToXpixmap(imgFile string) (xpixmap x.Pixmap, err error)

ConvertImageToXpixmap convert image file to x pixmap.

func ConvertPixbufToXpixmap

func ConvertPixbufToXpixmap(pixbuf *C.GdkPixbuf) (xpixmap x.Pixmap, err error)

func ConvertXpixmapToPixbuf

func ConvertXpixmapToPixbuf(xpixmap x.Pixmap, width, height int) (pixbuf *C.GdkPixbuf, err error)

func CopyArea

func CopyArea(srcPixbuf, destPixbuf *C.GdkPixbuf, srcX, srcY, width, height, destX, destY int) (err error)

func CopyAreaSimple

func CopyAreaSimple(srcPixbuf *C.GdkPixbuf, srcX, srcY, width, height int) (destPixbuf *C.GdkPixbuf, err error)

func Flip

func Flip(srcPixbuf *C.GdkPixbuf, horizontal bool) (destPixbuf *C.GdkPixbuf, err error)

func FlipImageHorizontal

func FlipImageHorizontal(srcFile, destFile string, f Format) (err error)

func FlipImageVertical

func FlipImageVertical(srcFile, destFile string, f Format) (err error)

func FreePixbuf

func FreePixbuf(pixbuf *C.GdkPixbuf)

func GetDominantColor

func GetDominantColor(pixbuf *C.GdkPixbuf) (h, s, v float64, err error)

func GetDominantColorOfImage

func GetDominantColorOfImage(imgFile string) (h, s, v float64, err error)

GetDominantColorOfImage return the dominant hsv color of an image.

func GetImageSize

func GetImageSize(imgFile string) (w, h int, err error)

GetImageSize return image file's width and height.

func GetPreferScaleClipRect

func GetPreferScaleClipRect(refWidth, refHeight, imgWidth, imgHeight int) (x, y, w, h int, err error)

GetPreferScaleClipRect get the maximum rectangle in center of image which with the same scale to reference width/heigh.

func GetSize

func GetSize(pixbuf *C.GdkPixbuf) (w, h int, err error)

GetSize return pixbuf's width and height.

func Hsv2Rgb

func Hsv2Rgb(h, s, v float64) (r, g, b uint8)

Hsv2Rgb convert color format from HSV(h=[0..360), s,v=[0..1]) to RGB(r, g, b=[0..255]).

func InitGdk

func InitGdk() (err error)

InitGdk initialize gdk.

func InitGdkXlib

func InitGdkXlib() (err error)

InitGdkXlib initialize gdk and xlib, should not be used with InitGdk().

func IsSupportedImage

func IsSupportedImage(imgFile string) bool

IsSupportedImage check if image file is supported.

func NewPixbufFromFile

func NewPixbufFromFile(imgFile string) (pixbuf *C.GdkPixbuf, err error)

func Rgb2Hsv

func Rgb2Hsv(r, g, b uint8) (h, s, v float64)

Rgb2Hsv convert color format from RGB(r, g, b=[0..255]) to HSV(h=[0..360), s,v=[0..1]).

func RotateImageLeft

func RotateImageLeft(srcFile, destFile string, f Format) (err error)

func RotateImageRight

func RotateImageRight(srcFile, destFile string, f Format) (err error)

func RotateImageUpsizedown

func RotateImageUpsizedown(srcFile, destFile string, f Format) (err error)

func RotateSimple

func RotateSimple(srcPixbuf *C.GdkPixbuf, angle GdkPixbufRotation) (destPixbuf *C.GdkPixbuf, err error)

func Save

func Save(pixbuf *C.GdkPixbuf, destFile string, f Format) (err error)

func ScaleImage

func ScaleImage(srcFile, destFile string, newWidth, newHeght int, interpType GdkInterpType, f Format) (err error)

ScaleImage returns a new image file with the given width and height created by resizing the given image.

func ScaleImageCache

func ScaleImageCache(srcFile string, newWidth, newHeght int, interpType GdkInterpType, f Format) (destFile string, useCache bool, err error)

func ScaleImagePrefer

func ScaleImagePrefer(srcFile, destFile string, newWidth, newHeght int, interpType GdkInterpType, f Format) (err error)

ScaleImagePrefer resize image file to new width and heigh, and maintain the original proportions unchanged.

func ScaleImagePreferCache

func ScaleImagePreferCache(srcFile string, newWidth, newHeght int, interpType GdkInterpType, f Format) (destFile string, useCache bool, err error)

func ScalePrefer

func ScalePrefer(srcPixbuf *C.GdkPixbuf, newWidth, newHeight int, interpType GdkInterpType) (destPixbuf *C.GdkPixbuf, err error)

ScalePrefer resize pixbuf to new width and heigh, and maintain the original proportions unchanged.

func ScaleSimple

func ScaleSimple(srcPixbuf *C.GdkPixbuf, newWidth, newHeght int, interpType GdkInterpType) (destPixbuf *C.GdkPixbuf, err error)

func Screenshot

func Screenshot() (pixbuf *C.GdkPixbuf, err error)

func ScreenshotImage

func ScreenshotImage(file string, f Format) (err error)

func Thumbnail

func Thumbnail(srcPixbuf *C.GdkPixbuf, maxWidth, maxHeight int, interpType GdkInterpType) (destPixbuf *C.GdkPixbuf, err error)

Thumbnail resize pixbuf with limited maximum width and height.

func ThumbnailImage

func ThumbnailImage(srcFile, destFile string, maxWidth, maxHeight int, interpType GdkInterpType, f Format) (err error)

ThumbnailImage resize target image file with limited maximum width and height.

Types

type Format

type Format string

Format defines the type of image format.

const (
	FormatPng  Format = "png"
	FormatJpeg Format = "jpeg"
	FormatBmp  Format = "bmp"
	FormatIco  Format = "ico"
	FormatTiff Format = "tiff"
)

Registered image format.

func GetImageFormat

func GetImageFormat(imgFile string) (f Format, err error)

GetImageFormat return image file's format, such as "png", "jpeg".

type GdkColorspace

type GdkColorspace uint
const (
	GDK_COLORSPACE_RGB GdkColorspace = iota
)

type GdkInterpType

type GdkInterpType uint
const (
	GDK_INTERP_NEAREST GdkInterpType = iota
	GDK_INTERP_TILES
	GDK_INTERP_BILINEAR
	GDK_INTERP_HYPER
)

type GdkPixbufAlphaMode

type GdkPixbufAlphaMode uint
const (
	GDK_PIXBUF_ALPHA_BILEVEL GdkPixbufAlphaMode = iota
	GDK_PIXBUF_ALPHA_FULL
)

type GdkPixbufError

type GdkPixbufError uint
const (
	/* image data hosed */
	GDK_PIXBUF_ERROR_CORRUPT_IMAGE GdkPixbufError = iota
	/* no mem to load image */
	GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY
	/* bad option passed to save routine */
	GDK_PIXBUF_ERROR_BAD_OPTION
	/* unsupported image type (sort of an ENOSYS) */
	GDK_PIXBUF_ERROR_UNKNOWN_TYPE
	/* unsupported operation (load, save) for image type */
	GDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION
	GDK_PIXBUF_ERROR_FAILED
)

type GdkPixbufRotation

type GdkPixbufRotation uint
const (
	GDK_PIXBUF_ROTATE_NONE             GdkPixbufRotation = 0
	GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE GdkPixbufRotation = 90
	GDK_PIXBUF_ROTATE_UPSIDEDOWN       GdkPixbufRotation = 180
	GDK_PIXBUF_ROTATE_CLOCKWISE        GdkPixbufRotation = 270
)

type GdkPixdataDumpType

type GdkPixdataDumpType uint
const (
	/* type of source to save */
	GDK_PIXDATA_DUMP_PIXDATA_STREAM GdkPixdataDumpType = 0
	GDK_PIXDATA_DUMP_PIXDATA_STRUCT GdkPixdataDumpType = 1
	GDK_PIXDATA_DUMP_MACROS         GdkPixdataDumpType = 2
	/* type of variables to use */
	GDK_PIXDATA_DUMP_GTYPES GdkPixdataDumpType = 0
	GDK_PIXDATA_DUMP_CTYPES GdkPixdataDumpType = 1 << 8
	GDK_PIXDATA_DUMP_STATIC GdkPixdataDumpType = 1 << 9
	GDK_PIXDATA_DUMP_CONST  GdkPixdataDumpType = 1 << 10
	/* save RLE decoder macro? */
	GDK_PIXDATA_DUMP_RLE_DECODER GdkPixdataDumpType = 1 << 16
)

type GdkPixdataType

type GdkPixdataType uint
const (
	/* colorspace + alpha */
	GDK_PIXDATA_COLOR_TYPE_RGB  GdkPixdataType = 0x01
	GDK_PIXDATA_COLOR_TYPE_RGBA GdkPixdataType = 0x02
	GDK_PIXDATA_COLOR_TYPE_MASK GdkPixdataType = 0xff
	/* width, support 8bits only currently */
	GDK_PIXDATA_SAMPLE_WIDTH_8    GdkPixdataType = 0x01 << 16
	GDK_PIXDATA_SAMPLE_WIDTH_MASK GdkPixdataType = 0x0f << 16
	/* encoding */
	GDK_PIXDATA_ENCODING_RAW  GdkPixdataType = 0x01 << 24
	GDK_PIXDATA_ENCODING_RLE  GdkPixdataType = 0x02 << 24
	GDK_PIXDATA_ENCODING_MASK GdkPixdataType = 0x0f << 24
)

Jump to

Keyboard shortcuts

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