JVMBufferAdapter

smile.infrastructure.JVMBufferAdapter
See theJVMBufferAdapter companion object
class JVMBufferAdapter(buffer: BufferedImage) extends BufferAdapter[BufferedImage]

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

Value parameters

buffer

The underlying BufferedImage instance.

Attributes

Companion
object
Graph
Supertypes
class BufferAdapter[BufferedImage]
class Object
trait Matchable
class Any

Members list

Value members

Constructors

def this(width: Int, height: Int)

Creates a JVMBufferAdapter instance with specified width and height, initializing a new BufferedImage.

Creates a JVMBufferAdapter instance with specified width and height, initializing a new BufferedImage.

Value parameters

height

The height of the image.

width

The width of the image.

Attributes

Concrete methods

def copyPortionXYWH(topLeftX: Double, topLeftY: Double, width: Double, height: Double): JVMBufferAdapter

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.

Creates a new JVMBufferAdapter 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 JVMBufferAdapter 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 JVMBufferAdapter instance containing the transformed image.

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: BufferedImage

Provides access to the underlying BufferedImage.

Provides access to the underlying BufferedImage.

Attributes

Returns

The underlying BufferedImage.

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 saveToPath(path: String): Boolean

Saves a BufferedImage to a specified path. The image is saved in PNG format.

Saves a BufferedImage to a specified path. The image is saved in PNG format.

Value parameters

path

The filesystem path where the image should be saved.

Attributes

Returns

true if the image was saved successfully, false otherwise.

def scaleTo(targetWidth: Double, targetHeight: Double): JVMBufferAdapter

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

def toSwingIcon: Icon

Converts the buffer into a Swing Icon.

Converts the buffer into a Swing Icon.

Attributes

Returns

An Icon representing the buffer.

Inherited methods

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

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.

Inherited from:
BufferAdapter
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.

Inherited from:
BufferAdapter
def setColorsByLocation(generator: (Int, Int) => Color): Unit

Attributes

Inherited from:
BufferAdapter
def transformColorToColor(transformer: Color => Color): BufferAdapter[_]

Attributes

Inherited from:
BufferAdapter

Concrete fields

val height: Int
val width: Int