Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
ImageDecoder Class Referencefinal

Decodes image data using Qt's built-in image loading capabilities. More...

#include <image_decoder.h>

Inheritance diagram for ImageDecoder:
Collaboration diagram for ImageDecoder:

Signals

void error (const QString &message)
 Emitted if an error occurs during image loading or decoding.
 
void imageInfo (int width, int height, bool has_alpha)
 Emitted after successful decoding, providing basic image information.
 
void imageReady (const QImage &image)
 Emitted when the image has been successfully decoded.
 

Public Member Functions

QImage Decode ()
 Attempts to decode the image data stored internally. Uses QImage::loadFromData() to perform the decoding. Emits imageReady() and imageInfo() on success, or error() on failure.
 
 ImageDecoder (const QByteArray &image_data, QObject *parent=nullptr)
 Constructs an ImageDecoder object.
 
 ~ImageDecoder () override
 Destructor. Does not require special resource management like FFmpeg-based decoders.
 

Static Public Member Functions

static void ReleaseResources ()
 Static method placeholder for resource release. In this Qt-based implementation, there are no specific resources to release globally.
 

Private Attributes

QByteArray image_data_
 Stores the raw image data provided in the constructor.
 

Detailed Description

Decodes image data using Qt's built-in image loading capabilities.

This class takes raw image data (e.g., PNG, JPEG, etc.) as a QByteArray and uses QImage::loadFromData() to decode it. It operates synchronously within the calling thread and emits signals to report the decoded image, image information, or errors.

Constructor & Destructor Documentation

◆ ImageDecoder()

ImageDecoder::ImageDecoder ( const QByteArray & image_data,
QObject * parent = nullptr )
inlineexplicit

Constructs an ImageDecoder object.

Parameters
image_dataThe raw image data to be decoded.
parentOptional parent QObject.

◆ ~ImageDecoder()

ImageDecoder::~ImageDecoder ( )
inlineoverride

Destructor. Does not require special resource management like FFmpeg-based decoders.

Member Function Documentation

◆ Decode()

QImage ImageDecoder::Decode ( )

Attempts to decode the image data stored internally. Uses QImage::loadFromData() to perform the decoding. Emits imageReady() and imageInfo() on success, or error() on failure.

Returns
The decoded QImage on success, or a null QImage on failure.
Here is the call graph for this function:

◆ error

void ImageDecoder::error ( const QString & message)
signal

Emitted if an error occurs during image loading or decoding.

Parameters
messageA description of the error.
Here is the caller graph for this function:

◆ imageInfo

void ImageDecoder::imageInfo ( int width,
int height,
bool has_alpha )
signal

Emitted after successful decoding, providing basic image information.

Parameters
widthThe width of the decoded image in pixels.
heightThe height of the decoded image in pixels.
has_alphaTrue if the image format supports an alpha channel, false otherwise.
Here is the caller graph for this function:

◆ imageReady

void ImageDecoder::imageReady ( const QImage & image)
signal

Emitted when the image has been successfully decoded.

Parameters
imageThe decoded image as a QImage object. A copy is emitted.
Here is the caller graph for this function:

◆ ReleaseResources()

static void ImageDecoder::ReleaseResources ( )
inlinestatic

Static method placeholder for resource release. In this Qt-based implementation, there are no specific resources to release globally.

Member Data Documentation

◆ image_data_

QByteArray ImageDecoder::image_data_
private

Stores the raw image data provided in the constructor.


The documentation for this class was generated from the following files: