/* texload is a simplistic routine for reading an SGI .rgb image file. */
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
ImageRec *image;
int swapFlag;
int x;
+ int result;
endianTest.testWord = 1;
if (endianTest.testByte[0] == 1) {
return NULL;
}
- fread(image, 1, 12, image->file);
+ result = fread(image, 1, 12, image->file);
+ assert(result == 12);
if (swapFlag) {
ConvertShort(&image->imagic, 1);
}
image->rleEnd = 512 + (2 * x);
fseek(image->file, 512, SEEK_SET);
- fread(image->rowStart, 1, x, image->file);
- fread(image->rowSize, 1, x, image->file);
+ result = fread(image->rowStart, 1, x, image->file);
+ assert(result == x);
+ result = fread(image->rowSize, 1, x, image->file);
+ assert(result == x);
if (swapFlag) {
ConvertUint(image->rowStart, x/(int) sizeof(unsigned));
ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int));
ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) {
unsigned char *iPtr, *oPtr, pixel;
int count;
+ int result;
if ((image->type & 0xFF00) == 0x0100) {
fseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET);
- fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
- image->file);
+ result = fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize],
+ image->file);
+ assert(result == (unsigned int)image->rowSize[y+z*image->ysize]);
iPtr = image->tmp;
oPtr = buf;
} else {
fseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize),
SEEK_SET);
- fread(buf, 1, image->xsize, image->file);
+ result = fread(buf, 1, image->xsize, image->file);
+ assert(result == image->xsize);
}
}
+#if 0
static GLubyte *
read_alpha_texture(char *name, int *width, int *height)
{
return (unsigned char *) base;
}
+#endif
static GLubyte *
read_rgb_texture(char *name, int *width, int *height)
int main(int argc, char **argv)
{
- int width, height;
+ int width = 0;
+ int height = 0;
GLubyte *data;
char buff[32];
int n;