Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

ImageMaker - image cache system

 

Image cache system provides means to create and cache Images. For example, in GUI there might be requirement for monochromatic version of icons to express disabled status. In this case, ImageMaker derived class can be defined to make such Image from color version and by using MakeImage, caching mechanism is introduced. Image cache is using global Value cache as underlying mechanism.

 

ImageMaker

 

struct ImageMaker

This class serves as base class for all image makers. Client class usually adds parameters to class derived from ImageMaker. For example, for caching rescaled images, parameters would be the source Image and the final size.

 


 

virtual String Key() const = 0

Returns the key for provided set of parameter. Note that the type identification of ImageMaker is automatically added by MakeImage.

 


 

virtual Image Make() const = 0

Creates Image based on parameters.

 


 

~ImageMaker()

Virtual destructor.

 

Function List

 

Image MakeImage(const ImageMaker& m)

Returns the Image based on ImageMaker (either retrieves from the cache or creates and stores to cache). Amount of images kept in is controlled by SetImageCacheSize and SetImageCacheMax.

 


 

Image MakeImage(const Image& image, Image (*make)(const Image& image))

Simplified version for Image making process that does not require other parameters than single input image.

 


 

Image MakeImagePaintOnly(const ImageMaker& m)

Similar to MakeImage, but creates and Image that can only be used in Draw::DrawImage (this is optimization hint that can save some memory in certain situations).

 


 

Image CachedRescale(const Image& m, Size sz, const Rect& src, int filter = Null)

Image CachedRescale(const Image& m, Size sz, int filter = Null)

Returns rescaled Image, with results being cached. filter can be one of predefined filters for RescaleFilter function (e.g. FILTER_BILINEAR), if Null, standard speed optimized custom algorithm is used.

 


 

Image CachedRescalePaintOnly(const Image& m, Size sz, const Rect& src, int filter = Null)

Image CachedRescalePaintOnly(const Image& m, Size sz, int filter = Null)

Returns rescaled Image, with results being cached, that can only be used with Draw::DrawImage(this is optimization hint that can save some memory in certain situations). filter can be one of predefined filters for RescaleFilter function (e.g. FILTER_BILINEAR), if Null, standard speed optimized custom algorithm is used.

 


 

Image CachedSetColorKeepAlpha(const Image& img, Color color)

Cached variant of SetColorKeepAlpha. Replaces all pixel colors in Image with color while not changing the alpha value.

 


 

Image CachedSetColorKeepAlphaPaintOnly(const Image& img, Color color)

Cached variant of SetColorKeepAlpha. Replaces all pixel colors in Image with color while not changing the alpha value, with results being cached, that can only be used with Draw::DrawImage(this is optimization hint that can save some memory in certain situations).

 


 

Image Magnify(const Image& img, int nx, int ny)

Multiplies the resolution of img by factors nx and ny by simply repeating the pixels (each pixel becomes nx x ny same color block).

 


 

Image Minify(const Image& img, int nx, int ny, bool co = false)

Reduces the resolution of img by factors nx and ny by averaging pixel value (each nx x ny block of pixels is averaged and produces single pixel in the resulting image). If co is true, parallel processing is enabled.

 


 

Image MinifyCached(const Image& img, int nx, int ny, bool co = false)

Same as Minify, but cached.

 


 

Image Upscale2x(const Image& src)

Doubles the resolution of image, using smart heuristics algorithm designed for upscaling synthetic images (like icons).

 


 

Image Downscale2x(const Image& src)

Halves the resolution of image.

 

Do you want to contribute?