Hi, I am trying to load a bitmap in.
I have decided to create a class called ImageLoader, and a class called Image.
ImageLoader loads in all the information about the image, and then passes it to a temporary image. From main() i can then call the image and store it as its own image, while using the same ImageLoader to load in more images. (Some of you here helped with the code...)
so one of the member variables of the loader is
unsigned int * pixelData;
if the file opens succesfully info (width, height, offset etc) are set to variables, and then the following method is called:
the only error my code has in it is on that for loop there:Code:unsigned int * ImageLoader::readPixelData() { // Dynamically create a 2D array. pixelData = new unsigned [imageWidth*imageHeight]; // Position file pointer to start of pixel data. file.seekg(offSet); // Read pixel data. for(int y = 0; y < imageHeight; y++) { char byte; for(int x = 0; x < imageWidth; x++) { unsigned n; file.get(byte); n = (byte & 0xff); file.get(byte); n = (n << 8) | (byte & 0xff); file.get(byte); n = (n << 8) | (byte & 0xff); pixelData[(y*imageWidth) + x] = n; //cout << setw(8) << pixelData[(y*imageWidth) + x] << '\n'; } // Skip padding bytes at the end of each row. for (int i = 0; i < 4 - pixelData % 4; i++) file.get(byte); //cout << '\n'; } file.close(); return pixelData; }
The error is:Code:for (int i = 0; i < 4 - pixelData % 4; i++)
Now this used to work fine, so Im not sure what I broke, but the error (and google) aren't being the greatest of helps here.invalid operands of types unsigned int* to binary operator%
Thanks
BTW just checking: the method above is called like:
which is expecting:Code:image.setPixelData(readPixelData());
I am calling delete [] pixelData;Code:void Image::setPixelData(unsigned int * data){
Is that right? - I have already passed the array to the image object that it belongs...



LinkBack URL
About LinkBacks



).