All pastes #674498 Raw Edit

rvsjoen

public c v1 · immutable
#674498 ·published 2007-08-29 09:30 UTC
rendered paste body
void loadTexture(char* filename){	struct jpeg_decompress_struct cinfo;	struct jpeg_error_mgr jerr;	FILE* infile;	if ((infile = fopen(filename, "rb")) == NULL){		printf("Error\n");		}		cinfo.err = jpeg_std_error(&jerr);	jpeg_create_decompress(&cinfo);	jpeg_stdio_src(&cinfo, infile);	jpeg_read_header(&cinfo, true);	jpeg_start_decompress(&cinfo);    int w = cinfo.image_width;    int h = cinfo.image_height;    int d = cinfo.jpeg_color_space;    int out_h = cinfo.output_height;    printf("width:%d height:%d depth:%d out_height:%d\n", w, h ,d, out_h);    unsigned char *data = new unsigned char[w * h * d];    int counter = 0;    while (cinfo.output_scanline < cinfo.output_height)    {        jpeg_read_scanlines(&cinfo, &data, 1);	printf("%i\n",counter++);   	data += d * cinfo.output_width;    }    fclose(infile);    jpeg_finish_decompress(&cinfo);    jpeg_destroy_decompress(&cinfo);}