sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

SGRImage

see header file

see source file

class SGRImage;

part of SGEXTN module SG_Widgets

represents an image

detailed description

list of all including inherited members

implementation details

preprocessor file inclusion directive: #include ‹SGRImage.h›

CMake target for BuildLah: SGEXTN::SG_Widgets

see this link for more information about BuildLah

parent class: (none)

children classes: (none)

instance member functions

SGRImage(int w, int h, SGXColourRGBA c);

SGRImage(const SGXString& filePath);

SGRImage(int w, int h);

[[nodiscard]] SGXColourRGBA colourAt(int x, int y) const;

[[nodiscard]] int height() const;

[[nodiscard]] SGXColourRGBA interpolatedColourAt(float x, float y) const;

void saveToFile(const SGXString& filePath) const;

void setColourAt(int x, int y, SGXColourRGBA c) const;

[[nodiscard]] int width() const;

Detailed Description

SGRImage stores and allows modification to any image. The image uses 8bit RGBA, consistent with SGXColourRGBA.

Implementation Details

wraps QImage

SGRImage(int w, int h, SGXColourRGBA c);

Creates a SGRImage with width w pixels, height h pixels, and with every pixel initialised to c.

Negative w or h will crash.

SGRImage(const SGXString& filePath);

Creates a SGRImage using the image found at filePath.

Nonexistent filePath is undefined behaviour.

The matching file must exist in the resource system. To ensure that, put the image in the assets folder. For more information about the resource system, see this tutorial.

SGRImage(int w, int h);

Creates a SGRImage with width w pixels, height h pixels, containing uninitialised nonsense.

Accessing the colours of this SGRImage before setting them is undefined behaviour.

Negative w or h will crash.

[[nodiscard]] SGXColourRGBA colourAt(int x, int y) const;

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

x below zero, x more than or equal to the width, y below zero, y more than or equal to the height will crash. If you want image sampling, use SGRImage::interpolatedColourAt instead.

[[nodiscard]] int height() const;

Returns the height of this SGRImage.

[[nodiscard]] SGXColourRGBA interpolatedColourAt(float x, float y) const;

Returns the SGXColourRGBA of the pixel at (x, y). If either coordinate is not integer, linear sampling is used. If either coordinate is out of bounds, wrap around is used.

This matches the sampling mode used by SG - RI ⁽㈳㈴㈳㈮㈱㈨㈠㈫ ㈧㈤㈱㈤⁾.

void saveToFile(const SGXString& filePath) const;

Saves this SGRImage to file at filePath in PNG format.

If filePath is not a valid file path, this is undefined behaviour.

void setColourAt(int x, int y, SGXColourRGBA c) const;

Sets the SGXColourRGBA of the pixel at (x, y) to c.

x below zero, x more than or equal to the width, y below zero, y more than or equal to the height will crash

[[nodiscard]] int width() const;

Returns the width of this SGRImage.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects