Help with image program (CImg)

I have been working on a program that takes a binary file, gets the size on bytes (always makes it a square image X x X), and saves the read data as a png file.

After much struggle, it finally compiles. I have been using CImg as the library to make the image. But the image created does not display anything, when it should look like the same image I am using as a binary file for the tests.

The progrma consists on 4 files:
1. main.cpp Used to create the image calling the functions
2. Image.h Defines 3 functions to get the size, data, and create the image
3. Image.cpp Implements the functions

I would really appreciate if someone helps me out because I need to deliver this project the 21st. I dont know what the problem is. It may be that the data is nor read/saved correctly? etc...

I made this pastebin with all the code except CImg.h, which you can download from here: (Code is too big to paste it).


Improtant notes: the header "#define cimg_display 2" works if you are using Windows. If you are using Linux I believe the correct number is 1. Some other headers such as "windows.h" or "winbgim.h" probably do nothing. I was testing multiple headers to fix a problem there was.

Thanks in advance!
You are using the string "entrada" when you mean to use the variable name entrada in getData and getSize.
    // This ...
    ifstream arch_in("entrada", ios::binary);

    // ... should be this:
    ifstream arch_in(entrada, ios::binary);

Last edited on
Topic archived. No new replies allowed.