Mapper  0.9.0
API documentation
Public Member Functions | Protected Attributes | List of all members
OpenOrienteering::ImageTransparencyFixup Class Reference

ImageTransparencyFixup repairs a particular issue with composing transparent pixels. More...

#include <image_transparency_fixup.h>

Public Member Functions

 ImageTransparencyFixup (QImage *image)
 Create a fixup functor for the given image. More...
 
void operator() () const
 Checks all pixels of the image for the known wrong result of composing fully transparent pixels, and replaces them with a fully transparent pixel. More...
 

Protected Attributes

QRgb * dest
 
QRgb * dest_end
 

Detailed Description

ImageTransparencyFixup repairs a particular issue with composing transparent pixels.

QPainter::CompositionMode_Multiply and QPainter::CompositionMode_Darken on a QImage of Format_ARGB32_Premultiplied calculate the resulting alpha channel in a very efficient but not accurate way. A particular case is the composition of two fully transparent pixels which should in theory give a fully transparent pixel. Qt yields an alpha value of 1 (in 0..255) instead. The error accumulates with further compositions.

This class may be used as a functor on a particular image, providing a comfortable way to fix the described case after each composition.

Synopsis:

QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); ImageTransparencyFixup fixup(&image); QPainter p(&image); p.setCompositionMode(QPainter::CompositionMode_Multiply); p.drawImage(another_image); p.end(); fixup();

Constructor & Destructor Documentation

◆ ImageTransparencyFixup()

OpenOrienteering::ImageTransparencyFixup::ImageTransparencyFixup ( QImage image)
inline

Create a fixup functor for the given image.

The image must be of QImage::Format_ARGB32_Premultiplied. It may be null.

Member Function Documentation

◆ operator()()

void OpenOrienteering::ImageTransparencyFixup::operator() ( ) const
inline

Checks all pixels of the image for the known wrong result of composing fully transparent pixels, and replaces them with a fully transparent pixel.

Member Data Documentation

◆ dest

QRgb* OpenOrienteering::ImageTransparencyFixup::dest
protected

◆ dest_end

QRgb* OpenOrienteering::ImageTransparencyFixup::dest_end
protected

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