如何保存背景图片? [英] How can i save an background image?

查看:93
本文介绍了如何保存背景图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

如何保存背景图片?就像用户从使用图片框在表单中提供的图片中选择图像,然后单击,保存背景图像,然后在表单加载时,它将保留用户在图片框或用户中选择的图像

How can i save an background image? like the user choose the image from the pictures given in the form using picturebox and on click, the background image get saved and then on form load it will remain the image selected by user in picture box or the user select its own image using openfiledialog.

推荐答案

您可以将.Image更改为.BackgroundImage.

You can change .Image to .BackgroundImage.

' TypeExtension would be .Bmp or .Png or whatever type

Using Bmp As New Bitmap(CType(PictureBox1.Image, Bitmap))
       Bmp.Save("FilePathandFileNameandTypeExtension", System.Drawing.Imaging.ImageFormat.TypeExtension)
End Using

' or

Using Bmp As New Bitmap(OpenFileDialog.FileName)
       Bmp.Save("FilePathandFileNameandTypeExtension", System.Drawing.Imaging.ImageFormat.TypeExtension)
End Using

更新:您还可以在应用程序属性,设置(可能是图像类型)中建立用户范围的变量.而PictureBox中的任何内容(如果有的话)都可以使用FormClosing事件子将PictureBox图像保存到用户范围内 变量设置.在Form Load上,使用用户范围的变量设置加载PictureBox.保存之前,您需要验证PictureBox是否包含图像或背景图像.或者在尝试之前,用户作用域变量包含图像 从中加载PictureBox.

Update: You could also establish a user scoped variable in the applications properties, settings, of type Image probably. And whatever is in the PictureBox, if anything, using FormClosing event sub save the PictureBox image to the user scoped variable setting. On Form Load load the PictureBox with the user scoped variable setting. You would need to validate whether the PictureBox contains an image or backgroundimage before saving. Or that the user scoped variable contains an image before trying to load the PictureBox from it.


这篇关于如何保存背景图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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