Click here to Skip to main content
15,885,546 members
Articles / Desktop Programming / MFC

ImageStone - A Powerful C++ Class Library for Image Manipulation

Rate me:
Please Sign up or sign in to vote.
4.81/5 (250 votes)
6 Dec 2011Zlib3 min read 117.7K   51.5K   405  
An article on a library for image manipulation
//-------------------------------------------------------------------------------------
/// Video (>=24 bit).
class FCEffectVideo : public FCImageEffect
{
public:
    enum VIDEO_TYPE {VIDEO_STAGGERED=0, VIDEO_TRIPED=1, VIDEO_3X3=2, VIDEO_DOTS=3} ;
    /**
        Constructor \n
        nVideoType - FCEffectVideo::VIDEO_STAGGERED / FCEffectVideo::VIDEO_TRIPED / FCEffectVideo::VIDEO_3X3 / FCEffectVideo::VIDEO_DOTS
    */
    FCEffectVideo (VIDEO_TYPE nVideoType) : m_type(nVideoType) {}
private:
    virtual void ProcessPixel (FCObjImage& img, int x, int y, BYTE* pPixel)
    {
        int   pattern_width[] = {2, 1, 3, 5} ;
        int   pattern_height[] = {6, 3, 3, 15} ;
        int   video_pattern[4][15 * 5] =
        {
            {
                0, 1,
                0, 2,
                1, 2,
                1, 0,
                2, 0,
                2, 1,
            },
            {
                0,
                1,
                2,
            },
            {
                0, 1, 2,
                2, 0, 1,
                1, 2, 0,
            },
            {
                0, 1, 2, 0, 0,
                1, 1, 1, 2, 0,
                0, 1, 2, 2, 2,
                0, 0, 1, 2, 0,
                0, 1, 1, 1, 2,
                2, 0, 1, 2, 2,
                0, 0, 0, 1, 2,
                2, 0, 1, 1, 1,
                2, 2, 0, 1, 2,
                2, 0, 0, 0, 1,
                1, 2, 0, 1, 1,
                2, 2, 2, 0, 1,
                1, 2, 0, 0, 0,
                1, 1, 2, 0, 1,
                1, 2, 2, 2, 0,
            }
        };

        int   nWidth = pattern_width[m_type],
              nHeight = pattern_height[m_type] ;
        for (int i=0 ; i < 3 ; i++)
        {
            if (video_pattern[m_type][nWidth * (y%nHeight) + (x%nWidth)] == i)
                pPixel[i] = FClamp0255 (2 * pPixel[i]) ;
        }
    }

    VIDEO_TYPE   m_type ;
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The zlib/libpng License


Written By
Team Leader PhoXo
China China
graduate from University of Science and Technology of China at 2002.

Now I work at www.phoxo.com.

Comments and Discussions