Nana C++ Library  

An open-source C++ framework project
The Programmer's Guide 
nana::paint::image_process::selector

Description

The class selector is used for configuring the algorithms of image processing.

Model of

None

Public base classes

None

Members

template<typename ImageProcessor>
void add_alpha_blend(const std::string& name)
Inserts a new user defined image process for alpha blend.
void alpha_blend(const std::string& name) Selects an image process through a specified name.
template<typename ImageProcessor>
void add_blend(const std::string& name)
Inserts a new user-defined image processor for blend.
void blend(const std::string& name) Selects an image processor through a specified name.
template<typename ImageProcessor>
void add_blur(const std::string& name)
Inserts a new user-defined image process for blur.
void blur(const std::string& name) Selects an image procssor through a specified name.
template<typename ImageProcessor>
void add_line(const std::string& name)
Inserts a new user-defined image processor for line.
void line(const std::string& name) Selects an image processor through a specified name.
template<typename ImageProcessor>
void add_stretch(const std::string& name)
Inserts a new user-defined image processor for stretch.
void stretch(const std::string& name) Selects an image processor through a specified name.

File

nana/paint/image_process_selector.hpp

Notes

1, If users give a non-existing name for choosing an image processor, the call succeed, but no image processor would be replaced.

2, The image processors that Nana provides are:

Stretch algorithms:
bilinear interoplation It produces a reasonably realistic image.
proximal interoplation It(also known as nearest-neighbor interoplation) is fast, but produces a not realistic image.

Alpha Blend algorith:
alpha_blend Blends two images with alpha channel that is given by source image.

Blend algorithm:
blend  Blends two images.

Blur algorithm:
blur Blurs an image.


Line algorithm:
bresenham_line Draws a line.

Examples

This is an example which creates a form to display an image, and when the size of form is changed, it makes the image fit the form.
In addtion, the example also shows the way to switch the stretch image processing algorithm.

#include <nana/gui/wvl.hpp>
#include <nana/gui/drawing.hpp>
#include <nana/paint/image_process_selector.hpp>

using namespace nana::gui;

class tsform
    : public form
{
public:
    tsform()
    {

        img_.open(STR("image01.bmp"));    //Open the image file.

        //Copy the image to the window
        nana::size sz = size();
       
        drawing dw(*this);
        dw.bitblt(0, 0, sz.width, sz.height, img_, 0, 0);
        dw.update();

        //Register events
        make_event<events::click>(*this, &tsform::_m_click);
        make_event<events::size>(*this, &tsform::_m_size);
    }
private:
    //Switchs the algorithm between two algorithms in every click on the form.
    void _m_click()
    {
        static bool interop;
        nana::paint::image_process::selector sl;
        sl.stretch(interop ? "bilinear interoplation" : "proximal interoplation");
        interop = !interop;
    }

    //When the window size is changed, it stretches the image to fit the window.
    void _m_size()
    {
        drawing dw(*this);
       
        dw.clear();  //Before stretch, it should clear the operations that are generated before.
        dw.stretch(size(), img_, img_.size());
        dw.update();
    }
private:
    nana::paint::image img_;
};

int main()
{
    tsform fm;
    fm.show();
    exec();
}

Result of application:
bilinear interoplation
Stretch the image through bilinear interoplation

proximal interoplation
Stretch the image through proximal interoplation



See also

None.


Move to The Nana Programmer's Guide Main Page