Thread: Changing background color of irregular image

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    24

    Changing background color of irregular image

    I have an irregularly shaped object and I want to be able to change the background color. The image is actually divided into sections and I would like to change the color of each section. Is there any way to do this?

    Thanks

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    24

    Changing background color of irregular image

    I think I may have posted this in the wrong forum so I have reposted here.

    I have an irregularly shaped object and I want to be able to change the background color. The image is actually divided into sections and I would like to change the color of each section. Is there any way to do this?

    Thanks

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    You probably can with an program like photoshop...what are you using to edit it?
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  4. #4
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    Basically, select the object, inverse the selection to select the background, and any changes you make on the background will not affect the object. In adobe photoshop, use magnetic lasso tool. It's a basic question, you should be able to find the details on the web.

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    You can use ExtFloodFill to colour the sections.

    Alternatively, if each section is a gdi region then you can use region painting/filling functions (FillRgn, PaintRgn) to accomplish the same thing.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Code:
    void AlterBackground(RGB *image,RGB backcolor,int imgszx,int imgszy)
    {
      for (int i=0;i<imgszx;i++)
      {
        for (int j=0;j<imgszy;j++)
        {
          unsigned int texoffset=(j*imgszx+i); 
          RGB texel=image[texoffset];
          if (texel.red!=backcolor.red && texel.grn!=backcolor.grn && texel.blu!=backcolor.blu) image[texoffset]=backcolor;
        }
      }
    }

    If you want to do this in code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. Replies: 0
    Last Post: 10-07-2008, 12:09 PM
  3. Background Image
    By NoFearXD in forum Windows Programming
    Replies: 4
    Last Post: 05-16-2007, 05:25 PM
  4. background image on form
    By luigi40 in forum C# Programming
    Replies: 0
    Last Post: 07-14-2005, 05:41 AM
  5. Changing a treeview item's image
    By SMurf in forum Windows Programming
    Replies: 0
    Last Post: 01-14-2003, 07:08 PM