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













SourceForge.net 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.

 

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).

 


 

void SweepMkImageCache()

Despite the name, this function in fact clears size counters on the cache. Size of cache is increased according to cache size counter data collected since the last SweepMkImageCache.

 


 

void ClearMakeImageCache()

Removes all images from the cache.

 


 

void SetMakeImageCacheSize(int m)

Sets the amount of images that can be kept in cache. This amount is automatically increased based on size counters of cache. Default value is zero.

 


 

void SetMakeImageCacheMax(int m)

Sets the absolute maximum of image data stored in cache. Default is one million pixels.

 

 


 

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 Upscale2x(const Image& src)

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

 

 

Last edit by cxl on 01/04/2018. Do you want to contribute?. T++