replacing a colour on an image when painting into picturebox
hi ya
ok. is it easily possible to replace a colour [white] with a different colour [lilac] when painting a picture into a picturebox?
i have an image with a white background, my picturebox is a lilac colour... the image is used in a number of places on my application, i guess i COULD have a different image, if required, but if i dont have to... :P
ta.
Re: replacing a colour on an image when painting into picturebox
Yes, it can be done in a number of ways where are you getting the picture from in your app.. I don't really want to post ideas until I know what you have to work with..
Re: replacing a colour on an image when painting into picturebox
i get the image from
Code:
loadpicture(filepath)
i may be including it in a res file though, because my external files are getting a to be quite a few. :)
ta.
Re: replacing a colour on an image when painting into picturebox
The most common method would be to use SetPixel on every white pixel in the PictureBox, but that can be really slow. Using DIBits() API would be a little faster, but still slow depending on the size of the image.
Another option is BitBlt() but that would require you to make another image, and you said you don't want to if you don't have to.
So I would take a look at regions. Here is a good example:
http://www.pscode.com/vb/scripts/Sho...63291&lngWId=1
Edit: You may also want to take a look at this thread:
http://www.vbforums.com/showthread.php?t=438378
Re: replacing a colour on an image when painting into picturebox
Quote:
Originally Posted by DigiRev
cheers. user control. :D - dunno why i didnt think of that :P meh, might actually save me some code in other parts of my app :D cheers