Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem Jak překrýt existující Bitmap barvou?

Private Sub Example_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
    If Form2.Button2.BackColor = Color.Red Then
        Dim rect As New Rectangle(0, 0, _zkouska1.Width, _zkouska1.Height)
        Dim bmpData As System.Drawing.Imaging.BitmapData = _zkouska1.LockBits(rect, Drawing.Imaging.ImageLockMode.ReadWrite, _zkouska1.PixelFormat)

        ' Get the address of the first line. 
        Dim ptr As IntPtr = bmpData.Scan0

        ' Declare an array to hold the bytes of the bitmap. 
        ' This code is specific to a bitmap with 24 bits per pixels. 
        Dim bytes As Integer = Math.Abs(bmpData.Stride) * bmp.Height
        Dim rgbValues(bytes - 1) 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 image will look red. 
        For counter As Integer = 0 To rgbValues.Length - 1
            If counter Mod 3 = 2 Then
                rgbValues(counter) = 255
            Else
                rgbValues(counter) = 0
            End If
        Next 

        ' Copy the RGB values back to the bitmap
        System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes)

        ' Unlock the bits.
        _zkouska1.UnlockBits(bmpData)
    End If
End Sub
Pak to jen překreslíš v události Paint.

Reakce na odpověď

1 Zadajte svou přezdívku:
2 Napište svou odpověď:
3 Pokud chcete dostat ban, zadejte libovolný text:

Zpět do poradny