Documentation
¶
Overview ¶
Package capture provides image conversion and processing utilities for VM screenshot workflows.
It converts CGImage data (BGRA pixel format) to Go image.Image values, generates visual diffs between successive frames, and encodes images to JPEG or PNG.
Basic usage:
img, err := capture.GoImageFromCGImage(cgImage, 0) data, err := capture.EncodeJPEG(img, 80)
Index ¶
- func EncodeJPEG(img image.Image, quality int) ([]byte, error)
- func EncodePNG(img image.Image) ([]byte, error)
- func GenerateDiff(old, new image.Image) image.Image
- func GoImageFromCGImage(cgImage coregraphics.CGImageRef, cropTopPx int) (image.Image, error)
- func ScaleImage(img image.Image, scale float64) image.Image
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeJPEG ¶
EncodeJPEG encodes an image as JPEG with the given quality (1-100).
func GenerateDiff ¶
GenerateDiff creates a diff image highlighting changes between two images. Changed pixels are shown in full color; unchanged pixels are shown as dimmed grayscale. If the dimensions differ, the new image is returned with a red border.
func GoImageFromCGImage ¶
func GoImageFromCGImage(cgImage coregraphics.CGImageRef, cropTopPx int) (image.Image, error)
GoImageFromCGImage converts a CGImageRef to a Go image.Image. CGImage uses BGRA pixel format; this function converts to RGBA. If cropTopPx > 0, that many pixels are cropped from the top (useful for removing window title bars from screenshots).
Types ¶
This section is empty.