【问题标题】:Picture box drawing image图片框绘图图像
【发布时间】:2016-09-07 09:12:46
【问题描述】:

我有一个问题。 Picture box的画图可以保存吗?

因为我有一个系统,用户可以使用 pentablet 或鼠标登录图片框。然后用户可以将此图像保存为它的签名。

这是我的输出。只是画框内的油漆:

是否可以将此绘图图像保存为 jpeg?如果是那怎么办?

感谢您的帮助。

【问题讨论】:

  • 无论您在PictureBox 上绘制了什么,当您准备保存时,您还可以在PictureBox 中绘制Image。这是一个包含该功能的演示:vbforums.com/…
  • 请注意,在Image 上绘制后,您可以调用Image.Save 将其保存到文件中。
  • @jmcilhinney 是否有可能的代码,例如单击保存按钮时会执行保存任务。这是因为这是我的系统中唯一缺少的代码
  • 是的,我已经为您提供了您需要使用的代码示例。如果你看那个演示然后编写你需要的代码太麻烦了,那是你的特权。
  • 优秀。如果您有解决方案,那么您应该将其作为答案发布并接受。我没有提供答案,因为我不想为完整的解决方案编写足够的代码,但是,如果您解决自己的问题,您应该始终提供自己的答案。这意味着其他人不会浪费时间来提供您不再需要的答案。

标签: .net vb.net picturebox


【解决方案1】:

这就是我如何将我的图片框中的颜料保存为 imgae,但在 .png 文件扩展名中。

Private Sub ts_btnSave_Click(sender As Object, e As EventArgs) Handles ts_btnSave.Click
    If Detector = 0 Then 'Detectore here is a variable where an identifier to inform me if the user paint something in picturebox or not.
        MessageBox.Show("No Signature Found", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        If MessageBox.Show("Are you sure you want to save?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) = vbYes Then
            Dim bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height)
            PictureBox1.DrawToBitmap(bmp, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height))
            bmp.Save("D:Images\Filename.png", Imaging.ImageFormat.Png) 'File name must be flexible so that it will not replace the old image.
            bmp.Dispose()
            Me.Dispose()
        End If
    End If
End Sub

@jmcilhinney 致以最诚挚的问候

【讨论】:

    猜你喜欢
    • 2013-05-14
    • 1970-01-01
    • 2011-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-27
    • 1970-01-01
    相关资源
    最近更新 更多