Pointer Cast Warning Between Two unsigned char * Values
I am getting this warning, warning: assignment makes pointer from integer without a cast, about the next code and I can not understand why.
unsigned char *dataBitmap = [self bitmapFromImage:image];
unsigned char *dataArray[(int)image.size.height][(int)ima开发者_如何学Goge.size.width * 4];
for (int i = 0; i < image.size.width * image.size.height * 4; i += 4) {
int aux = (int) i / 4;
int row = (int)(aux / image.size.width);
int column = i % ((int)image.size.width * 4);
// Alpha.
dataArray[row][column] = dataBitmap[i];
// Red.
dataArray[row][column + 1] = dataBitmap[i + 1];
// Green.
dataArray[row][column + 2] = dataBitmap[i + 2];
// Blue.
dataArray[row][column + 3] = dataBitmap[i + 3];
}
Thanks for reading.
unsigned char *dataArray[(int)image.size.height][(int)image.size.width * 4];
should be
unsigned char dataArray[(int)image.size.height][(int)image.size.width * 4];
Read the error message, and think! It says that you are somehow making a pointer from an integer (or something similar.) This means that you used a pointer where you should use an integer, or the other way round. Read your code from the start to finish, where you used pointers and integers.
精彩评论