capture

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 10 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJPEG

func EncodeJPEG(img image.Image, quality int) ([]byte, error)

EncodeJPEG encodes an image as JPEG with the given quality (1-100).

func EncodePNG

func EncodePNG(img image.Image) ([]byte, error)

EncodePNG encodes an image as PNG.

func GenerateDiff

func GenerateDiff(old, new image.Image) image.Image

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).

func ScaleImage

func ScaleImage(img image.Image, scale float64) image.Image

ScaleImage resizes an image by the given scale factor using bilinear interpolation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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