Search code examples
c++bitmappixelscanning

Read "bitmap" pixels in c++


Well I have a problem . I need to change a bitmap.bmp color into black and white using c++ , but the problem is I don't know how to read and change pixels . I don't know a bit about how to read a bitmap file . what library should I include? how should I work with pixels after scanning them ? I tried searching the web but I didn't find what I was seeking. any help would be appreciated ... I really need this information ...


Solution

  • in order to read bitmap u can use this and save .bmp bits as char to a vector(for example)...

    #include<vector>
    using namespace std;
    
    int main()
    {
       char bit;
       vector<char> name;
    
       while(cin.get(bit))
       {
           name.push_back(bit);
       }
    
    return 0;
    }