Click here to Skip to main content
15,885,278 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
#pragma once
#include "dlg_modal_base.h"

//-------------------------------------------------------------------------------------
//
// when click radio or check button, apply effect
//
class DlgEffectBase : public DlgModalBase
{
private:
    // process in thread
    class CProcessTask : public FCProgressObserver
    {
        // process image and notify observer
        static DWORD WINAPI ImageProcessThread (LPVOID lpParameter) ;

        // this callback still in thread
        virtual bool OnProgressUpdate (int nFinishPercentage) ;

    public:
        int      m_id ;
        HANDLE   m_thread ;
        DlgEffectBase   * m_pDlg ;
        volatile LONG   m_continue_process ;
        int   m_nLastUpdate ;
        int   m_nLastPercent ;
        std::auto_ptr<FCImageEffect>   m_cmd ;

    public:
        CProcessTask (DlgEffectBase* pDlg) ;
        ~CProcessTask () ;
    };

private:
    FCObjImage   m_backup_img ;

    CView        * m_view ;
    FCObjImage   * m_layer ;
    FCObjImage   m_curr ;
    BOOL         m_finish_close ;

    std::auto_ptr<CProcessTask>   m_task ;

public:
    DlgEffectBase (LPCWSTR strSection, UINT nDlgID, CMy002Doc* pDoc) ;
    ~DlgEffectBase() ;

    CSize GetProcessImageSize() {return CSize(m_curr.Width(),m_curr.Height());}

private:
    static BOOL CALLBACK disable_child_ctrl (HWND hwnd, LPARAM lParam)
    {
        if (::GetDlgCtrlID(hwnd) != IDCANCEL)
            ::EnableWindow(hwnd, FALSE) ;
        return TRUE ;
    }

    virtual void OnOK() ;
    virtual void OnCancel() ;

protected:
    virtual FCImageEffect* CreateProcessCommand() =0 ;

    void ApplyEffect() ;

protected:
    virtual BOOL OnInitDialog() ;
    virtual LRESULT WindowProc (UINT msg, WPARAM wParam, LPARAM lParam) ;

    afx_msg void OnPostInit();
    afx_msg LRESULT OnProcessStep(WPARAM wParam, LPARAM lParam);
    afx_msg LRESULT OnProcessFinish(WPARAM wParam, LPARAM lParam);
	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