Class: ModraUp::ImageRep
- Inherits:
-
Object
- Object
- ModraUp::ImageRep
Overview
Pixel buffer. From file #load_file or #new(path), or #set_data with RGB(A) bytes. PNG/JPEG encoding/decoding uses the host (Qt + QImage +). Without a host, #new(path) throws an error.
Class Method Summary # collapse
-
.new ⇒ ModraUp::ImageRep
Initialize with an empty buffer or decode a PNG/JPEG from a path.
Instance Method Summary # collapse
-
#load_file(filepath) ⇒ true
Fill pixels from PNG/JPEG.
-
#save_file(filepath) ⇒ true
Write as PNG or JPEG. The extension determines the format; JPEG accepts quality (0–100) or a hash :quality.
-
#width ⇒ Integer
Pixel width. An empty buffer is 0.
-
#height ⇒ Integer
Pixel height. Empty buffer is 0.
-
#bits_per_pixel ⇒ Integer
Bits per pixel: 8 / 24 / 32. Empty buffer: 0.
-
#row_padding ⇒ Integer
Number of bytes to fill at the end of each row.
-
#size ⇒ Integer
The number of bytes in #data.
-
#data ⇒ String, nil
Pixel bytes (ASCII-8BIT). An empty buffer is nil. Byte order is RGB(A).
-
#set_data(width, height, bits_per_pixel, row_padding, pixel_data) ⇒ ModraUp::ImageRep
Replace the buffer with original pixels. bits_per_pixel is 8 / 24 / 32.
-
#color_at_uv(u, v) ⇒ ModraUp::Color, nil
Samples the color at UV coordinates.(0,0) is the bottom-left, and (1,1) is the top-right. A nil buffer returns nil.
-
#colors ⇒ Array<ModraUp::Color>, nil
Each pixel a ModraUp::Color, row-major order (top to bottom). An empty buffer is nil.
Class Method Details
ImageRep.new ⇒ image_repImageRep.new(filepath) ⇒ image_rep
Initialize with an empty buffer or decode a PNG/JPEG from a path.
Instance Method Details
image_rep.load_file(filepath) ⇒ true
Fill pixels from PNG/JPEG.
image_rep.save_file(filepath) ⇒ trueimage_rep.save_file(filepath, quality) ⇒ trueimage_rep.save_file(filepath, extra) ⇒ true
Write as PNG or JPEG. The extension determines the format; JPEG accepts quality (0–100) or a hash :quality.
image_rep.width ⇒ Integer
Pixel width. An empty buffer is 0.
image_rep.height ⇒ Integer
Pixel height. Empty buffer is 0.
image_rep.bits_per_pixel ⇒ Integer
Bits per pixel: 8 / 24 / 32. Empty buffer: 0.
image_rep.row_padding ⇒ Integer
Number of bytes to fill at the end of each row.
image_rep.size ⇒ Integer
The number of bytes in #data.
image_rep.data ⇒ String, nil
Pixel bytes (ASCII-8BIT). An empty buffer is nil. Byte order is RGB(A).
image_rep.set_data(width, height, bits_per_pixel, row_padding, pixel_data) ⇒ image_rep
Replace the buffer with original pixels. bits_per_pixel is 8 / 24 / 32.
image_rep.color_at_uv(u, v) ⇒ ModraUp::Color, nilimage_rep.color_at_uv(u, v, bilinear) ⇒ ModraUp::Color, nil
Samples the color at UV coordinates.(0,0) is the bottom-left, and (1,1) is the top-right. A nil buffer returns nil.
image_rep.colors ⇒ Array<ModraUp::Color>, nil
Each pixel a ModraUp::Color, row-major order (top to bottom). An empty buffer is nil.