How to analyse a bitmap file in C++?
<p>I need to now how to analyse a BMP, the easiest way. This is only a little part of a bigger program and I don't really have a lot of time for this. Basically I only need to now the "coordinates" of the pixels which are black and that of the pixels which are white. I have done some research and found the following sites interesting:
<a href="http://www.experts-exchange.com/Programming/Languages/CPP/Q_20855407.html" rel="nofollow">site I</a>, <a href="http://www.programuj.com/forum/viewtopic.php?t=6568&amp;sid=8dcb4da79304d64144bbe0413715eb1e" rel="nofollow">site II</a>
<br>
the second one is in polish but the code posted there is understandable. The first one seems to be much more complicated (and working only on windows, which is ok for me but I try to avoid it), the second one is using vcl.h which is a Borland specific header(I use VisualStudio). I would appreciate, any help, suggestions, or links to sites covering that topic.</p>

<p>PS: This is my first post if you don't like the way I asked the question tell me what to do better. If you want additional information please ask.</p>

<p>Here is the code thanks for your help.</p>

<pre><code>// read_and_send_bmp.cpp
#include &lt;iostream&gt;&lt;\code&gt;
#include &lt;string&gt;
#include "bitmap_image.hpp"

using std::string;
using std::cin;
using std::cout;
using std::endl;

char * check(string name_of_bitmap);

int main()
{
    string name_of_bitmap;
    cout &lt;&lt; "Name of file: ";
    cin &gt;&gt; name_of_bitmap;
    char * toPrint = check(name_of_bitmap);
    cout &lt;&lt; endl &lt;&lt; "this is the value of 'toPrint': "&lt;&lt; toPrint;
    /* send
    ...
    */
    system("PAUSE");
    return 0;
}

char * check(string name_of_bitmap)
{
    bitmap_image myBitMapImage(name_of_bitmap);
    int size = myBitMapImage.pixel_count();
    char * toReturn = new char[size+1];
        for(int i = 0; i &lt; myBitMapImage.pixel_count(); i++)
        toReturn[i] = 'f';
     int h = 1;
     for(int j = 0, jlen = myBitMapImage.height(); j &lt; jlen; j++)
    {
        for(int i = 0, ilen = myBitMapImage.width(); i &lt; ilen; i++, h++)
            {
            if(myBitMapImage.red_channel(i, j) == 0 &amp;&amp; myBitMapImage.green_channel(i, j) == 0 &amp;&amp; myBitMapImage.blue_channel(i, j) == 0)
            {
            toReturn[(j)*myBitMapImage.width()+i] = 'b';
            cout &lt;&lt; "pixel nr." &lt;&lt; (j)*myBitMapImage.width()+i &lt;&lt; " = b" &lt;&lt; endl;
            }
            else
            {
            toReturn[(j)*myBitMapImage.width()+i] = 'w';
            cout &lt;&lt; "pixel nr." &lt;&lt; (j)*myBitMapImage.width()+i &lt;&lt; " = w" &lt;&lt; endl;
            }
        }
    }
    toReturn[size]='\0';
    return toReturn;
}
</code></pre>
