|
-
Nov 15th, 2006, 07:29 AM
#1
Thread Starter
Frenzied Member
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.
-
Nov 15th, 2006, 09:48 AM
#2
Hyperactive Member
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..
-
Nov 17th, 2006, 03:01 AM
#3
Thread Starter
Frenzied Member
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.
-
Nov 17th, 2006, 04:27 AM
#4
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
-
Nov 17th, 2006, 05:26 AM
#5
Thread Starter
Frenzied Member
Re: replacing a colour on an image when painting into picturebox
 Originally Posted by DigiRev
cheers. user control. - dunno why i didnt think of that :P meh, might actually save me some code in other parts of my app cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|