[ create a new paste ] login | about

Link: http://codepad.org/c2jyj8Mu    [ raw code | output | fork ]

C, pasted on Oct 30:
#define WIDTH 640
#define HEIGHT 480

#include<stdio.h>
#include<stdlib.h>

typedef struct color{
	unsigned char r;
	unsigned char g;
	unsigned char b;
}COLOR;

int main(){
	int i, j;
	COLOR data[WIDTH][HEIGHT];
	FILE *fp;

	if((fp = fopen("image.bmp", "rb")) == NULL){
		fprintf(stderr, "file open error");
		exit(1);
	}

	fseek(fp, 54, SEEK_SET);

	for(j=HEIGHT-1; j>=0; j--){
		for(i=0; i<WIDTH; i++){
			data[i][j].b = getc(fp);
			data[i][j].g = getc(fp);
			data[i][j].r = getc(fp);
		}
	}

	fclose(fp);

	return 0;
}


Output:
1
file open error


Create a new paste based on this one


Comments: