BufferAdapter

smile.infrastructure.BufferAdapter
See theBufferAdapter companion object
abstract class BufferAdapter[Buffer]

Adapter for managing and manipulating a bitmap. This class provides methods for common image processing tasks such as copying, scaling, and transforming.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def copyPortionXYWH(topLeftX: Double, topLeftY: Double, width: Double, height: Double): BufferAdapter[Buffer]

Copies a portion of the image defined by a top-left corner and dimensions.

Copies a portion of the image defined by a top-left corner and dimensions.

Value parameters

height

Height of the portion to copy.

topLeftX

X-coordinate of the top-left corner.

topLeftY

Y-coordinate of the top-left corner.

width

Width of the portion to copy.

Attributes

Returns

A new BufferAdapter instance containing the copied portion of the image.

def createTransformedVersionWith(transformation: AffineTransformation, backgroundColor: Color): BufferAdapter[Buffer]

Creates a new BufferAdapter instance that is a transformed version of the current buffer. The transformation is applied using an AffineTransformation. The canvas can optionally be resized based on the transformation.

Creates a new BufferAdapter instance that is a transformed version of the current buffer. The transformation is applied using an AffineTransformation. The canvas can optionally be resized based on the transformation.

Value parameters

backgroundColor

The background color to use when clearing the canvas if resizing is necessary. Defaults to DefaultBackgroundColor.

transformation

The AffineTransformation to apply to the image.

Attributes

Returns

A new BufferAdapter instance containing the transformed image.

def deepCopy: BufferAdapter[Buffer]

Creates a deep copy of the current BufferAdapter instance, drawing the current buffer onto a new one.

Creates a deep copy of the current BufferAdapter instance, drawing the current buffer onto a new one.

Attributes

Returns

A new BufferAdapter instance that is a copy of the current one.

def get: Buffer
def imageData: Seq[Color]
def pixelColor(x: Int, y: Int): Color

Retrieves the color at a specified pixel location in the buffer.

Retrieves the color at a specified pixel location in the buffer.

Value parameters

x

The x-coordinate of the pixel.

y

The y-coordinate of the pixel.

Attributes

Returns

The Color of the pixel at the specified coordinates.

def scaleTo(targetWidth: Double, targetHeight: Double): BufferAdapter[Buffer]

Scales the image to a target width and height.

Scales the image to a target width and height.

Value parameters

targetHeight

The target height for the scaled image.

targetWidth

The target width for the scaled image.

Attributes

Returns

A new BufferAdapter instance containing the scaled image.

def setColorsFromSeq(colors: Seq[Color]): Unit

Sets the colors of the image from a sequence of Color objects.

Sets the colors of the image from a sequence of Color objects.

Value parameters

colors

A sequence of Color objects to be applied to the image. The sequence must have exactly width * height items.

Attributes

def setRGBA(x: Int, y: Int, color: Color): Unit

Sets the color of a pixel at a specified location in the buffer.

Sets the color of a pixel at a specified location in the buffer.

Value parameters

color

The Color to set the pixel to.

x

The x-coordinate of the pixel.

y

The y-coordinate of the pixel.

Attributes

Concrete methods

def copyPortionXYXY(left: Double, top: Double, right: Double, bottom: Double): BufferAdapter[Buffer]

Copies a portion of the image defined by two corners: top-left and bottom-right.

Copies a portion of the image defined by two corners: top-left and bottom-right.

Value parameters

bottom

Y-coordinate of the bottom-right corner.

left

X-coordinate of the top-left corner.

right

X-coordinate of the bottom-right corner.

top

Y-coordinate of the top-left corner.

Attributes

Returns

A new BufferAdapter instance containing the copied portion of the image.

def mergeWith(another: BufferAdapter[_], pixelMerger: (Color, Color) => Color): BufferAdapter[_]

Merges this Buffer with another Buffer using a specified pixel merging function.

Merges this Buffer with another Buffer using a specified pixel merging function.

Value parameters

another

The other BufferAdapter to merge with.

pixelMerger

A function that takes two colors and returns a merged color.

Attributes

Returns

A new BufferAdapter instance representing the merged image.

def setColorsByLocation(generator: (Int, Int) => Color): Unit
def transformColorToColor(transformer: Color => Color): BufferAdapter[_]

Abstract fields

val height: Int
val width: Int