1
0
mirror of https://frontier.innolan.net/github/AmigaExamples.git synced 2025-12-07 03:28:05 +00:00

Removed verbose debug output

This commit is contained in:
alpine9000
2016-03-01 17:31:26 +11:00
parent 92d0b97d85
commit eafef61462
2 changed files with 35 additions and 20 deletions

View File

@ -3,7 +3,7 @@ SRCS=imagecon.c
HOST_WARNINGS=-pedantic-errors -Wfatal-errors -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow -limagequant
HOST_CFLAGS=$(HOST_WARNINGS)
imagecon: out bin $(SRCS)
$(IMAGECON): out bin $(SRCS)
gcc $(HOST_CFLAGS) $(SRCS) -o $(IMAGECON) -lpng
out:
@ -12,12 +12,14 @@ out:
bin:
mkdir bin
bitplane.bin copper-list.s: bin/imagecon
out/bitplane.bin: $(IMAGECON)
-rm -f out/bitplane.bin out/hello-copper-list.s
$(IMAGECON) ../../assets/hello.png out/hello
test: imagecon bitplane.bin copper-list.s
test: $(IMAGECON) out/bitplane.bin
diff out/hello.bin reference/bitplane.bin
diff out/hello-copper-list.s reference/copper-list.s
@echo "Success!"
clean:
rm -r out bin

View File

@ -19,6 +19,7 @@
#include <pngquant/libimagequant.h>
char** _argv;
int verbose = 0;
void
abort_(const char * s, ...)
@ -85,12 +86,14 @@ void readFile(char* file_name)
color_type = png_get_color_type(png_ptr, info_ptr);
bit_depth = png_get_bit_depth(png_ptr, info_ptr);
printf("width = %d\n", width);
printf("height = %d\n", height);
printf("color_type = %d (palette = %s)\n", color_type, color_type == PNG_COLOR_TYPE_PALETTE ? "yes" : "no");
printf("bit_depth = %d\n", bit_depth);
printf("number_of_passes = %d\n", number_of_passes);
if (verbose) {
printf("width = %d\n", width);
printf("height = %d\n", height);
printf("color_type = %d (palette = %s)\n", color_type, color_type == PNG_COLOR_TYPE_PALETTE ? "yes" : "no");
printf("bit_depth = %d\n", bit_depth);
printf("number_of_passes = %d\n", number_of_passes);
}
if (color_type == PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png_ptr);
@ -133,11 +136,13 @@ void readFile(char* file_name)
fclose(fp);
printf("width = %d\n", width);
printf("height = %d\n", height);
printf("color_type = %d (palette = %s)\n", color_type, color_type == PNG_COLOR_TYPE_PALETTE ? "yes" : "no");
printf("bit_depth = %d\n", bit_depth);
printf("number_of_passes = %d\n", number_of_passes);
if (verbose) {
printf("width = %d\n", width);
printf("height = %d\n", height);
printf("color_type = %d (palette = %s)\n", color_type, color_type == PNG_COLOR_TYPE_PALETTE ? "yes" : "no");
printf("bit_depth = %d\n", bit_depth);
printf("number_of_passes = %d\n", number_of_passes);
}
}
@ -159,11 +164,15 @@ processFile(char* outFilename)
const liq_palette *pal = liq_get_palette(res);
printf("pal->count = %d\n", pal->count);
if (verbose) {
printf("pal->count = %d\n", pal->count);
}
for (unsigned i = 0; i < pal->count; i++) {
printf("%d %d %d %d\n", i, pal->entries[i].r, pal->entries[i].g, pal->entries[i].b);
if (verbose) {
printf("%d %d %d %d\n", i, pal->entries[i].r, pal->entries[i].g, pal->entries[i].b);
}
palette[i].r = pal->entries[i].r >> 4;
palette[i].g = pal->entries[i].g >> 4;
palette[i].b = pal->entries[i].b >> 4;
@ -207,9 +216,11 @@ processFile(char* outFilename)
int numBitPlanes = (int)(log(numColors-1) / log(2))+1;
printf("number of colors = %d\n", numColors);
printf("number of bitplanes = %d\n", numBitPlanes);
if (verbose) {
printf("number of colors = %d\n", numColors);
printf("number of bitplanes = %d\n", numBitPlanes);
}
char filenameBuffer[2048];
snprintf(filenameBuffer, 2048, "%s-copper-list.s", outFilename);
FILE* fp = fopen(filenameBuffer, "w+");
@ -218,7 +229,9 @@ processFile(char* outFilename)
}
for (int i = 0; i < numColors; i++) {
printf("%d: %x %d %d %d\n", i , palette[i].r << 8 | palette[i].g << 4 | palette[i].b, palette[i].r, palette[i].g, palette[i].b);
if (verbose) {
printf("%d: %x %d %d %d\n", i , palette[i].r << 8 | palette[i].g << 4 | palette[i].b, palette[i].r, palette[i].g, palette[i].b);
}
fprintf(fp, "\tdc.w $%x,$%x\n", 0x180+(i*2), palette[i].r << 8 | palette[i].g << 4 | palette[i].b);
}