Results 1 to 5 of 5

Thread: replacing a colour on an image when painting into picturebox

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    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.
    Wayne

  2. #2
    Hyperactive Member
    Join Date
    Aug 2006
    Posts
    367

    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..

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    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.
    Wayne

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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

  5. #5

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Re: replacing a colour on an image when painting into picturebox

    Quote Originally Posted by DigiRev
    Edit: You may also want to take a look at this thread:
    http://www.vbforums.com/showthread.php?t=438378
    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
    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width