iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nrt::PixelPainter< T, PixDest, U, PixSource, Enable > Class Template Reference

#include <nrt/ImageProc/Drawing/PixelPainter.H>

template<class T, template< typename > class PixDest, class U, template< typename > class PixSource, class Enable = void>
class nrt::PixelPainter< T, PixDest, U, PixSource, Enable >

The PixelPainter class is a small optimization for drawing on Images.

It performs 2 optimizations:

  • It automatically caches the representation of the drawing color in the destination Image's color space.
    // We have some Image...
    Image<PixRGB<byte> > myImage(640, 480, ImageInitPolicy::Zeros);
    // Create a new PixelPainter to help us with drawing an HSV color onto our RGB Image. The PixelPainter will
    // immediately convert the input HSV color to the destination color (RGB). This ensures that later, when we want
    // to draw, we can just copy the converted RGB values onto our destination Image.
    PixelPainter<byte, PixRGB, byte, PixHSV> painter(PixHSV<byte>(240, 255, 134));
    // Paint our color onto the Image
    Image<PixRGB<byte> >::iterator it = myImage.begin();
    for (; it != myImage.end(); ++it) painter.paint(it);
  • It completely avoids alpha blending if the source color does not have an alpha channel.
    // We have some Image...
    Image<PixRGB<byte> > myImage(640, 480, ImageInitPolicy::Zeros);
    // Create a new PixelPainter to help us with drawing a PixRGBA color (e.g. half opaque red) onto our RGB Image. No
    // colorspace conversion is necessary here, however the PixelPainter that is created knows that it can't just copy
    // the input color into the destination Image - it will have to blend the input color with the underlying Image
    // instead.
    PixelPainter<byte, PixRGB, byte, PixRGBA> painter(PixRGBA<byte>(255, 0, 0, 128));
    // Blend the input color onto the Image
    Image<PixRGB<byte> >::iterator it = myImage.begin();
    for (; it != myImage.end(); ++it) painter.paint(it);

Definition at line 90 of file PixelPainter.H.

Public Member Functions

 PixelPainter (PixSource< U > const &color)
 
void paint (PixDest< T > *dest)
 

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