Documentation
¶
Index ¶
- func AsNRGBA(img image.Image) *image.NRGBA
- func AsRGBA(img image.Image) *image.RGBA
- func Blend(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, ...) (image.Image, error)
- func Composite(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, ...) (image.Image, error)
- func Draw(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, ...) (image.Image, error)
- func DrawToDst(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, ...) (image.Image, error)
- func DrawToImage(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, ...) (image.Image, error)
- func DrawToNewImage(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, ...) (image.Image, error)
- func SetDefaultContext(ctx Context)
- func ToDst() core.Output
- func ToImage(img image.Image, pt image.Point) core.Output
- func ToNewImage() core.Output
- type Context
- type Option
- type PixCalculator
- type PixRowCalculator
- type PixelIterator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsNRGBA ¶
AsNRGBA returns the image as an *image.NRGBA. If the image is already in this format, it is returned directly. Otherwise, a new NRGBA image is created and the content is drawn onto it.
func AsRGBA ¶
AsRGBA returns the image as an *image.RGBA. If the image is already in this format, it is returned directly. Otherwise, a new RGBA image is created and the content is drawn onto it.
func Blend ¶
func Blend(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, op op.BlendOp, output core.Output) (image.Image, error)
Blend performs a blend operation using the default context. See Context.Blend for details.
func Composite ¶
func Composite(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, op op.CompositeOp, output core.Output) (image.Image, error)
Composite performs a composite operation using the default context. See Context.Composite for details.
func Draw ¶
func Draw(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, oper internal.Op, output core.Output) (image.Image, error)
Draw is the primary function for applying image manipulation operations (both blend and composite) using the default context. It follows similar semantics as Go's draw.Draw function. However, rather than always writing to the destination image, this function writes to a specified output which may be the destination image, a provided image, or a new image. It returns the modified output image.
func DrawToDst ¶
func DrawToDst(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, op internal.Op) (image.Image, error)
DrawToDst is a convenience function that applies an operation using the default context and writes the result directly to the destination image (dst). It is equivalent to calling Draw with ToDst() as the output.
func DrawToImage ¶
func DrawToImage(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, op internal.Op, out image.Image, outPt image.Point) (image.Image, error)
DrawToImage is a convenience function that applies an operation using the default context and writes the result to a user-provided image at a specified point. It is equivalent to calling Draw with ToImage(out, outPt) as the output.
func DrawToNewImage ¶
func DrawToNewImage(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, op internal.Op) (image.Image, error)
DrawToNewImage is a convenience function that applies an operation using the default context and writes the result to a newly created image. It is equivalent to calling Draw with ToNewImage() as the output.
func SetDefaultContext ¶
func SetDefaultContext(ctx Context)
SetDefaultContext sets the default configuration for the project. This will affect all subsequent operations that use the default context.
func ToNewImage ¶
ToNewImage returns an Output that creates a new image.
Types ¶
type Context ¶
type Context interface {
core.Config
// Blend applies a blend operation and optional compositing.
// It follows similar semantics as draw.Draw. However, rather than always writing to the destination image,
// this function writes to output which may be the destination image, a provided image, or a new image.
// Returns the modified output image.
Blend(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, op op.BlendOp, out core.Output) (image.Image, error)
// Composite applies a composite operation.
// It follows similar semantics as draw.Draw. However, rather than always writing to the destination image,
// this function writes to output which may be the destination image, a provided image, or a new image.
// Returns the modified output image.
Composite(dst image.Image, r image.Rectangle, src image.Image, sp image.Point, op op.CompositeOp, out core.Output) (image.Image, error)
}
Context defines the interface for image manipulation operations. It holds configuration settings that control how blending and compositing operations are performed.
func DefaultContext ¶
func DefaultContext() Context
DefaultContext returns the default Magpie context. This context is used by the top-level Blend and Composite functions.
func NewContext ¶
func NewContext(options ...func(*context)) Context
NewContext creates a new Context with the given options. The default configuration is used as a base, with the options overriding default values.
type Option ¶
type Option func(*context)
Option is a function that configures a Context.
func WithDefaultColorModelNRGBA ¶
func WithDefaultColorModelNRGBA() Option
WithDefaultColorModelNRGBA sets the default color model to NRGBA. The default color model is only used when none of the images use a supported color model.
func WithDefaultColorModelRGBA ¶
func WithDefaultColorModelRGBA() Option
WithDefaultColorModelRGBA sets the default color model to RGBA. The default color model is only used when none of the images use a supported color model.
func WithDefaultToDst ¶
func WithDefaultToDst() Option
WithDefaultToDst sets the default output mode to write to the destination image.
func WithDefaultToNewImage ¶
func WithDefaultToNewImage() Option
WithDefaultToNewImage sets the default output mode to create a new image.
func WithPixelIterator ¶
WithPixelIterator sets the pixel iterator to be used by the context. The concurrency parameter specifies the number of goroutines to use for parallel processing.
func WithPixelIteratorInstance ¶
func WithPixelIteratorInstance(pixIter core.PixelIterator) Option
WithPixelIteratorInstance sets the pixel iterator to be used by the context. The provided instance will be used instead of creating a new one.
type PixCalculator ¶
type PixCalculator[T image.Image] = core.PixCalculator[T]
PixCalculator calculates the set of Pix slices for a given row.
type PixRowCalculator ¶
type PixRowCalculator = core.PixRowCalculator
type PixelIterator ¶
type PixelIterator = core.PixelIterator
PixelIterator is an alias for core.PixelIterator. It iterates over pixels in an image an passes each row to a PixRowCalculator.
func NewPixelIterator ¶
func NewPixelIterator(concurrency int) PixelIterator
NewPixelIterator creates a new PixelIterator. Concurrency specifies the number of goroutines to use for parallel processing.