class CrImage::RGBAImage

Overview

An image with red, green, blue, and alpha color channels (i.e. a color image). This image type is likely the one read from and written to file (or IO).

Included Modules

Extended Modules

Defined in:

cr-image/rgba_image.cr
jpeg.cr
pluto.cr
png.cr
stumpy.cr
webp.cr

Constructors

Instance Method Summary

Instance methods inherited from module CrImage::Format::WebP

to_webp(io : IO, *, lossy : Bool = false, quality : Int32 = 100) : Nil to_webp

Instance methods inherited from module CrImage::Format::JPEG

to_jpeg(io : IO, quality : Int32 = 100) : Nil to_jpeg

Instance methods inherited from module CrImage::Operation::MaskApply

apply(mask : Mask) : self
apply(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self
apply
, apply!(mask : Mask) : self
apply!(mask : Mask, &block : UInt8, ChannelType, Int32, Int32 -> UInt8 | Nil) : self
apply!
, apply_color(mask : Mask, color : Color) : self apply_color, apply_color!(mask : Mask, color : Color) : self apply_color!

Instance methods inherited from module CrImage::Format::Save

save(filename : String) : self save

Instance methods inherited from module CrImage::Operation::VerticalBlur

vertical_blur(value : Int32) : self vertical_blur, vertical_blur!(value : Int32) : self vertical_blur!

Instance methods inherited from module CrImage::Operation::Pad

pad(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self pad, pad!(all : Int32 = 0, *, top : Int32 = 0, bottom : Int32 = 0, left : Int32 = 0, right : Int32 = 0, pad_type : EdgePolicy = EdgePolicy::Black) : self pad!

Instance methods inherited from module CrImage::Operation::Rotate

rotate(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self rotate, rotate!(degrees : Float64, *, center_x : Int32 = width // 2, center_y : Int32 = height // 2, radius : Int32 = -1, pad : Bool = false, pad_type : EdgePolicy = EdgePolicy::Black) : self rotate!

Instance methods inherited from module CrImage::Operation::HorizontalBlur

horizontal_blur(k : Int32) : self horizontal_blur, horizontal_blur!(k : Int32) : self horizontal_blur!

Instance methods inherited from module CrImage::Operation::HistogramEqualize

histogram(channel_type : ChannelType) : Histogram histogram, histogram_equalize : self histogram_equalize, histogram_equalize! : self histogram_equalize!

Instance methods inherited from module CrImage::Operation::GaussianBlur

gaussian_blur(sigma : Int32) : self gaussian_blur, gaussian_blur!(sigma : Int32) : self gaussian_blur!

Instance methods inherited from module CrImage::Operation::Draw

draw_circle(x : Int, y : Int, radius : Int, color : Color, *, fill : Bool = false) : self
draw_circle(region : Region, radius : Int, color : Color, *, fill : Bool = false) : self
draw_circle
, draw_circle!(center_x : Int, center_y : Int, radius : Int, color : Color, *, fill : Bool = false) : self
draw_circle!(region : Region, color : Color, *, fill : Bool = false, radius : Int32 | Nil = nil) : self
draw_circle!
, draw_line(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self draw_line, draw_line!(x1 : Int32, y1 : Int32, x2 : Int32, y2 : Int32, color : Color) : self draw_line!, draw_square(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self
draw_square(region : Region, color : Color, *, fill : Bool = false) : self
draw_square
, draw_square!(x : Int, y : Int, box_width : Int, box_height : Int, color : Color, *, fill : Bool = false) : self
draw_square!(region : Region, color : Color, *, fill : Bool = false) : self
draw_square!

Instance methods inherited from module CrImage::Operation::Crop

[](xrange : Range, yrange : Range) : self [], crop(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self
crop(region : Region) : self
crop
, crop!(x : Int32, y : Int32, new_width : Int32, new_height : Int32) : self
crop!(region : Region) : self
crop!

Instance methods inherited from module CrImage::Operation::Contrast

contrast(value : Float64) : self contrast, contrast!(value : Float64) : self contrast!

Instance methods inherited from module CrImage::Operation::ChannelSwap

channel_swap(a : ChannelType, b : ChannelType) : self channel_swap, channel_swap!(a : ChannelType, b : ChannelType) : self channel_swap!

Instance methods inherited from module CrImage::Operation::Brightness

brightness(value : Float64) : self brightness, brightness!(value : Float64) : self brightness!

Instance methods inherited from module CrImage::Operation::BoxBlur

box_blur(value : Int32) : self box_blur, box_blur!(value : Int32) : self box_blur!

Instance methods inherited from module CrImage::Operation::BilinearResize

bilinear_resize(width : Int32, height : Int32) : self bilinear_resize, bilinear_resize!(width : Int32, height : Int32) : self bilinear_resize!

Instance methods inherited from module CrImage::Format::PNG

to_png(io : IO) : Nil to_png

Instance methods inherited from module CrImage::Format::PPM

to_ppm(io : IO) : Nil to_ppm

Instance methods inherited from class CrImage::Image

[](channel_type : ChannelType) : Array(UInt8) [], []=(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8) []=, alpha : Array(UInt8) alpha, blue : Array(UInt8) blue, each_channel(& : Array(UInt8), ChannelType -> Nil) : Nil each_channel, each_color_channel(& : Array(UInt8), ChannelType -> Nil) : Nil each_color_channel, green : Array(UInt8) green, height : Int32 height, red : Array(UInt8) red, size : Int32 size, width : Int32 width

Macros inherited from class CrImage::Image

subsclasses_include(mod) subsclasses_include

Constructor Detail

def self.from_jpeg(image_data : Bytes) : self #

Read image_data as JPEG encoded bytes


def self.from_jpeg(io : IO) : self #

Construct an Image from reading in bytes from io


def self.from_png(image_data : Bytes) : self #

Read image_data and PNG encoded bytes


def self.from_png(io : IO) : self #

Construct an Image by reading bytes from io


def self.from_ppm(image_data : Bytes) : self #

Read image_data as PPM encoded bytes


def self.from_ppm(io : IO) : self #

Read bytes from io as PPM encoded


def self.from_webp(image_data : Bytes) : self #

Read image_data as WebP encoded bytes


def self.from_webp(io : IO) : self #

Read bytes from io as WebP encoded


def self.new(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32) #

[View source]
def self.new(width : Int32, height : Int32) #

[View source]

Instance Method Detail

def [](x : Int32, y : Int32) : Color #

[View source]
def [](channel_type : ChannelType) : Array(UInt8) #

Return the channel corresponding to channel_type


[View source]
def []=(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8) #

Set the corresponding channel_type with channel


[View source]
def alpha : Array(UInt8) #
Description copied from class CrImage::Image

Return the alpha channel


[View source]
def alpha=(alpha : Array(UInt8)) #

[View source]
def blue : Array(UInt8) #
Description copied from class CrImage::Image

Return the blue channel


[View source]
def blue=(blue : Array(UInt8)) #

[View source]
def clone : RGBAImage #

Create a copy of this image


[View source]
def each_channel(& : Array(UInt8), ChannelType -> Nil) : Nil #

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.


[View source]
def each_color_channel(& : Array(UInt8), ChannelType -> Nil) : Nil #

Run provided block with the ChannelType::Red, ChannelType::Green, and ChannelType::Blue channels.


[View source]
def green : Array(UInt8) #
Description copied from class CrImage::Image

Return the green channel


[View source]
def green=(green : Array(UInt8)) #

[View source]
def height : Int32 #
Description copied from class CrImage::Image

Height of image


[View source]
def height=(height : Int32) #

[View source]
def mask_from(&block : Color, Int32, Int32 -> Bool) : Mask #

[View source]
def red : Array(UInt8) #
Description copied from class CrImage::Image

Return the red channel


[View source]
def red=(red : Array(UInt8)) #

[View source]
def size : Int32 #

Return the number of pixels in this image


[View source]
def to_gray(red_multiplier : Float = 0.299, green_multiplier : Float = 0.587, blue_multiplier : Float = 0.114) : GrayscaleImage #

Convert color image to GrayscaleImage, using the NTSC formula as default values.

Woman with black turtleneck and white background

Becomes

Woman in black turtleneck on white background in grayscale

[View source]
def to_pluto : Pluto::ImageRGBA #

[View source]
def to_rgba : RGBAImage #

Returns self


[View source]
def to_stumpy : StumpyCore::Canvas #

[View source]
def width : Int32 #
Description copied from class CrImage::Image

Width of image


[View source]
def width=(width : Int32) #

[View source]