class CrImage::RGBAImage
- CrImage::RGBAImage
- CrImage::Image
- Reference
- Object
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
- CrImage::Format::JPEG
- CrImage::Format::PNG
- CrImage::Format::PPM
- CrImage::Format::Save
- CrImage::Format::WebP
- CrImage::Operation::BilinearResize
- CrImage::Operation::BoxBlur
- CrImage::Operation::Brightness
- CrImage::Operation::ChannelSwap
- CrImage::Operation::Contrast
- CrImage::Operation::Crop
- CrImage::Operation::Draw
- CrImage::Operation::GaussianBlur
- CrImage::Operation::HistogramEqualize
- CrImage::Operation::HorizontalBlur
- CrImage::Operation::MaskApply
- CrImage::Operation::Pad
- CrImage::Operation::Rotate
- CrImage::Operation::VerticalBlur
Extended Modules
Defined in:
cr-image/rgba_image.crjpeg.cr
pluto.cr
png.cr
stumpy.cr
webp.cr
Constructors
-
.from_jpeg(image_data : Bytes) : self
Read
image_data
as JPEG encoded bytes -
.from_jpeg(io : IO) : self
Construct an Image from reading in bytes from
io
-
.from_png(image_data : Bytes) : self
Read
image_data
and PNG encoded bytes -
.from_png(io : IO) : self
Construct an Image by reading bytes from
io
-
.from_ppm(image_data : Bytes) : self
Read
image_data
as PPM encoded bytes -
.from_ppm(io : IO) : self
Read bytes from
io
as PPM encoded -
.from_webp(image_data : Bytes) : self
Read
image_data
as WebP encoded bytes -
.from_webp(io : IO) : self
Read bytes from
io
as WebP encoded - .new(red : Array(UInt8), green : Array(UInt8), blue : Array(UInt8), alpha : Array(UInt8), width : Int32, height : Int32)
- .new(width : Int32, height : Int32)
Instance Method Summary
- #[](x : Int32, y : Int32) : Color
-
#[](channel_type : ChannelType) : Array(UInt8)
Return the channel corresponding to
channel_type
-
#[]=(channel_type : ChannelType, channel : Array(UInt8)) : Array(UInt8)
Set the corresponding
channel_type
withchannel
-
#alpha : Array(UInt8)
Return the alpha channel
- #alpha=(alpha : Array(UInt8))
-
#blue : Array(UInt8)
Return the blue channel
- #blue=(blue : Array(UInt8))
-
#clone : RGBAImage
Create a copy of this image
-
#each_channel(& : Array(UInt8), ChannelType -> Nil) : Nil
Run provided block with the
ChannelType::Red
,ChannelType::Green
, andChannelType::Blue
channels. -
#each_color_channel(& : Array(UInt8), ChannelType -> Nil) : Nil
Run provided block with the
ChannelType::Red
,ChannelType::Green
, andChannelType::Blue
channels. -
#green : Array(UInt8)
Return the green channel
- #green=(green : Array(UInt8))
-
#height : Int32
Height of image
- #height=(height : Int32)
- #mask_from(&block : Color, Int32, Int32 -> Bool) : Mask
-
#red : Array(UInt8)
Return the red channel
- #red=(red : Array(UInt8))
-
#size : Int32
Return the number of pixels in this image
-
#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. - #to_pluto : Pluto::ImageRGBA
-
#to_rgba : RGBAImage
Returns self
- #to_stumpy : StumpyCore::Canvas
-
#width : Int32
Width of image
- #width=(width : Int32)
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) : selfapply(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) : selfdraw_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) : selfcrop(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
Instance Method Detail
Return the channel corresponding to channel_type
Set the corresponding channel_type
with channel
Run provided block with the ChannelType::Red
, ChannelType::Green
, and ChannelType::Blue
channels.
Run provided block with the ChannelType::Red
, ChannelType::Green
, and ChannelType::Blue
channels.
Convert color image to GrayscaleImage
, using the NTSC formula as default values.
Becomes