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

A jak tedy nastavim napriklad (255, 174, 201)?
A neslo by aby to bylo automaticky nejak pridat toto akort misto s RED na BLUE atd??

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) * _zkouska1.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
Dim modulo As Integer = counter Mod 4
If modulo = 3 Then
Continue For
End If
If modulo = 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(rgbVal ues, 0, ptr, bytes)

' Unlock the bits.
_zkouska1.UnlockBits(bmpData)

Refresh()
End If

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