CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2002
    Posts
    1

    About monochrome format

    I need to read a monochrome image in C++ but there is no a function or something like that. The problem is to read it, available definitions in C++ don´t permit to work in binary format and I need the code source that permits it. Thanks a lot.

  2. #2
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    Are you trying to read a .bmp file? If all else fails in C++, you could fall back into C and use FILE*. eg

    #include <stdio.h>
    FILE* image = fopen ("filename", "r+b"); // b means binary
    fread (
    buffer, // The input buffer - you have to new this
    1, // size of each item
    size, // total size
    image);

    I haven't done binary I/O in C++. I'll dig through my books and see what there is.
    Succinct is verbose for terse

  3. #3
    Join Date
    Jun 2002
    Location
    Letchworth, UK
    Posts
    1,020
    I don't know if this is VC++ specific. To open a binary file using streams, use

    ifstream bmp(bmpfilename);
    bmp.setmode(filebuf::binary);

    The default is filebuf::text.
    Succinct is verbose for terse

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured