Same DevIL-Project in WIN fails with Ubuntu

134 views Asked by At

By using DevIL in Linux the function ilCopyPixels() returns always false, whereas it does work normally in Windows. I am trying to manipulate an input image with the library and it really works fine, but no chance when I try to compile it with g++ in ubuntu like:

g++ main.cpp PictureOperation.h PictureOperation.cpp StopWatch.h StopWatch.cpp -std=gnu++11 -lIL

I do not get an error, so it compiles fine too, but the function ilCopyPixels from DevIL returns false in this case. Here is my Init function of the class "PictureOperation":

bool PictureOperation::Init(){                                                              
ilInit();   // init DevIL

ILuint tmp = ilGenImage();
ilBindImage(tmp);

ilLoadImage(reinterpret_cast<const char *>(mInput.c_str()));

// image-information
mHeight = ilGetInteger(IL_IMAGE_HEIGHT);
mWidth = ilGetInteger(IL_IMAGE_WIDTH);

// copy into a buffer
assert(mPicOld == nullptr);
mPicOld = new ILubyte[mHeight*mWidth];
ILuint res = ilCopyPixels(0, 0, 0, mWidth, mHeight, 1, IL_COLOR_INDEX, IL_UNSIGNED_BYTE, mPicOld);

return res; // returns true if copying was successful                                               
}

So in the end it seems that my configuration with g++ and devil does not work well.. Hopefully any solutions.

In addition:

PictureOperation::PictureOperation(std::string const& inputFile, std::string const& outputFile, const int mask[SIZE_OF_MATRIX][SIZE_OF_MATRIX]){
// initialization of the members
mPicOld = nullptr;
mHeight = 0;
mWidth = 0;

mInput = inputFile;
mOutput = outputFile;

for (int y = 0; y < SIZE_OF_MATRIX; ++y) {
    for (int x = 0; x < SIZE_OF_MATRIX; ++x) {
        mFilterMask[y][x] = mask[y][x];
    }
}
}
0

There are 0 answers