1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
ILuint Image = ilGenImage();
ilBindImage(Image);
if(!ilLoadImage("Image filename here"))
// Cannot load!
ILuint Width = ilGetInteger(IL_IMAGE_WIDTH);
ILuint Height = ilGetInteger(IL_IMAGE_HEIGHT);
unsigned char Data = new unsigned char[Width * Height * 4];
ilCopyPixels(0,0,0,Width,Height,1,IL_RGBA,IL_UNSIGNED_BYTE,Data);
ilDeleteImages(1,&Image);
Image = 0;
// Use Data as a R8, G8, B8, A8 array.
// Data[0] = First pixel, red component
// Data[1] = First pixel, green component
// Data[2] = First pixel, blue component
// Data[3] = First pixel, alpha component
// Data[ (Width * Height * 4) - 1] = Last pixel, alpha component
delete[] Data;
Data = 0;
|