Click here to Skip to main content
15,880,469 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.1K   51.5K   405  
An article on a library for image manipulation
#pragma once

//-------------------------------------------------------------------------------------
class CWndPaletteSlider : public FCButtonBase
{
    int   m_nMin, m_nMax, m_nPos ;
public:
    // nMin <= range <= nMax
    CWndPaletteSlider (int nMin, int nMax, int nInit)
    {
        m_nMin = nMin ;
        m_nMax = nMax ;
        m_nPos = nInit ;
    }

    int GetPos() const {return m_nPos;}
    int GetMax() const {return m_nMax;}

    static void DDX_Pos (CDataExchange* pDX, CWndPaletteSlider& rSlider, int& nPos) ;

protected:
    virtual void OnDrawSliderImage (CDC* pDC, CRect rc) {}

private:
    void DrawArrow (CDC* pDC, CRect rc)
    {
        int   nCenter = rc.left + (m_nPos-m_nMin) * (rc.Width()-1) / (m_nMax-m_nMin) ;
        Gdiplus::Point   pt[3] ;
        pt[0] = Gdiplus::Point (nCenter-4, rc.bottom) ;
        pt[1] = Gdiplus::Point (nCenter+4, rc.bottom) ;
        pt[2] = Gdiplus::Point (nCenter, rc.bottom-9) ;
        Gdiplus::Graphics   g (*pDC) ;
        g.SetSmoothingMode (Gdiplus::SmoothingModeAntiAlias) ;

        Gdiplus::SolidBrush   b1 (Gdiplus::Color(0,0,0)) ;
        g.FillPolygon (&b1, pt, 3) ;

        pt[0].X-- ;
        pt[1].X++ ;
        pt[2].Y-- ;

        Gdiplus::Pen   p1 (Gdiplus::Color(255,255,255)) ;
        g.DrawPolygon (&p1, pt, 3) ;
    }

    virtual void OnDrawButton (CDC* pDC, CRect rcButton)
    {
        rcButton.DeflateRect(2,2,2,2) ;
        OnDrawSliderImage (pDC, rcButton) ;
        DrawArrow (pDC, rcButton) ;
        rcButton.InflateRect(1,1,1,1) ;
        FrameRect (*pDC, rcButton, CBrush(RGB(255,255,255))) ;
        rcButton.InflateRect(1,1,1,1) ;
        FrameRect (*pDC, rcButton, CBrush(RGB(192,192,192))) ;
    }

    void UpdateMousePos (CPoint pt) ;

    virtual BOOL PreTranslateMessage (MSG* pMsg);

    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    DECLARE_MESSAGE_MAP()
};

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