Anonymous - 2009-11-22

Hi ,

I have an image class that I am trying to get to work with file i/o using DevIL.  While I can successfully read raw data into my pixel buffer, I can't seem to be able to get the reverse right :(

Here's a snippet that achieves input (this works) …

    bool isOK = ilLoadImage(inFile.c_str());

    ILubyte *fileData = ilGetData();
    int w = ilGetInteger(IL_IMAGE_WIDTH);
    int h = ilGetInteger(IL_IMAGE_HEIGHT);
    int d = ilGetInteger(IL_IMAGE_DEPTH);


    int *dataPtr = reinterpret_cast<int*>(myImage.rawData());
    int pixelSize = 3;

    for(int i = 0; i < h*w*d*pixelSize; i++){
    *(dataPtr + i) = *(fileData+i);

Here's what I'm trying to do when I try to save my image …

    int *dataPtr = reinterpret_cast<int*>(myImage.rawData());
    ilGenImages(1, ilImage);

    int size = w*h*d*pixelSize;
    ILubyte* dstData = new ILubyte;
    for( int i =0; i < size; i++){
        *(dstData+i) = *(dataPtr+i);
    isOK = ilSetData(dstData);

This only manages to save a 1x1 image. What am I doing wrong? :(