当前位置: 首页>>代码示例>>C++>>正文


C++ Graphics::SetClip方法代码示例

本文整理汇总了C++中gdiplus::Graphics::SetClip方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::SetClip方法的具体用法?C++ Graphics::SetClip怎么用?C++ Graphics::SetClip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gdiplus::Graphics的用法示例。


在下文中一共展示了Graphics::SetClip方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw_text

		void draw_text(const Rect* r, const char* str)
		{
			Gdiplus::SolidBrush* brush = new Gdiplus::SolidBrush(*color);
			if(brush == NULL) return;

			st count = cl::StringUtil::char_to_wchar_count(str);
			wchar* wstr = cl_alloc_type_with_count(wchar, count);
			if(wstr == NULL) { delete brush;  return; }
			cl::StringUtil::char_to_wchar(wstr, count, str);

			Gdiplus::Region old_val;
			graphics->GetClip(&old_val);

			Gdiplus::Region new_val(TO_RECT(r));
			graphics->SetClip(&new_val);

			graphics->DrawString(wstr, -1, font, TO_POINTF(((Point*)r)), brush);
			graphics->SetClip(&old_val);
			cl_free(wstr);
			delete brush;
		}
开发者ID:ChinaCCF,项目名称:Fortunes,代码行数:21,代码来源:Render.cpp

示例2: OnDraw

void Sprite::OnDraw( Gdiplus::Graphics &g, const Gdiplus::RectF &rcDirty )
{
	if (!m_bVisible)
	{
		return; // 子节点也不会被绘制
	}
	// 前序遍历 让父节点先绘制
	//Gdiplus::RectF rc = GetRect();
	//if (10 == rc.Width && 10 == rc.Height)
	//{
	//	LOGW(<<L"Orignal Size 10 10"); // 检查下有没有多余的重绘
	//}
	if (m_bClipChildren)
	{
		Gdiplus::RectF rcClip = GetRect();
		rcClip.X = 0.0f;
		rcClip.Y = 0.0f;
		g.SetClip(rcClip);
	}
    PaintEvent ev;
    ev.graphics = &g;
    ev.rcDirty = rcDirty;
    SendNotify(ePaint, &ev);
    //this->ClientDraw(g, rcDirty);
	Sprite *sp = m_firstChild;
	while(sp)
	{
		// 如果需要重绘部分矩形和sp相交则重画它 否则不重画
		// 这里还有个问题就是 父矩形必须比子矩形要大 否则可能父的相交不到 而子的相交的到
		// 可能要强制这一原理 类似于浏览器 会撑大
		Gdiplus::RectF rc2 = sp->GetRect();
		Gdiplus::RectF rcAbs = sp->GetAbsRect();
		rcAbs.X -= 0.5f; // FIXME 有时无法得到重画导致边界1像素消失
		rcAbs.Y -= 0.5f;
		rcAbs.Width += 1.0f;
		rcAbs.Height += 1.0f;
		if (rcDirty.IntersectsWith(rcAbs))
		{
			g.TranslateTransform(rc2.X, rc2.Y);
			sp->OnDraw(g, rcDirty);
			g.TranslateTransform(-rc2.X, -rc2.Y);
		}
		sp = sp->m_nextSibling;
	}
	if (m_bClipChildren)
	{
		g.ResetClip();
	}
}
开发者ID:magic8421,项目名称:LuaUI2,代码行数:49,代码来源:Sprite.cpp

示例3: clipPath

void GraphicsContext::clipPath(const Path& path, WindRule clipRule)
{
    if (paintingDisabled())
        return;

    // FIXME: Why does this method ignore empty paths?
    if (path.isEmpty())
        return; 

    wxGraphicsContext* gc = m_data->context->GetGraphicsContext();

#if wxUSE_CAIRO
    cairo_t* cr = (cairo_t*)gc->GetNativeContext();
    cairo_path_t* nativePath = (cairo_path_t*)path.platformPath()->GetNativePath();

    cairo_new_path(cr);
    cairo_append_path(cr, nativePath);

    cairo_set_fill_rule(cr, clipRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
    cairo_clip(cr);
#elif __WXMAC__
    CGContextRef context = (CGContextRef)gc->GetNativeContext();   
    CGPathRef nativePath = (CGPathRef)path.platformPath()->GetNativePath(); 
    
    CGContextBeginPath(context);
    CGContextAddPath(context, nativePath);
    if (clipRule == RULE_EVENODD)
        CGContextEOClip(context);
    else
        CGContextClip(context);
#elif __WXMSW__
    Gdiplus::Graphics* g = (Gdiplus::Graphics*)gc->GetNativeContext();
    Gdiplus::GraphicsPath* nativePath = (Gdiplus::GraphicsPath*)path.platformPath()->GetNativePath();
    if (clipRule == RULE_EVENODD)
        nativePath->SetFillMode(Gdiplus::FillModeAlternate);
    else
        nativePath->SetFillMode(Gdiplus::FillModeWinding);
    g->SetClip(nativePath);
#endif
}
开发者ID:dog-god,项目名称:iptv,代码行数:40,代码来源:GraphicsContextWx.cpp

示例4: ClipRectInt

 bool CanvasGdiplus::ClipRectInt(int x, int y, int w, int h)
 {
     Gdiplus::Graphics* current = GetCurrentGraphics();
     return current->SetClip(Gdiplus::Rect(x, y, w, h),
         Gdiplus::CombineModeIntersect) == Gdiplus::Ok;
 }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:6,代码来源:canvas_gdiplus.cpp

示例5: SetClip

void Graphics::SetClip(const RectF& rc) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    g->SetClip(ToGDIRect<RectF, Gdiplus::RectF>(rc));
}
开发者ID:pixelspark,项目名称:corespark,代码行数:4,代码来源:tjgraphics-gdiplus.cpp


注:本文中的gdiplus::Graphics::SetClip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。