Help us shape the future of Go! Take the 2026 Go Developer Survey

imageops

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package imageops 提供渲染期的纯图片像素运算:透明度、掩码合成、内容边界、裁图及印章白底透明化。

本包不依赖 OFD 模型、绘制后端或资源缓存。输入图片与掩码均视为只读;需要修改 像素时分配独立结果。不透明度不变时可直接返回原图,保留懒解码和原编码内嵌。 裁剪路径的栅格化、页面坐标及是否应用印章白底策略由调用方负责。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAlpha

func ApplyAlpha(img image.Image, alpha uint8) image.Image

ApplyAlpha 将整张图片的不透明度乘以 alpha,不修改原图,255 时直接返回原图。

func ApplyMaskAlpha

func ApplyMaskAlpha(img image.Image, mask *image.Alpha, alpha uint8) image.Image

ApplyMaskAlpha 一次合成源 Alpha、覆盖率掩码和对象 Alpha。掩码左上角对应原图 左上角,尺寸须覆盖原图;返回独立 NRGBA,不修改共享图片或掩码。

func ApplyResourceMask

func ApplyResourceMask(img, mask image.Image) image.Image

ApplyResourceMask 将资源掩码的亮度合成到原图透明度,尺寸不同时按比例取样。 掩码完全透明的像素视为零覆盖,缺失或空掩码保持原图。

func ContentBounds

func ContentBounds(img image.Image) (float64, float64, float64, float64)

ContentBounds 返回 Alpha 大于 8 的内容像素包围盒,保留图像原点,右下边界不包含。 空白图片返回全零,阈值与渲染器测量复合单元的既有行为一致。

func Crop

func Crop(img image.Image, x0, y0, x1, y1 int) image.Image

Crop 按原图像素区域生成以零为原点的独立 RGBA 图片。

func CropNRGBA

func CropNRGBA(img image.Image, region image.Rectangle) image.Image

CropNRGBA 按源图区域生成以零为原点的独立 NRGBA 图片,保留非预乘颜色。 region 应为源图内的有效非空区域;印章布局层负责区域计算及整图复用判断。

func SealTransparentBackground

func SealTransparentBackground(img image.Image) image.Image

SealTransparentBackground 将全不透明印章图中的近白纸张背景置为透明。 这是既有印章兼容策略:三个通道均不低于 250 时视为背景。 已有透明像素或无法查询 Opaque 的图像直接复用,避免删除其白色图案。

Types

This section is empty.

Jump to

Keyboard shortcuts

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