game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
QtImageService Class Reference

#include <qt_image_service.h>

Inheritance diagram for QtImageService:
Collaboration diagram for QtImageService:

Public Member Functions

 QtImageService ()=default
 ~QtImageService () override=default
void clearCache () override
 Clear all cached images and free resources.
bool getImageDimensions (const std::string &path, int *width, int *height) const override
 Get dimensions of a loaded image.
QPixmap getPixmap (const std::string &path)
QPixmap getScaledPixmap (const std::string &path, int maxWidth, int maxHeight)
bool isImageLoaded (const std::string &path) const override
 Check if an image is already loaded/cached.
bool loadImage (const std::string &path, int *width=nullptr, int *height=nullptr) override
 Load an image from disk.
void unloadImage (const std::string &path) override
 Unload a specific image and free resources.
Public Member Functions inherited from core::IImageService
virtual ~IImageService ()=default

Detailed Description

Definition at line 18 of file qt_image_service.h.

Constructor & Destructor Documentation

◆ QtImageService()

QtImageService::QtImageService ( )
default

◆ ~QtImageService()

QtImageService::~QtImageService ( )
overridedefault

Member Function Documentation

◆ clearCache()

void QtImageService::clearCache ( )
overridevirtual

Clear all cached images and free resources.

Implements core::IImageService.

Definition at line 77 of file qt_image_service.cpp.

◆ getImageDimensions()

bool QtImageService::getImageDimensions ( const std::string & path,
int * width,
int * height ) const
overridevirtual

Get dimensions of a loaded image.

Parameters
pathPath to the image
widthOutput parameter for width
heightOutput parameter for height
Returns
true if image is loaded and dimensions retrieved

Implements core::IImageService.

Definition at line 83 of file qt_image_service.cpp.

◆ getPixmap()

QPixmap QtImageService::getPixmap ( const std::string & path)

Definition at line 104 of file qt_image_service.cpp.

Referenced by getScaledPixmap().

◆ getScaledPixmap()

QPixmap QtImageService::getScaledPixmap ( const std::string & path,
int maxWidth,
int maxHeight )

Definition at line 137 of file qt_image_service.cpp.

References getPixmap().

◆ isImageLoaded()

bool QtImageService::isImageLoaded ( const std::string & path) const
overridevirtual

Check if an image is already loaded/cached.

Parameters
pathPath to check
Returns
true if image is cached

Implements core::IImageService.

Definition at line 65 of file qt_image_service.cpp.

◆ loadImage()

bool QtImageService::loadImage ( const std::string & path,
int * width = nullptr,
int * height = nullptr )
overridevirtual

Load an image from disk.

Parameters
pathPath to the image file
widthOutput parameter for image width (optional)
heightOutput parameter for image height (optional)
Returns
true if loading succeeded, false otherwise

Implementations should cache the loaded image for subsequent calls.

Implements core::IImageService.

Definition at line 13 of file qt_image_service.cpp.

◆ unloadImage()

void QtImageService::unloadImage ( const std::string & path)
overridevirtual

Unload a specific image and free resources.

Parameters
pathPath of the image to unload

Implements core::IImageService.

Definition at line 71 of file qt_image_service.cpp.


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