Changing background color of irregular image

This is a discussion on Changing background color of irregular image within the C++ Programming forums, part of the General Programming Boards category; I have an irregularly shaped object and I want to be able to change the background color. The image is ...

  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
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    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, 06:08 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21