亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? test_aggview.cpp

?? agg圖形庫在WINCE下的一個(gè)DEMO
?? CPP
字號(hào):
// test_aggView.cpp : implementation of the CTest_aggView class
//

#include "stdafx.h"
#include "test_agg.h"

#include "test_aggDoc.h"
#include "test_aggView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include "agg_trans_affine.h"
#include "agg_path_storage.h"
#include "agg_conv_transform.h"
#include "agg_color_rgba8.h"
#include "agg_bounding_rect.h"
#include "ctrl/agg_slider_ctrl.h"


//============================================================================
// Demonstration of the principle of creating custom rasterizer.
// Strictly speaking it's not a rasterizer because it can use any HDC, 
// including non-raster ones (windows metafile or something)
// This class doesn't use anything but WinGDI function PolyPolygon.
// 
// This is only a demonstration and a proof of concept!
//
// Do NOT expect great quality from it because it depends on the 
// abilities of the PolyPolygon only. So, forget about any anti-aliasing
// and subpixel accuracy.
//
// The proof of concept is that you can use any part of the library. This
// example doesn't use the nice AGG rasterization algorithm, in fact, 
// it doesn't use anything but the coordinate conversion pipeline.
// The example demonstrates how the library can be adapted to the use
// a write-only graphic device with very poor drawing abilities.
//
// The example also demonstrates the use of the AGG controls. The control 
// in this example changes the saturation of the image and it's also being 
// rendered with this very class. 
//
// At the end of this file you can find the code that makes the control "alive"
// i.e. just processing the mouse events.
// 
//----------------------------------------------------------------------------
class hdc_rasterizer
{
    // Since it's only a demonstratoion, the capacity of the point container
    // is restricted. There're no reallocs, but if you exceed this number
    // it won't crash. The maximal number of polygons doesn't mean that
    // you can draw no more than this number of polygons in total.
    // This value restricts only the number of polygons in a single
    // PolyPolygon.
    enum
    {
        max_points   = 4094,
        max_polygons = 256
    };

public:
    ~hdc_rasterizer()
    {
        ::SelectObject(m_dc, m_old_pen);
        ::DeleteObject(m_null_pen);
        ::SelectObject(m_dc, m_old_brush);
        if(m_brush)
        {
            ::DeleteObject(m_brush);
        }
        delete [] m_counts;
        delete [] m_points;
    }


    hdc_rasterizer(HDC dc, agg::rgba8 c) :
        m_dc(dc),
        m_sat(255),
        m_brush(0),
        m_old_brush(0),
        m_null_pen(0),
        m_old_pen(0),
        m_points(new POINT[max_points]),
        m_counts(new int[max_polygons]),
        m_num_poly(0),
        m_num_points(0),
        m_reset_flag(false)
    {
        HBRUSH brush = ::CreateSolidBrush(0);
        m_old_brush = (HBRUSH)::SelectObject(m_dc, brush);
        ::SelectObject(m_dc, m_old_brush);
        ::DeleteObject(brush);
        m_null_pen = ::CreatePen(PS_NULL, 1, 0);
        m_old_pen = (HPEN)::SelectObject(m_dc, m_null_pen);
//        ::SetPolyFillMode(m_dc, WINDING);
    }

    //------------------------------------------------------------------------
    void color(agg::rgba8 c);
    void saturation(unsigned sat) { m_sat = sat; }

    //------------------------------------------------------------------------
    void reset();
    void move_to(int x, int y);
    void line_to(int x, int y); 
    void render();

    //------------------------------------------------------------------------
    template<class VertexSource>
    void add_path(VertexSource& vs, unsigned id=0)
    {
        double x;
        double y;

        unsigned flag;
        vs.rewind(id);
        while(!agg::is_stop(flag = vs.vertex(&x, &y)))
        {
            if(agg::is_vertex(flag))
            {
                if(agg::is_move_to(flag)) 
                {
                    move_to(int(x), int(y));
                }
                else 
                {
                    line_to(int(x), int(y));
                }
            }
        }
    }

    //------------------------------------------------------------------------
    template<class VertexSource, class ColorStorage, class PathId>
    void render_all_paths(VertexSource& vs, 
                          const ColorStorage& colors, 
                          const PathId& id,
                          unsigned num_paths)
    {
        for(unsigned i = 0; i < num_paths; i++)
        {
            reset();
            add_path(vs, id[i]);
            color(colors[i]);
            render();
        }
    }

    //------------------------------------------------------------------------
    template<class Ctrl> void render_ctrl(Ctrl& c)
    {
        unsigned i;
        for(i = 0; i < c.num_paths(); i++)
        {
            reset();
            add_path(c, i);
            color(c.color(i));
            render();
        }
    }

private:
    HDC       m_dc;
    unsigned  m_sat;
    HBRUSH    m_brush;
    HBRUSH    m_old_brush;
    HPEN      m_null_pen;
    HPEN      m_old_pen;
    POINT*    m_points;
    int*      m_counts;
    int       m_num_poly;
    int       m_num_points;
    bool      m_reset_flag;
};




//----------------------------------------------------------------------------
// The real drawing color is calculated considering the additional
// parameter "saturation". The saturation is also not a part of AGG, it's
// used just to demonstrate that the renderer can have anything you want
// and to make the slider control have some effect :-)
void hdc_rasterizer::color(agg::rgba8 c)
{
    int gray8 = c.r * 77 + c.g * 150 + c.b * 29;
    int gray = gray8 >> 8;
    int r = (((int(c.r) - gray) * m_sat) + gray8) >> 8;
    int g = (((int(c.g) - gray) * m_sat) + gray8) >> 8;
    int b = (((int(c.b) - gray) * m_sat) + gray8) >> 8;

    HBRUSH brush = ::CreateSolidBrush(RGB(r, g, b));
    ::SelectObject(m_dc, brush);
    if(m_brush)
    {
        ::DeleteObject(m_brush);
    }
    m_brush = brush;
}


//------------------------------------------------------------------------
void hdc_rasterizer::reset()
{
    m_num_poly = 0;
    m_num_points = 0;
    m_reset_flag = false;
}

//------------------------------------------------------------------------
void hdc_rasterizer::move_to(int x, int y) 
{ 
    if(m_reset_flag) reset();
    if(m_num_points < max_points && m_num_poly < max_polygons)
    {
        m_points[m_num_points].x = x;
        m_points[m_num_points].y = y;
        m_counts[m_num_poly] = 1;
        m_num_points++;
        m_num_poly++;
    }
}

//------------------------------------------------------------------------
void hdc_rasterizer::line_to(int x, int y) 
{ 
    if(m_num_points < max_points && m_num_poly)
    {
        m_points[m_num_points].x = x;
        m_points[m_num_points].y = y;
        m_counts[m_num_poly-1]++;
        m_num_points++;
    }
}

//------------------------------------------------------------------------
void hdc_rasterizer::render()
{
    if(m_num_poly)
    {
//TCHAR msg[260];
//_stprintf( msg, _T("poly = %d\n"), m_num_poly );
//OutputDebugString( msg );

//		::PolyPolygon(m_dc, m_points, m_counts, m_num_poly);
		//	由于m_num_poly個(gè)多邊形均使用同一顏色繪制,而且是空畫筆,多邊形
		//	沒有邊界線,所以可用Polygon模擬PolyPolygon。
		POINT* points = m_points;
		for(int i = 0; i < m_num_poly; i++)
		{
			Polygon(m_dc, points, m_counts[i]);
			points += m_counts[i];
		}
    }
    m_reset_flag = true;
}




agg::slider_ctrl<agg::rgba8> g_sat_slider(5, 5, 150, 12, true);
agg::path_storage g_path;
agg::rgba8        g_colors[100];
unsigned          g_path_idx[100];
unsigned          g_npaths = 0;
double            g_x1 = 0;
double            g_y1 = 0;
double            g_x2 = 0;
double            g_y2 = 0;
double            g_base_dx = 0;
double            g_base_dy = 0;
double            g_angle = 0;
double            g_scale = 1.0;




unsigned parse_lion(agg::path_storage& ps, agg::rgba8* colors, unsigned* path_idx);
void parse_lion()
{
    g_npaths = parse_lion(g_path, g_colors, g_path_idx);
    agg::bounding_rect(g_path, g_path_idx, 0, g_npaths, &g_x1, &g_y1, &g_x2, &g_y2);
    g_base_dx = (g_x2 - g_x1) / 2.0;
    g_base_dy = (g_y2 - g_y1) / 2.0;
}



/////////////////////////////////////////////////////////////////////////////
// CTest_aggView

IMPLEMENT_DYNCREATE(CTest_aggView, CView)

BEGIN_MESSAGE_MAP(CTest_aggView, CView)
	//{{AFX_MSG_MAP(CTest_aggView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTest_aggView construction/destruction

CTest_aggView::CTest_aggView()
{
	// TODO: add construction code here
    parse_lion();
}

CTest_aggView::~CTest_aggView()
{
}

BOOL CTest_aggView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTest_aggView drawing

void CTest_aggView::OnDraw(CDC* pDC)
{
	CTest_aggDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	CDC dcMem;
	dcMem.CreateCompatibleDC( pDC );
	CBitmap bmpBuffer;
	bmpBuffer.CreateCompatibleBitmap( pDC, 500, 500 );
	CBitmap* pOldBitmap = dcMem.SelectObject( &bmpBuffer );
	CBrush brWhite( RGB(0, 255, 255) );
	dcMem.FillRect( CRect(0, 0, 500, 500), &brWhite );

DWORD tick = GetTickCount();

	// TODO: add draw code for native data here
    RECT clrect;
    GetClientRect(&clrect);
    int width = clrect.right - clrect.left;
    int height = clrect.bottom - clrect.top;

    hdc_rasterizer r(dcMem, agg::rgba8());

    agg::trans_affine mtx;
    mtx *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
    mtx *= agg::trans_affine_scaling(g_scale, g_scale);
    mtx *= agg::trans_affine_rotation(g_angle);
    mtx *= agg::trans_affine_translation(width/2, height/2);

    agg::path_storage p2(g_path);
    agg::conv_transform<agg::path_storage> trans(p2, mtx);

    r.saturation(unsigned(g_sat_slider.value() * 255.0));
    r.render_all_paths(trans, g_colors, g_path_idx, g_npaths);

tick = GetTickCount() - tick;
TCHAR msg[260];
_stprintf( msg, _T("tick = %d\n"), tick );
OutputDebugString( msg );

    r.render_ctrl(g_sat_slider);

	pDC->BitBlt( 0, 0, 500, 500, &dcMem, 0, 0, SRCCOPY );
	dcMem.SelectObject( pOldBitmap );
	bmpBuffer.DeleteObject();

}

/////////////////////////////////////////////////////////////////////////////
// CTest_aggView diagnostics

#ifdef _DEBUG
void CTest_aggView::AssertValid() const
{
	CView::AssertValid();
}

void CTest_aggView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CTest_aggDoc* CTest_aggView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTest_aggDoc)));
	return (CTest_aggDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTest_aggView message handlers

/////////////////////////////////////////////////////////////////////////////
// CCustomRasterizerView message handlers

void transform(double width, double height, double x, double y)
{
    x -= width / 2;
    y -= height / 2;
    g_angle = atan2(y, x);
    g_scale = sqrt(y * y + x * x) / 100.0;
}


void CTest_aggView::OnLButtonDown(UINT nFlags, CPoint point) 
{
    if(g_sat_slider.in_rect(point.x, point.y))
    {
        if(g_sat_slider.on_mouse_button_down(point.x, point.y))
        {
            Invalidate();
        }
    }
    else
    {
        RECT clrect;
        GetClientRect(&clrect);
        int width = clrect.right - clrect.left;
        int height = clrect.bottom - clrect.top;
        transform(width, height, point.x, point.y);
        Invalidate();
	    CView::OnLButtonDown(nFlags, point);
    }
	CView::OnLButtonDown(nFlags, point);
}

void CTest_aggView::OnLButtonUp(UINT nFlags, CPoint point) 
{
    if(g_sat_slider.on_mouse_button_up(point.x, point.y))
    {
        Invalidate();
    }
	CView::OnLButtonUp(nFlags, point);
}

void CTest_aggView::OnMouseMove(UINT nFlags, CPoint point) 
{
    if(nFlags & MK_LBUTTON)
    {
        if(g_sat_slider.on_mouse_move(point.x, point.y, true))
        {
            Invalidate();
        }
        else
        {
            if(!g_sat_slider.in_rect(point.x, point.y))
            {
                RECT clrect;
                GetClientRect(&clrect);
                int width = clrect.right - clrect.left;
                int height = clrect.bottom - clrect.top;
                transform(width, height, point.x, point.y);
                Invalidate();
	            CView::OnMouseMove(nFlags, point);
            }
        }
    }
	CView::OnMouseMove(nFlags, point);
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲第四色夜色| 成人免费黄色在线| 国产精品理伦片| 欧美日本精品一区二区三区| 国产馆精品极品| 日韩av网站免费在线| 国产精品国产三级国产| 精品日韩欧美一区二区| 欧美亚洲国产一区二区三区| 国产精品小仙女| 久久精品国内一区二区三区| 亚洲精品视频在线看| 日本一区二区在线不卡| 宅男噜噜噜66一区二区66| av电影一区二区| 国产成人精品亚洲日本在线桃色| 日本成人在线视频网站| 亚洲一区二区三区四区不卡| 亚洲婷婷国产精品电影人久久| 欧美成人女星排名| 日韩视频在线你懂得| 欧美日韩午夜在线视频| 色噜噜夜夜夜综合网| 成人av资源在线观看| 国产成人自拍网| 韩日精品视频一区| 蜜臀av性久久久久蜜臀aⅴ流畅 | 美国毛片一区二区| 亚洲一区二区黄色| 亚洲欧美电影院| 国产精品福利一区| 国产精品萝li| 国产精品不卡一区二区三区| 中文字幕不卡一区| 国产精品天天摸av网| 国产网红主播福利一区二区| 久久久久久久性| 久久精品亚洲国产奇米99| 久久久久久久免费视频了| 久久色.com| 久久久久青草大香线综合精品| 精品免费国产二区三区| www国产精品av| 久久午夜色播影院免费高清| 久久久久国色av免费看影院| 久久久久久免费网| 国产精品丝袜黑色高跟| 国产精品久久久久久久久动漫 | 国产精品欧美一级免费| 国产精品美女久久久久av爽李琼| 欧美国产精品中文字幕| 亚洲视频在线一区二区| 亚洲综合丁香婷婷六月香| 亚洲国产美国国产综合一区二区| 亚洲国产成人porn| 免费在线观看精品| 国产精品资源在线| 91性感美女视频| 欧美日韩色一区| 精品日韩在线一区| 国产精品久久久爽爽爽麻豆色哟哟| 国产精品国产三级国产aⅴ无密码| 亚洲黄色小说网站| 日本一道高清亚洲日美韩| 国产揄拍国内精品对白| av激情亚洲男人天堂| 欧美日韩一区三区| 久久久久亚洲蜜桃| 最新热久久免费视频| 五月天中文字幕一区二区| 老司机免费视频一区二区三区| 国产成人av网站| 欧美自拍丝袜亚洲| 2021久久国产精品不只是精品| 国产精品沙发午睡系列990531| 亚洲国产一二三| 国内精品在线播放| 在线免费不卡电影| 精品1区2区在线观看| 亚洲精品欧美激情| 精品一区二区久久久| 成人黄色国产精品网站大全在线免费观看| 欧洲视频一区二区| 欧美精品一区二| 亚洲国产精品久久不卡毛片| 国产精品夜夜爽| 精品视频免费在线| 欧美精彩视频一区二区三区| 午夜激情久久久| 成人免费毛片片v| 日韩一区二区三区四区| 最新日韩在线视频| 国产在线日韩欧美| 欧美亚洲免费在线一区| 欧美国产97人人爽人人喊| 视频一区中文字幕国产| 不卡av在线网| 欧美成人三级在线| 午夜精品免费在线| 91丨porny丨户外露出| 久久久精品日韩欧美| 午夜精品久久久| 色婷婷av一区二区三区之一色屋| 欧美大度的电影原声| 亚洲在线视频免费观看| 大白屁股一区二区视频| 91精品国产综合久久久蜜臀粉嫩 | 欧美不卡一区二区三区四区| 一区二区成人在线| 成人av影视在线观看| 久久综合色一综合色88| 日韩国产精品久久| 在线观看日韩高清av| 国产精品免费视频观看| 国产精品77777| 日韩视频一区二区在线观看| 亚洲一级在线观看| 91国偷自产一区二区三区成为亚洲经典| 久久五月婷婷丁香社区| 青青草精品视频| 7777精品伊人久久久大香线蕉的 | 欧美三级韩国三级日本三斤| 国产精品毛片大码女人| 国产69精品久久久久777| 久久青草欧美一区二区三区| 美女视频免费一区| 欧美一级爆毛片| 日韩主播视频在线| 在线不卡免费欧美| 无码av免费一区二区三区试看 | 国产精品污网站| 成人一区二区三区| 欧美韩日一区二区三区| 国产精品99久久久久| 国产亚洲一区二区三区四区| 国产伦理精品不卡| 国产婷婷一区二区| 高清免费成人av| 国产精品天美传媒| av在线一区二区三区| 亚洲精品少妇30p| 欧美亚洲丝袜传媒另类| 午夜精品一区二区三区三上悠亚| 欧美日本一道本在线视频| 天堂va蜜桃一区二区三区| 91精品国产综合久久精品性色| 日日摸夜夜添夜夜添国产精品| 欧美精品一卡二卡| 美女一区二区在线观看| 亚洲精品一线二线三线| 成人免费视频免费观看| 亚洲人123区| 欧美高清你懂得| 极品少妇一区二区| 中文字幕av一区二区三区| 91亚洲精品久久久蜜桃网站| 亚洲国产一区二区a毛片| 日韩情涩欧美日韩视频| 国产成人亚洲精品狼色在线 | 中文字幕亚洲精品在线观看 | 国产日韩精品一区| 99精品国产视频| 婷婷国产在线综合| 欧美mv日韩mv国产网站app| 国产精品12区| 亚洲免费色视频| 欧美一区二区三区视频在线| 国产成人在线观看免费网站| 亚洲区小说区图片区qvod| 51精品视频一区二区三区| 国产精品99久久久久久有的能看| 亚洲少妇中出一区| 欧美日韩国产在线播放网站| 国产在线一区观看| 亚洲卡通欧美制服中文| 日韩一区二区不卡| 91色porny蝌蚪| 日韩高清国产一区在线| 国产精品久久久久久久久图文区| 在线亚洲一区二区| 韩国v欧美v日本v亚洲v| 亚洲美女屁股眼交| 欧美成人aa大片| 欧美在线小视频| 国产成人综合自拍| 日韩成人免费看| 中文字幕色av一区二区三区| 91精品国产91久久综合桃花| 成人蜜臀av电影| 青青草国产成人av片免费| 亚洲同性同志一二三专区| 26uuu精品一区二区| 欧美亚洲一区二区在线| 国产99久久精品| 裸体一区二区三区| 一区二区三区免费| 欧美国产一区视频在线观看| 欧美一级免费大片| 在线一区二区三区做爰视频网站| 国产成人丝袜美腿|