#include "stdio.h" #include "stdlib.h" #define SWAP(x) ( ((x) << 24) | \ (((x) << 8) & 0x00ff0000) | \ (((x) >> 8) & 0x0000ff00) | \ ((x) >> 24) ) #define FIX(x) (*(unsigned *)&(x) = \ SWAP(*(unsigned *)&(x))) int main(int argc,char **argv) { int i,j; int a,r,g,b; FILE *fptr; int width,height; /* Assumes 4 byte ints */ if (argc < 2) { fprintf(stderr,"Usage: %s xfilename\n",argv[0]); exit(-1); } /* Attempt to open the file */ if ((fptr = fopen(argv[1],"r")) == NULL) { fprintf(stderr,"Failed to open input file \"%s\"\n",argv[1]); exit(-1); } /* Read the header */ fread(&width,sizeof(int),1,fptr); width = FIX(width); fprintf(stderr,"Width: %d\n",width); fread(&height,sizeof(int),1,fptr); height = FIX(height); fprintf(stderr,"Height: %d\n",height); /* Read the ARGB for each pixel */ for (j=0;j