class

CrImage::NYCbCrA

Inherits CrImage::Image / Reference / Object

NYCbCrA is an in-memory image using Y'CbCr color space with alpha channel.

Similar to YCbCr but includes an alpha channel for transparency. The alpha values are non-premultiplied, meaning color values are independent of the alpha value.

Example:

img = CrImage::NYCbCrA.new(
  CrImage.rect(0, 0, 640, 480),
  CrImage::YCbCrSubSampleRatio::YCbCrSubsampleRatio420
)

Constructors

new(rect : Rectangle, sub_sample_ratio : YCbCrSubSampleRatio)
Source
new(y : Slice(UInt8) = Bytes.empty, cb : Slice(UInt8) = Bytes.empty, cr : Slice(UInt8) = Bytes.empty, a : Slice(UInt8) = Bytes.empty, y_stride : Int32 = 0, c_stride : Int32 = 0, a_stride : Int32 = 0, sub_sample_ratio : CrImage::YCbCrSubSampleRatio = YCbCrSubSampleRatio::YCbCrSubsampleRatio444, rect : CrImage::Rectangle = Rectangle.zero)
Source

Instance methods

a=(a : Bytes)
Source
a_offset(x, y)

returns the index of the first element of a that corresponds to the pixel at (x,y)

Source
a_stride
Source
a_stride=(a_stride : Int32)
Source
at(x : Int32, y : Int32) : Color::Color

Returns the color of the pixel at (x,y).

If coordinates are outside bounds, returns a default color (typically transparent black) rather than raising an exception. This simplifies image processing algorithms.

  • at(bounds().min.x, bounds().min.y) returns the upper-left pixel of the grid.
  • at(bounds().max.x-1, bounds().max.y-1) returns the lower-right one.

For explicit nil on out-of-bounds, concrete types provide at? method.

Source
bounds

bounds returns the domain for which at can return non-zero color. The bounds do not necessarily contain the point(0,0).

Source
c_offset(x, y)

returns the index of the first element of cb or cr that corresponds to the pixel at (x,y)

Source
c_stride
Source
c_stride=(c_stride : Int32)
Source
cb=(cb : Bytes)
Source
color_model

color_model returns the Image's color model

Source
cr=(cr : Bytes)
Source
nycbcra_at(x : Int32, y : Int32) : Color::Color
Source
opaque?
Source
rect
Source
rect=(rect : Rectangle)
Source
set(x : Int32, y : Int32, c : Color::Color)

Sets the color of the pixel at (x,y).

If the provided coordinates are not within bounds, this method does nothing (no-op). This simplifies drawing operations that may extend beyond image boundaries.

Source
set_nycbcra(x : Int32, y : Int32, c : Color::NYCbCrA)
Source
sub_image(r : Rectangle) : Image

sub_image returns an image representing the portion of the image visible though r. the returned value shares pixes with the original image.

Source
sub_sample_ratio
Source
sub_sample_ratio=(sub_sample_ratio : YCbCrSubSampleRatio)
Source
y=(y : Bytes)
Source
y_offset(x, y)

returns the index of the first element of Y that corresponds to the pixel at (x,y)

Source
y_stride
Source
y_stride=(y_stride : Int32)
Source