GDI图形->通过图片() [英] GDI graphics -> fromimage()

查看:86
本文介绍了GDI图形->通过图片()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试创建用于在Picturebox内绘图的应用程序.此代码:

Hi guys i am trying to create application for drawing inside picturebox. This code :

if(bitmap_render!=nullptr)
    delete bitmap_render;
bitmap_render=gcnew Bitmap(bitmap_black);
Control ^c=gcnew Control();
Graphics ^render_graphics2=c->CreateGraphics();


render_graphics2->FromImage(bitmap_render);

render_graphics2->FillRectangle(gcnew SolidBrush( Color::Red ),50,50,500,500);
render_graphics->DrawImage(bitmap_render,0,0);

delete render_graphics2;



具有render_graphics,这是使用picturebox-> creategraphics()方法创建的Grahics ^对象.我相信其他人几乎可以自我解释.我试图直接绘制到位图,然后渲染该位图以避免闪烁.问题是在输出中应该有一个红色矩形,而没有.您有任何建议吗?



have render_graphics which is Grahics ^ object created using picturebox->creategraphics() method . Other is pretty much self explanatory I believe. I am trying to draw directly to bitmap and than render this bitmap to avoid flickering. Problem is that in output there should be a red rectangle present and it isn´t. Do you have any sugestions ?

推荐答案

Okey我不知道这个论坛的内容是什么,但是每次我遇到大量时间都遇到问题时,请在这里写下出于纯粹的沮丧,我自己解决了这个问题.因此,执行此操作的正确方法是创建这样的新图形

图形^ render_graphics2 = Graphics :: FromImage(bitmap_render);
Okey i dont know what is it about this forum but every time i am stuck with a problem for huge amount of time and write here out of pure frustration I solve it myself. So the proper way to do this is to create new graphics like this

Graphics ^render_graphics2=Graphics::FromImage( bitmap_render );


这篇关于GDI图形->通过图片()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆