将对象的外观转换为图像 [英] Convert object's appearance to image

查看:80
本文介绍了将对象的外观转换为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我有一个带有图像的PictureBox和一个已经添加到PictureBox控件的Button控件。



现在我想保存带有按钮外观(图形+文字+ ...)创建的图像的PictureBox图像,并将所有图像保存为单个图像。



如何将对象的外观更改为图像并在此之后将其视为图像?



I希望我的问题很明确。谢谢



我尝试了什么:



我试图运行一个在picturebox.controls中循环并创建大量的craphic和...

hello

I have a "PictureBox" with an image and a "Button" control which has been added to "PictureBox" controls.

Now I want to save image of "PictureBox" with image which has been created from Button Appearance(Graphic + Text + ...) and save all as an single image.

how can I change Object's appearance to image and treat with them as an "image" after that?

I hope that my question was clear. thanks

What I have tried:

I tried to run a loop in picturebox.controls and create a ton of craphic and ...

推荐答案

参见屏幕截图 [ ^ ]


图像是一个显示在图片框中的图片,是全部 - 您添加到PictureBox.Controls集合的任何其他控件实际上根本没有在图像上绘制,它们是在屏幕上绘制的(或者使用的其他图形上下文)显示PictureBox)但不以任何方式,形状或形式改变Image属性。



如果你想修改图像,你必须得到一个图形上下文,并绘制到它。



但是......如果你想拍摄带有图像和控件的图片框的快照,请查看ethe Graphics.CopyFromScreen Method(System.Drawing)| Microsoft Docs [ ^ ] - 它应该让你这样做到一个新的位图,你可以随后做你喜欢的事。
An Image is a picture which is displayed in a Picture box, is all - any other controls you add to the PictureBox.Controls collection aren't actually drawn on the Image at all, they are drawn on the screen (or other Graphics context used to displaying the PictureBox) but do not in any way, shape, or form alter the Image property.

If you want to modify the Image, your have to get a graphics context for it, and draw onto that.

But ... if you want to take a "snapshot" of the picturebox complete with Image and controls on top of it, look at ethe Graphics.CopyFromScreen Method (System.Drawing) | Microsoft Docs[^] - it should let you do that onto a new bitmap, which you can do what you like with afterwards.


谢谢你。我找到了以下指南:



Control.DrawToBitmap(Bitmap,Rectangle)方法(System.Windows.Forms)| Microsoft Docs [ ^ ]
thank you. I found following guide:

Control.DrawToBitmap(Bitmap, Rectangle) Method (System.Windows.Forms) | Microsoft Docs[^]


这篇关于将对象的外观转换为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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