所以我有这段代码:
Private Sub button28_Click(sender As Object, e As EventArgs) Handles button28.Click
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = PicOuterBorder.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
picFinal.Image = screenshot
'this takes a screenshot
End Sub
PicOuterBorder
是我表单上的图片框。 PicFinal
是另一个显示图片框。但是这段代码让我知道了这一点:这基本上是从屏幕原点开始的PicOuterBorder大小的窗口截图。但是,Me.Bounds
代替PicOuterBorder.Bounds
可以正常工作,并获得仅仅是我的表单的完美屏幕截图。我希望picFinal有一个PicOuterBorder的截图
答案 0 :(得分:1)
根据以下内容调整代码:
Public Sub SaveImage(filename As String, image As Image, Encoder As ImageCodecInfo, EncParam As EncoderParameter)
Dim path As String = System.IO.Path.Combine(My.Application.Info.DirectoryPath, filename & ".jpg")
Dim mySource As New Bitmap(image.Width, image.Height)
Dim grfx As Graphics = Graphics.FromImage(mySource)
grfx.DrawImageUnscaled(image, Point.Empty)
grfx.Dispose()
mySource.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg)
mySource.Dispose()
End Sub
答案 1 :(得分:1)
尝试以下代码。您必须使用 <tr onclick="doSomething()">
<td>text</td>
<td>text</td>
<td>text</td>
<td onclick="doSomethingElse(); event.stopPropagation(); ">
<!-- drop down elements -->
</td>
</tr>
将控件坐标映射到屏幕坐标。我已将PointToScreen
放在面板PicOuterBorder
中。 PanelPicture
没有任何边框,而PanelPicture
可以有任何类型的边框样式。下面的代码拍摄了面板的快照。
PicOuterBorder