绘制控件

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
ibruce
In need of some credit
In need of some credit
Posts: 6
Joined: Tue May 06, 2014 6:47 am

绘制控件

Post by ibruce » Wed May 07, 2014 5:53 am

我现在想将一个控件(wxWidgets自带的控件)绘制结果保存到图片中,比如:一个wxButton,我想将它在屏上显示的形状保存到一幅图片中,然后去特殊效果处理,不知道该怎么去做,谢谢!

ibruce
In need of some credit
In need of some credit
Posts: 6
Joined: Tue May 06, 2014 6:47 am

Re: 绘制控件

Post by ibruce » Fri May 09, 2014 1:02 am

不知道有没有做过,给点思路也行。

infoworld
In need of some credit
In need of some credit
Posts: 5
Joined: Fri May 09, 2014 2:47 am

Re: 绘制控件

Post by infoworld » Fri May 09, 2014 2:56 am

ibruce wrote:我现在想将一个控件(wxWidgets自带的控件)绘制结果保存到图片中,比如:一个wxButton,我想将它在屏上显示的形状保存到一幅图片中,然后去特殊效果处理,不知道该怎么去做,谢谢!
奇怪,国外回复还要审核的?

用wxClientDC(wxButton)绑定wxButton,之后用wxMemoryDC来copy.

Code: Select all

wxMemoryDC temp_dc;
temp_dc.SelectObject(test_bitmap);
// We can now draw into the memory DC...
// Copy from this DC to another DC.
temp_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT,clientDC, width,height);

ibruce
In need of some credit
In need of some credit
Posts: 6
Joined: Tue May 06, 2014 6:47 am

Re: 绘制控件

Post by ibruce » Mon May 12, 2014 1:12 am

infoworld wrote:
ibruce wrote:我现在想将一个控件(wxWidgets自带的控件)绘制结果保存到图片中,比如:一个wxButton,我想将它在屏上显示的形状保存到一幅图片中,然后去特殊效果处理,不知道该怎么去做,谢谢!
奇怪,国外回复还要审核的?

用wxClientDC(wxButton)绑定wxButton,之后用wxMemoryDC来copy.

Code: Select all

wxMemoryDC temp_dc;
temp_dc.SelectObject(test_bitmap);
// We can now draw into the memory DC...
// Copy from this DC to another DC.
temp_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT,clientDC, width,height);
这种方法可行,但是适用自绘控件,我现在可能要获取wxWidgets自带的控件。

Post Reply