Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class MyButton
- Inherits Button
- Public WithEvents Measurement As New Button
- Private Function GetFormImage(ByVal include_borders As _
- Boolean) As Bitmap
- ' Make the bitmap.
- Dim wid As Integer = Me.Width
- Dim hgt As Integer = Me.Height
- Dim bm As New Bitmap(wid, hgt)
- ' Draw the form onto the bitmap.
- Me.DrawToBitmap(bm, New Rectangle(0, 0, wid, hgt))
- ' If we want the borders, return the bitmap.
- If include_borders Then Return bm
- ' Make a smaller bitmap without borders.
- wid = Me.ClientSize.Width
- hgt = Me.ClientSize.Height
- Dim bm2 As New Bitmap(wid, hgt)
- ' Get the offset from the window's corner to its client
- ' area's corner.
- Dim pt As New Point(0, 0)
- pt = PointToScreen(pt)
- Dim dx As Integer = pt.X - Me.Left
- Dim dy As Integer = pt.Y - Me.Top
- ' Copy the part of the original bitmap that we want
- ' into the bitmap.
- Dim gr As Graphics = Graphics.FromImage(bm2)
- gr.DrawImage(bm, 0, 0, New Rectangle(dx, dy, wid, hgt),
- GraphicsUnit.Pixel)
- Return bm2
- End Function
- Sub Konzertkarte(Farn As Button)
- With Farn
- .Location = New Point(250, 250)
- '.BackgroundImage = New Bitmap("C:\Temp\karu.bmp")
- '.Size = Farn.BackgroundImage.Size
- End With
- End Sub
- Sub LockUnlockBitsExample(ByVal e As PaintEventArgs)
- 'Create a new bitmap.
- Dim bmp As New Bitmap("C:\Temp\karu.bmp")
- Dim test_zeilenumbruch As Graphics = Graphics.FromImage(bmp)
- test_zeilenumbruch.Dispose()
- 'Lock the bitmap's bits.
- Dim rect As New Rectangle(0, 0, bmp.Width, bmp.Height)
- Dim bmpData As System.Drawing.Imaging.BitmapData =
- bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
- bmp.PixelFormat)
- 'Get the address of the first line.
- Dim ptr As IntPtr = bmpData.Scan0
- 'Declare an array to hold the bytes of the bitmap.
- Dim bytes As Integer = Math.Abs(bmpData.Stride) * bmp.Height
- Dim rgbValues(bytes) As Byte
- 'Copy the RGB values into the array.
- System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes)
- 'Set every third value to 255. A 24bpp bitmap will look red.
- For counter As Integer = 2 To rgbValues.Length - 1 Step 3
- rgbValues(counter) = 255
- Next
- 'Copy the RGB values back to the bitmap
- System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes)
- 'Unlock the bits.
- bmp.UnlockBits(bmpData)
- 'Draw the modified image.
- e.Graphics.DrawImage(bmp, 300, 200)
- End Sub
- Public toggle As Integer
- Public Pong As Boolean
- Private Sub Measurement_Click(sender As Object, e As EventArgs) Handles Measurement.Click
- If toggle Then
- 'Measurement.Text = "Status: ON"
- Measurement.BackgroundImage = New Bitmap("C:\Temp\karu.bmp")
- Measurement.Size = Measurement.BackgroundImage.Size
- Dim graph As Graphics
- Dim frmleft As System.Drawing.Point = Me.Bounds.Location
- Dim bmp As New Bitmap(48, 48) 'Me.Bounds.Width + 8, Me.Bounds.Height + 8
- graph = Graphics.FromImage(bmp)
- Dim screenx As Integer = frmleft.X
- Dim screeny As Integer = frmleft.Y
- graph.CopyFromScreen(screenx + 58, screeny + 81, 0, 0, bmp.Size)
- bmp.Save("C:\Temp\RaidThrough.bmp", System.Drawing.Imaging.ImageFormat.Jpeg)
- Else
- 'Measurement.Text = "Status: OFF"
- Measurement.BackgroundImage = New Bitmap("C:\Temp\DimSim.bmp")
- Measurement.Size = Measurement.BackgroundImage.Size
- Pong = True
- Form1.Invalidate()
- End If
- toggle = Not toggle
- End Sub
- End Class
Advertisement
RAW Paste Data
Copied
Advertisement