Skip to content

Commit 66b9630

Browse files
committed
Improve QImage support
1 parent 15c584d commit 66b9630

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

crates/cxx-qt-lib/src/gui/qimage.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,56 @@ mod ffi {
1111
unsafe extern "C++" {
1212
include!("cxx-qt-lib/qimage.h");
1313
type QImage = super::QImage;
14+
include!("cxx-qt-lib/qsize.h");
15+
type QSize = crate::QSize;
16+
include!("cxx-qt-lib/qrect.h");
17+
type QRect = crate::QRect;
18+
include!("cxx-qt-lib/qcolor.h");
19+
type QColor = crate::QColor;
20+
1421

1522
/// Whether the QImage is null.
1623
///
1724
/// This means that the QImage has all parameters set to zero and no allocated data.
1825
#[rust_name = "is_null"]
1926
fn isNull(self: &QImage) -> bool;
27+
28+
/// Returns true if all the colors in the image are shades of gray
29+
#[rust_name = "all_gray"]
30+
fn allGray(self: &QImage) -> bool;
31+
32+
/// For 32-bit images, this function is equivalent to allGray().
33+
/// For color indexed images, this function returns true if color(i) is QRgb(i, i, i)
34+
/// for all indexes of the color table; otherwise returns false.
35+
#[rust_name = "is_gray_scale"]
36+
fn isGrayscale(self: &QImage) -> bool;
37+
38+
/// Returns true if the image has a format that respects the alpha channel, otherwise returns false.
39+
#[rust_name = "has_alpha_channel"]
40+
fn hasAlphaChannel(self: &QImage) -> bool;
41+
42+
/// Returns the size of the color table for the image.
43+
#[rust_name = "color_count"]
44+
fn colorCount(self: &QImage) -> i32;
45+
46+
/// Returns the depth of the image.
47+
fn depth(self: &QImage) -> i32;
48+
49+
/// Returns the height of the image.
50+
fn height(self: &QImage) -> i32;
51+
52+
/// Returns the width of the image.
53+
fn width(self: &QImage) -> i32;
54+
55+
/// Returns the size of the image.
56+
fn size(self: &QImage) -> QSize;
57+
58+
/// Returns the enclosing rectangle (0, 0, width(), height()) of the image.
59+
fn rect(self: &QImage) -> QRect;
60+
61+
/// Returns the color of the pixel at coordinates (x, y) as a QColor.
62+
#[rust_name = "pixel_color"]
63+
fn pixelColor(self: &QImage, x: i32, y: i32) -> QColor;
2064
}
2165

2266
#[namespace = "rust::cxxqtlib1"]

0 commit comments

Comments
 (0)