title: Why doesn't c# bitmap setPixel() method work?
body: <p>I have a method that takes in numbers for a rectangle and "blanks" the pixels (turns them white) for that area.  For some reason though when my program searches for non white pixels, its finding the ones i just set to white. </p>
  
  <p>Why is it saying its not white when it is? I have an image that gets cropped and is saved to my hard drive. So I'm able to view the area it says isn't white, but when i open the image, its completely white as can be. So I'm at a lose as to why this isn't working. The program stops on the same pixel every time. It says the R value is 238 and I know that pixel was set to white because i stepped through the debugger and watched the pixel value go into the <code>bmp.SetPixel</code> method.</p>
  
  <p>This is the code for the "blanking" method:</p>
  
  <pre><code>void blankArea(int x, int y, int width, int height)
          {
              for (int i = y; i &lt;= height+y; ++i)
                  for (int t = x; t &lt;= width+x; ++t)
                  {
                      if (t == w)
                          break;
                      bmp.SetPixel(t, i, Color.White);
                  }
          }
  </code></pre>
  
  <p>this is the code that says that pixel isn't white:</p>
  
  <pre><code>bool allWhiteColumn (int col)
          {
              for (int i = 5; i &lt; h; ++i)
                  if (bmp.GetPixel(col - 1, i).R &lt; 248 &amp;&amp; bmp.GetPixel(col - 1, i).G &lt; 248)
                  {
                      imageBelowColumEnd = bmp.GetPixel(col - 1, i).R;
                      this.row = i;
                      return false;
                  }
              return true;
          }
  </code></pre>
  
  <p>Any help at this point would be greatly appreciated. I have no idea why it's saying the R is 238 after I set it to white. Thanks</p>
  
  <p>EDIT- since I post a comment I'll edit instead. Taking the if out, did nothing. Same problem. I can't check for plain white. The program finds images from a scanner. So because a scanners "white" areas are not true white, I can not look for Color.WHITE.  I'll try the bitlock though...</p>
  
  <p>EDIT 2- "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." was thrown when i tried to do the example for the locking and unlocking of the bits. It threw it once it tried to copy the bits into the array. Apparently thats not allowed.</p>
  
  <p>Thanks for the answers though.</p>