Lines Matching refs:fp

100 static void OutputByte(FILE * fp, int val);
101 static void OutputHalf(FILE * fp, int val);
102 static void OutputIndex(FILE * fp, char *label, int max_colors, int width, int height, u8 *pixel);
103 static void OutputCLUT(FILE * fp, char *label, ColorTable * cp);
119 static int ReadHeader(FILE * fp, int *pwidth, int *pheight, int *pdepth) in ReadHeader() argument
129 while (buffer == fgets(buffer, sizeof(buffer), fp)) in ReadHeader()
197 static int ReadBody(FILE * fp, u8 *buffer, int size) in ReadBody() argument
199 return size == fread(buffer, sizeof(u8), size, fp); in ReadBody()
326 static void OutputByte(FILE * fp, int val) in OutputByte() argument
329 fprintf(fp, "\t"); in OutputByte()
331 fprintf(fp, "0x%02x, ", val); in OutputByte()
335 fprintf(fp, "\n"); in OutputByte()
338 static void OutputHalf(FILE * fp, int val) in OutputHalf() argument
341 fprintf(fp, "\t"); in OutputHalf()
343 fprintf(fp, "0x%04x, ", val); in OutputHalf()
347 fprintf(fp, "\n"); in OutputHalf()
362 static void OutputCLUT(FILE * fp, char *label, ColorTable * cp) in OutputCLUT() argument
376 fprintf(fp, "const int Num_%s_Palette = %d;\n\n", label, cp->num_colors); in OutputCLUT()
377 fprintf(fp, "const unsigned short %s_Palette[] =\n{\n", label); in OutputCLUT()
381 OutputHalf(fp, ColorTableGetColor(cp, i)); in OutputCLUT()
383 fprintf(fp, "\n};\n\n"); in OutputCLUT()
388 fwrite(cp->color, sizeof(u16), cp->num_colors, fp); in OutputCLUT()
405 static void OutputIndex(FILE * fp, char *label, int max_colors, int width, int height, u8 *pixel) in OutputIndex() argument
414 fprintf(fp, "const int Num_%s_Texel = %d * %d;\n\n", label, width, height); in OutputIndex()
415 fprintf(fp, "const unsigned char %s_Texel[] =\n{\n", label); in OutputIndex()
429 OutputByte(fp, pixel[n]); in OutputIndex()
433 OutputByte(fp, (pixel[n] << 4) | (pixel[n - 1] & 15)); in OutputIndex()
439 fprintf(fp, "\n};\n\n"); in OutputIndex()
459 fwrite(&pixel[n], sizeof(u8), 1, fp); in OutputIndex()
464 fwrite(&buffer, sizeof(u8), 1, fp); in OutputIndex()
491 FILE *fp = NULL; in Convert() local
505 fp = fopen(ppmfile, "rb"); in Convert()
506 if (!fp) in Convert()
509 result = ReadHeader(fp, &width, &height, &depth); in Convert()
519 result = ReadBody(fp, rgb_buffer, num_pixels * 3); in Convert()
523 fclose(fp); in Convert()
524 fp = NULL; in Convert()
543 fp = fopen(outfile, valuelabel ? "w" : "wb"); in Convert()
544 if (!fp) in Convert()
549 OutputCLUT(fp, valuelabel, &clut); in Convert()
553 OutputIndex(fp, valuelabel, colormax, width, height, index_buffer); in Convert()
555 fclose(fp); in Convert()
567 if (fp) in Convert()
568 fclose(fp); in Convert()