0

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];
    }
}
}
smrj
  • 1
  • 1
  • How do you read input into `mInput`? How do you initialize`mPicOld`? Please try to create a [mcve] to show us. – Some programmer dude Jan 05 '20 at 20:21
  • I have updated my question. mInput will be initialized with inputFile and mPicOld will be initialized with nullptr. – smrj Jan 05 '20 at 20:31
  • The return value is ILuint, not ILvoid. ilCopyPixels is declared like this: ILAPI ILuint ILAPIENTRY ilCopyPixels(ILuint XOff, ILuint YOff, ILuint ZOff, ILuint Width, ILuint Height, ILuint Depth, ILenum Format, ILenum Type, ILvoid *Data); – smrj Jan 05 '20 at 20:44

0 Answers0