Is it possible to change the color of a custom shape (bitmap; for example a shape consiting of several lines and circles)during runtime??
Printable View
Is it possible to change the color of a custom shape (bitmap; for example a shape consiting of several lines and circles)during runtime??
Yes it is possible.
Make an array of your custom shapes like Shape(1), Shape(2).....etc
and then do this
Private sub SomeObject_SomeEvent()
for i = 0 to Shape.Count - 1
Shape(i).Bordercolor = RGB(255,0,0)
Shape(i).Fillcolor = RGB(0,0,255)
Next
End Sub
Hope this is what you had asked for. :D
:p Kinjal :p
And if you want to change the color of a bitmap then I think you have to put another color bitmap in a separate invisible picture box(e.xx Picture2, Autosize = True) on the form and then do this :D
Private Sub SomeObject_SomeEvent()
Picture1.Picture = Picture2.Image
End Sub
:p Kinjal :p
I do not quite understand your question. Do you want to change the Colour of a Bitmap? If so, you can use a Brute-Force method.
This example checks each Pixel in your Picture. If it is a Red Pixel, then it will be converted to Blue.
Code:Private Sub Command1_Click()
Dim iLength As Integer
Dim iWidth As Integer
'Set the variables to the Height and Width of the Picture
iLength = Picture1.Height
iWidth = Picture1.Width
'Loop through each Pixel of the Picture
For y = 0 To iLength
For x = 0 To iWidth
'DoEvents makes sure the OS doesn't freeze
DoEvents
'Get the Pixel
Retval = GetPixel(Picture1.hdc, x, y)
'If it's Red then convert it to Blue
If Retval = vbRed Then SetPixel Picture1.hdc, x, y, vbBlue
Next x
Next y
End Sub