forked from hkc/cc-stuff
888 lines
38 KiB
C
888 lines
38 KiB
C
// x-run: ~/scripts/runc.sh % -Wall -Wextra -lm --- ~/images/boykisser.png cpi-images/boykisser.cpi
|
|
#define STB_IMAGE_IMPLEMENTATION
|
|
#include <stb/stb_image.h>
|
|
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
|
#include <stb/stb_image_resize2.h>
|
|
#include <argp.h>
|
|
#include <stdio.h>
|
|
#include <getopt.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <strings.h>
|
|
#include <stdbool.h>
|
|
|
|
#define MAX_COLOR_DIFFERENCE 768
|
|
|
|
struct rgba { uint8_t r, g, b, a; };
|
|
union color {
|
|
struct rgba rgba;
|
|
uint32_t v;
|
|
};
|
|
struct cc_char {
|
|
unsigned char character;
|
|
unsigned char bg, fg;
|
|
};
|
|
|
|
const extern char font_atlas[256][11];
|
|
const extern union color DEFAULT_PALETTE[16], DEFAULT_GRAY_PALETTE[16];
|
|
|
|
struct arguments {
|
|
bool fast_mode;
|
|
int width, height;
|
|
enum cpi_version {
|
|
CPI_VERSION_AUTO,
|
|
CPI_VERSION_RAW,
|
|
CPI_VERSION_0,
|
|
CPI_VERSION_1,
|
|
CPI_VERSION_2,
|
|
} cpi_version;
|
|
enum placement {
|
|
PLACEMENT_CENTER,
|
|
PLACEMENT_COVER,
|
|
PLACEMENT_TILE,
|
|
PLACEMENT_FULL,
|
|
PLACEMENT_EXTEND,
|
|
PLACEMENT_FILL
|
|
} placement;
|
|
enum palette_type {
|
|
PALETTE_DEFAULT,
|
|
PALETTE_DEFAULT_GRAY,
|
|
PALETTE_AUTO,
|
|
PALETTE_PATH,
|
|
PALETTE_LIST
|
|
} palette_type;
|
|
char *palette;
|
|
char *input_path;
|
|
char *output_path;
|
|
} args = {
|
|
.fast_mode = false,
|
|
.width = 4 * 8 - 1, // 4x3 blocks screen
|
|
.height = 3 * 6 - 2,
|
|
.cpi_version = CPI_VERSION_AUTO,
|
|
.placement = PLACEMENT_FULL,
|
|
.input_path = NULL,
|
|
.output_path = NULL,
|
|
.palette = NULL,
|
|
.palette_type = PALETTE_DEFAULT // TODO(kc): change to PALETTE_AUTO when
|
|
// k-means is implemented
|
|
};
|
|
|
|
struct image {
|
|
int w, h;
|
|
union color *pixels;
|
|
};
|
|
|
|
struct image_pal {
|
|
int w, h;
|
|
uint8_t *pixels;
|
|
};
|
|
|
|
bool parse_cmdline(int argc, char **argv);
|
|
void show_help(const char *progname, bool show_all, FILE *fp);
|
|
struct image *image_load(const char *fp);
|
|
struct image *image_new(int w, int h);
|
|
struct image *image_resize(struct image *original, int new_w, int new_h);
|
|
struct image_pal *image_quantize(struct image *original, const union color *colors, size_t n_colors);
|
|
float get_color_difference(union color a, union color b);
|
|
void image_unload(struct image *img);
|
|
void get_size_keep_aspect(int w, int h, int dw, int dh, int *ow, int *oh);
|
|
|
|
const char *known_file_extensions[] = {
|
|
".png", ".jpg", ".jpeg", ".jfif", ".jpg", ".gif",
|
|
".tga", ".bmp", ".hdr", ".pnm", 0
|
|
};
|
|
|
|
static const struct optiondocs {
|
|
char shortopt;
|
|
char *longopt;
|
|
char *target;
|
|
char *doc;
|
|
struct optiondocs_choice { char *value; char *doc; } *choices;
|
|
} optiondocs[] = {
|
|
{ 'h', "help", 0, "Show help", 0 },
|
|
{ 'f', "fast", 0, "Use fast (old) method for picking characters and colors", 0 },
|
|
{ 'W', "width", "width", "Width in characters", 0 },
|
|
{ 'h', "height", "height", "Height in characters", 0 },
|
|
{ 'P', "palette", "palette", "Use specific palette.\n"
|
|
" `auto` uses automatic selection\n"
|
|
" `default` uses default palette\n"
|
|
" `defaultgray` uses default grayscale palette\n"
|
|
" `list:#RRGGBB,#RRGGBB,...` uses hard-coded one\n"
|
|
" `txt:PATH` reads hex colors from each line in a file\n", 0 },
|
|
{ 'V', "cpi_version", "version", "Force specific version of CPI",
|
|
(struct optiondocs_choice[]) {
|
|
{ "-2,raw", "Use raw format. No headers, no palette, just characters and colors" },
|
|
{ "-1,auto", "Choose best available" },
|
|
{ "0", "OG CPI, 255x255, uncompressed" },
|
|
{ "1", "CPIv1, huge images, uncompressed" },
|
|
{ "255", "In-dev version, may not work" },
|
|
{ 0, 0 } } },
|
|
{ 'p', "placement", "placement", "Image placement mode (same as in hsetroot)",
|
|
(struct optiondocs_choice[]){
|
|
{ "center", "Render image centered on the canvas" },
|
|
{ "cover", "Centered on screen, scaled to fill fully" },
|
|
{ "tile", "Render image tiled" },
|
|
{ "full", "Use maximum aspect ratio" },
|
|
{ "extend", "Same as \"full\", but filling borders" },
|
|
{ "fill", "Stretch to fill" },
|
|
{ 0, 0 } } },
|
|
{ 0, 0, "input.*", "Input file path", 0 },
|
|
{ 0, 0, "output.cpi", "Output file path", 0 },
|
|
{ 0 }
|
|
};
|
|
|
|
int main(int argc, char **argv) {
|
|
if (!parse_cmdline(argc, argv)) {
|
|
show_help(argv[0], false, stderr);
|
|
fprintf(stderr, "Fatal error occurred, exiting.\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
printf("fast_mode = %s\n", args.fast_mode ? "true" : "false");
|
|
printf("size = %dx%d\n", args.width, args.height);
|
|
printf("version = %s\n",
|
|
args.cpi_version == CPI_VERSION_AUTO ? "AUTO" : (
|
|
args.cpi_version == CPI_VERSION_RAW ? "RAW" : (
|
|
args.cpi_version == CPI_VERSION_0 ? "0" : (
|
|
args.cpi_version == CPI_VERSION_1 ? "1" : (
|
|
args.cpi_version == CPI_VERSION_2 ? "2" : (
|
|
"UNKNOWN"
|
|
)
|
|
)
|
|
)
|
|
)
|
|
));
|
|
printf("placement = %s\n",
|
|
args.placement == PLACEMENT_CENTER ? "CENTER" : (
|
|
args.placement == PLACEMENT_COVER ? "COVER" : (
|
|
args.placement == PLACEMENT_TILE ? "TILE" : (
|
|
args.placement == PLACEMENT_FULL ? "FULL" : (
|
|
args.placement == PLACEMENT_EXTEND ? "EXTEND" : (
|
|
args.placement == PLACEMENT_FILL ? "FILL" : (
|
|
"UNKNOWN"
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
));
|
|
printf("palette = %s => %s\n",
|
|
args.palette_type == PALETTE_DEFAULT ? "DEFAULT" : (
|
|
args.palette_type == PALETTE_DEFAULT_GRAY ? "DEFAULTGRAY" : (
|
|
args.palette_type == PALETTE_AUTO ? "AUTO" : (
|
|
args.palette_type == PALETTE_PATH ? "PATH" : (
|
|
args.palette_type == PALETTE_LIST ? "LIST" : (
|
|
"UNKNOWN"
|
|
)
|
|
)
|
|
)
|
|
)
|
|
),
|
|
args.palette
|
|
);
|
|
printf("input: %s\n", args.input_path);
|
|
printf("output: %s\n", args.output_path);
|
|
|
|
struct image *src_image = image_load(args.input_path);
|
|
if (!src_image) {
|
|
fprintf(stderr, "Error: failed to open the file\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
struct image *canvas;
|
|
if (args.fast_mode) {
|
|
canvas = image_new(args.width * 2, args.height * 3);
|
|
} else {
|
|
canvas = image_new(args.width * 8, args.height * 11);
|
|
}
|
|
|
|
if (!canvas) {
|
|
fprintf(stderr, "Error: failed to allocate second image buffer\n");
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
// TODO: load palette
|
|
|
|
|
|
// TODO: properly scale
|
|
struct image *scaled_image;
|
|
{
|
|
int new_w, new_h;
|
|
get_size_keep_aspect(src_image->w, src_image->h, canvas->w, canvas->h, &new_w, &new_h);
|
|
|
|
printf("new size: %dx%d\n", new_w, new_h);
|
|
scaled_image = image_resize(src_image, new_w, new_h);
|
|
}
|
|
|
|
// TODO: position image properly
|
|
int small_w = scaled_image->w < canvas->w ? scaled_image->w : canvas->w;
|
|
int small_h = scaled_image->h < canvas->h ? scaled_image->h : canvas->h;
|
|
for (int y = 0; y < small_h; y++) {
|
|
memcpy(&canvas->pixels[y * canvas->w],
|
|
&scaled_image->pixels[y * scaled_image->w],
|
|
small_w * sizeof(union color));
|
|
}
|
|
|
|
|
|
// TODO: actually do stuff
|
|
|
|
const union color *palette = DEFAULT_PALETTE;
|
|
struct cc_char *characters = calloc(args.width * args.height, sizeof(struct cc_char));
|
|
|
|
struct image_pal *quantized_image = image_quantize(canvas, palette, 16);
|
|
|
|
FILE *tmp = fopen("/tmp/img.raw", "wb");
|
|
for (int i = 0; i < quantized_image->w * quantized_image->h; i++) {
|
|
union color pix = palette[quantized_image->pixels[i]];
|
|
fputc(pix.rgba.r, tmp);
|
|
fputc(pix.rgba.g, tmp);
|
|
fputc(pix.rgba.b, tmp);
|
|
}
|
|
fclose(tmp);
|
|
|
|
if (args.fast_mode) {
|
|
// use old 2x3
|
|
} else {
|
|
// use new 8x11 character matching
|
|
for (int y = 0; y < args.height; y++) {
|
|
for (int x = 0; x < args.width; x++) {
|
|
printf("DBG: %d:%d\n", x, y);
|
|
// Oh boy...
|
|
int min_diff = 0xffffff;
|
|
char closest_sym = 0x00, closest_color = 0xae;
|
|
for (int sym = 0x01; sym <= 0xff; sym++) {
|
|
if (sym == '\t' || sym == '\n' || sym == '\r' || sym == '\x0e') {
|
|
continue;
|
|
}
|
|
for (int color = 0x00; color <= 0xff; color++) {
|
|
union color cell_bg = palette[color & 0xF],
|
|
cell_fg = palette[color >> 4];
|
|
int difference = 0;
|
|
for (int oy = 0; oy < 11; oy++) {
|
|
unsigned char sym_line = font_atlas[sym][oy];
|
|
for (int ox = 0; ox < 8; ox++) {
|
|
bool lit = sym_line & (0x80 >> ox);
|
|
union color pixel = palette[quantized_image->pixels[
|
|
ox + (x + (y * 11 + oy) * args.width) * 8
|
|
]];
|
|
difference += get_color_difference(pixel, lit ? cell_fg : cell_bg);
|
|
}
|
|
}
|
|
if (difference <= min_diff) {
|
|
min_diff = difference;
|
|
closest_sym = sym;
|
|
closest_color = color;
|
|
}
|
|
}
|
|
}
|
|
if (closest_sym != 0) {
|
|
printf("HIT! %d\n", closest_sym);
|
|
}
|
|
characters[x + y * args.width].character = closest_sym;
|
|
characters[x + y * args.width].bg = closest_color & 0xF;
|
|
characters[x + y * args.width].fg = closest_color >> 4;
|
|
}
|
|
}
|
|
}
|
|
|
|
// TODO: implement something other than CPIv0
|
|
FILE *fp = fopen(args.output_path, "wb");
|
|
fwrite("CCPI", 1, 4, fp);
|
|
fputc(args.width, fp);
|
|
fputc(args.height, fp);
|
|
fputc(0x00, fp);
|
|
for (int i = 0; i < 16; i++) {
|
|
fputc(palette[i].rgba.r, fp);
|
|
fputc(palette[i].rgba.g, fp);
|
|
fputc(palette[i].rgba.b, fp);
|
|
}
|
|
for (int i = 0; i < args.width * args.height; i++) {
|
|
fputc(characters[i].character, fp);
|
|
fputc(characters[i].bg | (characters[i].fg << 4), fp);
|
|
}
|
|
fclose(fp);
|
|
|
|
image_unload(src_image);
|
|
image_unload(canvas);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
bool parse_cmdline(int argc, char **argv) {
|
|
static struct option options[] = {
|
|
{ "help", no_argument, 0, 'h' },
|
|
{ "fast", no_argument, 0, 'f' },
|
|
{ "width", required_argument, 0, 'W' },
|
|
{ "height", required_argument, 0, 'H' },
|
|
{ "cpi_version", required_argument, 0, 'V' },
|
|
{ "placement", required_argument, 0, 'p' },
|
|
{ "palette", required_argument, 0, 'P' },
|
|
{ 0, 0, 0, 0 }
|
|
};
|
|
|
|
while (true) {
|
|
int option_index = 0;
|
|
int c = getopt_long(argc, argv, "hfW:H:V:p:P:", options, &option_index);
|
|
if (c == -1) break;
|
|
if (c == 0) c = options[option_index].val;
|
|
if (c == '?') break;
|
|
|
|
switch (c) {
|
|
case 'h':
|
|
show_help(argv[0], true, stdout);
|
|
exit(EXIT_SUCCESS);
|
|
break;
|
|
case 'f':
|
|
args.fast_mode = true;
|
|
if (args.cpi_version != CPI_VERSION_AUTO) {
|
|
fprintf(stderr, "Warning: text mode ignores version\n");
|
|
}
|
|
break;
|
|
case 'W':
|
|
args.width = atoi(optarg);
|
|
break;
|
|
case 'H':
|
|
args.height = atoi(optarg);
|
|
break;
|
|
case 'V':
|
|
{
|
|
if (0 == strcmp(optarg, "auto") || 0 == strcmp(optarg, "-1")) {
|
|
args.cpi_version = CPI_VERSION_AUTO;
|
|
} else if (0 == strcmp(optarg, "raw") || 0 == strcmp(optarg, "-2")) {
|
|
args.cpi_version = CPI_VERSION_RAW;
|
|
} else if (0 == strcmp(optarg, "0")) {
|
|
args.cpi_version = CPI_VERSION_0;
|
|
} else if (0 == strcmp(optarg, "1")) {
|
|
args.cpi_version = CPI_VERSION_1;
|
|
} else if (0 == strcmp(optarg, "2")) {
|
|
args.cpi_version = CPI_VERSION_2;
|
|
}
|
|
}
|
|
break;
|
|
case 'p':
|
|
if (0 == strcmp(optarg, "center")) {
|
|
args.placement = PLACEMENT_CENTER;
|
|
} else if (0 == strcmp(optarg, "cover")) {
|
|
args.placement = PLACEMENT_COVER;
|
|
} else if (0 == strcmp(optarg, "tile")) {
|
|
args.placement = PLACEMENT_TILE;
|
|
} else if (0 == strcmp(optarg, "full")) {
|
|
args.placement = PLACEMENT_FULL; }
|
|
else if (0 == strcmp(optarg, "extend")) {
|
|
args.placement = PLACEMENT_EXTEND;
|
|
} else if (0 == strcmp(optarg, "fill")) {
|
|
args.placement = PLACEMENT_FILL;
|
|
} else {
|
|
fprintf(stderr, "Error: invaild placement %s\n", optarg);
|
|
return false;
|
|
}
|
|
break;
|
|
case 'P':
|
|
if (0 == strcmp(optarg, "default")) {
|
|
args.palette_type = PALETTE_DEFAULT;
|
|
} else if (0 == strcmp(optarg, "defaultgray")) {
|
|
args.palette_type = PALETTE_DEFAULT_GRAY;
|
|
} else if (0 == strcmp(optarg, "auto")) {
|
|
args.palette_type = PALETTE_AUTO;
|
|
} else if (0 == strncmp(optarg, "list:", 5)) {
|
|
args.palette_type = PALETTE_LIST;
|
|
args.palette = &optarg[5];
|
|
} else {
|
|
fprintf(stderr, "Error: invaild palette %s\n", optarg);
|
|
return false;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (optind == argc) {
|
|
fprintf(stderr, "Error: no input file provided\n");
|
|
return false;
|
|
} else if (optind + 1 == argc) {
|
|
fprintf(stderr, "Error: no output file provided\n");
|
|
return false;
|
|
} else if ((argc - optind) != 2) {
|
|
fprintf(stderr, "Error: too many arguments\n");
|
|
return false;
|
|
}
|
|
|
|
args.input_path = argv[optind];
|
|
args.output_path = argv[optind + 1];
|
|
|
|
const char *extension = strrchr(args.input_path, '.');
|
|
if (!extension) {
|
|
fprintf(stderr, "Warning: no file extension, reading may fail!\n");
|
|
} else {
|
|
bool known = false;
|
|
for (int i = 0; known_file_extensions[i] != 0; i++) {
|
|
if (0 == strcasecmp(known_file_extensions[i], extension)) {
|
|
known = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!known) {
|
|
fprintf(stderr, "Warning: unknown file extension %s, reading may fail!\n", extension);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void show_help(const char *progname, bool show_all, FILE *fp) {
|
|
fprintf(fp, "usage: %s", progname);
|
|
for (int i = 0; optiondocs[i].doc != 0; i++) {
|
|
struct optiondocs doc = optiondocs[i];
|
|
fprintf(fp, " [");
|
|
if (doc.shortopt) fprintf(fp, "-%c", doc.shortopt);
|
|
if (doc.shortopt && doc.longopt) fprintf(fp, "|");
|
|
if (doc.longopt) fprintf(fp, "--%s", doc.longopt);
|
|
if (doc.target) {
|
|
if (doc.shortopt || doc.longopt) fprintf(fp, " ");
|
|
fprintf(fp, "%s", doc.target);
|
|
}
|
|
fprintf(fp, "]");
|
|
}
|
|
fprintf(fp, "\n");
|
|
|
|
if (!show_all) return;
|
|
|
|
fprintf(fp, "\n");
|
|
fprintf(fp, "ComputerCraft Palette Image converter\n");
|
|
fprintf(fp, "\n");
|
|
fprintf(fp, "positional arguments:\n");
|
|
for (int i = 0; optiondocs[i].doc != 0; i++) {
|
|
struct optiondocs doc = optiondocs[i];
|
|
if (!doc.shortopt && !doc.longopt) {
|
|
fprintf(fp, " %s\t%s\n", doc.target, doc.doc);
|
|
}
|
|
}
|
|
fprintf(fp, "\n");
|
|
fprintf(fp, "options:\n");
|
|
for (int i = 0; optiondocs[i].doc != 0; i++) {
|
|
struct optiondocs doc = optiondocs[i];
|
|
if (!doc.shortopt && !doc.longopt) { continue; }
|
|
fprintf(fp, " ");
|
|
int x = 2;
|
|
if (doc.shortopt) { fprintf(fp, "-%c", doc.shortopt); x += 2; }
|
|
if (doc.shortopt && doc.longopt) { fprintf(fp, ", "); x += 2; }
|
|
if (doc.longopt) { fprintf(fp, "--%s", doc.longopt); x += strlen(doc.longopt) + 2; }
|
|
if (doc.choices) {
|
|
fprintf(fp, " {");
|
|
for (int j = 0; doc.choices[j].value != 0; j++) {
|
|
if (j > 0) { fprintf(fp, ","); x += 1; }
|
|
fprintf(fp, "%s", doc.choices[j].value);
|
|
x += strlen(doc.choices[j].value);
|
|
}
|
|
fprintf(fp, "}");
|
|
x += 3;
|
|
} else if (doc.target) {
|
|
fprintf(fp, " ");
|
|
fprintf(fp, "%s", doc.target);
|
|
x += strlen(doc.target) + 1;
|
|
}
|
|
if (x > 24) fprintf(fp, "\n%24c", ' ');
|
|
else fprintf(fp, "%*c", 24 - x, ' ');
|
|
|
|
fprintf(fp, "%s\n", doc.doc);
|
|
|
|
if (doc.choices) {
|
|
for (int j = 0; doc.choices[j].value != 0; j++) {
|
|
fprintf(fp, "%26c", ' ');
|
|
if (doc.shortopt) fprintf(fp, "-%c ", doc.shortopt);
|
|
else if (doc.longopt) fprintf(fp, "--%s", doc.longopt);
|
|
fprintf(fp, "%-12s %s\n", doc.choices[j].value, doc.choices[j].doc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct image *image_load(const char *fp) {
|
|
struct image *img = calloc(1, sizeof(struct image));
|
|
if (!img) return NULL;
|
|
img->pixels = (union color*)stbi_load(fp, &img->w, &img->h, 0, 4);
|
|
if (!img->pixels) {
|
|
free(img);
|
|
return NULL;
|
|
}
|
|
return img;
|
|
}
|
|
|
|
struct image *image_new(int w, int h) {
|
|
struct image *img = calloc(1, sizeof(struct image));
|
|
if (!img) return NULL;
|
|
img->pixels = calloc(h, sizeof(union color) * w);
|
|
img->w = w;
|
|
img->h = h;
|
|
if (!img->pixels) {
|
|
free(img);
|
|
return NULL;
|
|
}
|
|
return img;
|
|
}
|
|
|
|
struct image *image_resize(struct image *original, int new_w, int new_h) {
|
|
struct image *resized = image_new(new_w, new_h);
|
|
if (!resized) return NULL;
|
|
stbir_resize_uint8_srgb((unsigned char *)original->pixels, original->w, original->h, 0,
|
|
(unsigned char *)resized->pixels, resized->w, resized->h, 0,
|
|
STBIR_RGBA);
|
|
return resized;
|
|
}
|
|
|
|
void image_unload(struct image *img) {
|
|
free(img->pixels);
|
|
free(img);
|
|
}
|
|
|
|
void get_size_keep_aspect(int w, int h, int dw, int dh, int *ow, int *oh)
|
|
{
|
|
*ow = dw;
|
|
*oh = dh;
|
|
float ratio = (float)w / (float)h;
|
|
float ratio_dst = (float)dw / (float)dh;
|
|
int tmp_1, tmp_2;
|
|
if (ratio_dst >= ratio)
|
|
{
|
|
tmp_1 = floor(dh * ratio);
|
|
tmp_2 = ceil(dh * ratio);
|
|
if (fabsf(ratio - (float)tmp_1 / dh) < fabsf(ratio - (float)tmp_2 / dh))
|
|
*ow = tmp_1 < 1 ? 1 : tmp_1;
|
|
else
|
|
*ow = tmp_2 < 1 ? 1 : tmp_2;
|
|
}
|
|
else
|
|
{
|
|
tmp_1 = floor(dw / ratio);
|
|
tmp_2 = ceil(dw / ratio);
|
|
if (tmp_2 == 0 ||
|
|
fabs(ratio - (float)dw / tmp_1) < fabs(ratio - (float)dw / tmp_2))
|
|
(*oh) = tmp_1 < 1 ? 1 : tmp_1;
|
|
else
|
|
(*oh) = tmp_2 < 1 ? 1 : tmp_2;
|
|
}
|
|
}
|
|
|
|
struct image_pal *image_quantize(struct image *original, const union color *colors, size_t n_colors) {
|
|
struct image_pal *out = calloc(1, sizeof(struct image_pal));
|
|
out->w = original->w;
|
|
out->h = original->h;
|
|
out->pixels = calloc(original->w, original->h);
|
|
|
|
for (int i = 0; i < out->w * out->h; i++) {
|
|
int closest_color = 0;
|
|
float closest_distance = 1e20;
|
|
for (int color = 0; color < n_colors; color++) {
|
|
float dist = get_color_difference(colors[color], original->pixels[i]);
|
|
if (dist <= closest_distance) {
|
|
closest_distance = dist;
|
|
closest_color = color;
|
|
}
|
|
}
|
|
out->pixels[i] = closest_color;
|
|
}
|
|
|
|
return out;
|
|
}
|
|
|
|
float get_color_difference(union color a, union color b) {
|
|
int dr = a.rgba.r - b.rgba.r,
|
|
dg = a.rgba.g - b.rgba.g,
|
|
db = a.rgba.b - b.rgba.b;
|
|
return dr * dr + dg * dg + db * db;
|
|
}
|
|
|
|
const union color DEFAULT_PALETTE[16] = {
|
|
{ 0xf0, 0xf0, 0xf0, 0xff },
|
|
{ 0xf2, 0xb2, 0x33, 0xff },
|
|
{ 0xe5, 0x7f, 0xd8, 0xff },
|
|
{ 0x99, 0xb2, 0xf2, 0xff },
|
|
{ 0xde, 0xde, 0x6c, 0xff },
|
|
{ 0x7f, 0xcc, 0x19, 0xff },
|
|
{ 0xf2, 0xb2, 0xcc, 0xff },
|
|
{ 0x4c, 0x4c, 0x4c, 0xff },
|
|
{ 0x99, 0x99, 0x99, 0xff },
|
|
{ 0x4c, 0x99, 0xb2, 0xff },
|
|
{ 0xb2, 0x66, 0xe5, 0xff },
|
|
{ 0x33, 0x66, 0xcc, 0xff },
|
|
{ 0x7f, 0x66, 0x4c, 0xff },
|
|
{ 0x57, 0xa6, 0x4e, 0xff },
|
|
{ 0xcc, 0x4c, 0x4c, 0xff },
|
|
{ 0x11, 0x11, 0x11, 0xff }
|
|
}, DEFAULT_GRAY_PALETTE[16] = {
|
|
{ 0xf0, 0xf0, 0xf0, 0xff },
|
|
{ 0x9d, 0x9d, 0x9d, 0xff },
|
|
{ 0xbe, 0xbe, 0xbe, 0xff },
|
|
{ 0xbf, 0xbf, 0xbf, 0xff },
|
|
{ 0xb8, 0xb8, 0xb8, 0xff },
|
|
{ 0x76, 0x76, 0x76, 0xff },
|
|
{ 0xd0, 0xd0, 0xd0, 0xff },
|
|
{ 0x4c, 0x4c, 0x4c, 0xff },
|
|
{ 0x99, 0x99, 0x99, 0xff },
|
|
{ 0x87, 0x87, 0x87, 0xff },
|
|
{ 0xa9, 0xa9, 0xa9, 0xff },
|
|
{ 0x77, 0x77, 0x77, 0xff },
|
|
{ 0x65, 0x65, 0x65, 0xff },
|
|
{ 0x6e, 0x6e, 0x6e, 0xff },
|
|
{ 0x76, 0x76, 0x76, 0xff },
|
|
{ 0x11, 0x11, 0x11, 0xff }
|
|
};
|
|
|
|
const char font_atlas[256][11] = {
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x6c, 0x44, 0x54, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x7c, 0x54, 0x7c, 0x44, 0x6c, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x28, 0x7c, 0x7c, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x38, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x38, 0x10, 0x7c, 0x7c, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x38, 0x7c, 0x7c, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7e, 0x7e, 0x66, 0x42, 0x42, 0x66, 0x7e, 0x7e, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x1c, 0x0c, 0x34, 0x48, 0x48, 0x30, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x10, 0x38, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x3c, 0x24, 0x3c, 0x20, 0x60, 0x60, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x3e, 0x22, 0x3e, 0x22, 0x66, 0x66, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x40, 0x70, 0x7c, 0x70, 0x40, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x04, 0x1c, 0x7c, 0x1c, 0x04, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x38, 0x7c, 0x10, 0x10, 0x7c, 0x38, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x24, 0x24, 0x24, 0x24, 0x24, 0x00, 0x24, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x3c, 0x54, 0x54, 0x34, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x3c, 0x60, 0x58, 0x44, 0x34, 0x0c, 0x78, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x38, 0x7c, 0x10, 0x7c, 0x38, 0x10, 0x7c, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x38, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x38, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x18, 0x7c, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x30, 0x7c, 0x30, 0x10, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x24, 0x7e, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x10, 0x38, 0x38, 0x7c, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x7c, 0x38, 0x38, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x14, 0x14, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x28, 0x7c, 0x28, 0x7c, 0x28, 0x28, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x3c, 0x40, 0x38, 0x04, 0x78, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x48, 0x08, 0x10, 0x20, 0x24, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x28, 0x10, 0x34, 0x58, 0x48, 0x34, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x08, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x10, 0x20, 0x20, 0x20, 0x10, 0x0c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x30, 0x08, 0x04, 0x04, 0x04, 0x08, 0x30, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x24, 0x18, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x04, 0x08, 0x08, 0x10, 0x20, 0x20, 0x40, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x4c, 0x54, 0x64, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x04, 0x18, 0x20, 0x44, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x04, 0x18, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x14, 0x24, 0x44, 0x7c, 0x04, 0x04, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7c, 0x40, 0x78, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x18, 0x20, 0x40, 0x78, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7c, 0x44, 0x04, 0x08, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x44, 0x38, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x44, 0x3c, 0x04, 0x08, 0x30, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x04, 0x08, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x3c, 0x42, 0x5a, 0x5a, 0x5e, 0x40, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x78, 0x44, 0x78, 0x44, 0x44, 0x44, 0x78, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x40, 0x40, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x78, 0x44, 0x44, 0x44, 0x44, 0x44, 0x78, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7c, 0x40, 0x70, 0x40, 0x40, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7c, 0x40, 0x70, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x3c, 0x40, 0x4c, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x44, 0x7c, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x10, 0x10, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x48, 0x70, 0x48, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x6c, 0x54, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x64, 0x54, 0x4c, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x78, 0x44, 0x78, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x44, 0x44, 0x44, 0x48, 0x34, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x78, 0x44, 0x78, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x3c, 0x40, 0x38, 0x04, 0x04, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x44, 0x44, 0x44, 0x28, 0x28, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x44, 0x44, 0x44, 0x54, 0x6c, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7c, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x40, 0x20, 0x20, 0x10, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x38, 0x04, 0x3c, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x78, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x04, 0x04, 0x34, 0x4c, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x38, 0x44, 0x7c, 0x40, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x10, 0x3c, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x3c, 0x44, 0x44, 0x3c, 0x04, 0x78, 0x00, 0x00, },
|
|
{ 0x00, 0x40, 0x40, 0x58, 0x64, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x04, 0x00, 0x04, 0x04, 0x04, 0x44, 0x44, 0x38, 0x00, 0x00, },
|
|
{ 0x00, 0x20, 0x20, 0x24, 0x28, 0x30, 0x28, 0x24, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x68, 0x54, 0x54, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x78, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x58, 0x64, 0x44, 0x78, 0x40, 0x40, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x34, 0x4c, 0x44, 0x3c, 0x04, 0x04, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x58, 0x64, 0x40, 0x40, 0x40, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x3c, 0x40, 0x38, 0x04, 0x78, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x10, 0x38, 0x10, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x28, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x44, 0x44, 0x54, 0x54, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x78, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x7c, 0x08, 0x10, 0x20, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x10, 0x10, 0x20, 0x10, 0x10, 0x0c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x30, 0x08, 0x08, 0x04, 0x08, 0x08, 0x30, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x32, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x24, 0x48, 0x12, 0x24, 0x48, 0x12, 0x24, 0x48, 0x12, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xfe, 0xfe, 0xfe, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x7f, 0x7f, 0x7f, 0x7f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0xf0, 0xf0, 0xf0, 0xf0, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x0f, 0x0f, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x38, 0x44, 0x40, 0x44, 0x38, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x18, 0x24, 0x20, 0x78, 0x20, 0x20, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x44, 0x38, 0x44, 0x44, 0x44, 0x38, 0x44, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x28, 0x7c, 0x10, 0x7c, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x3c, 0x60, 0x58, 0x44, 0x34, 0x0c, 0x78, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x3c, 0x4a, 0x52, 0x52, 0x4a, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x30, 0x08, 0x38, 0x48, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x14, 0x28, 0x50, 0x28, 0x14, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x7c, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x3c, 0x5a, 0x5a, 0x56, 0x42, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x30, 0x48, 0x48, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x10, 0x7c, 0x10, 0x10, 0x00, 0x7c, 0x00, 0x00, },
|
|
{ 0x00, 0x40, 0x20, 0x60, 0x40, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x20, 0x60, 0x20, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44, 0x7a, 0x40, 0x40, 0x00, },
|
|
{ 0x00, 0x3c, 0x54, 0x54, 0x34, 0x14, 0x14, 0x14, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x20, 0x60, 0x20, 0x20, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x50, 0x28, 0x14, 0x28, 0x50, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x48, 0x08, 0x10, 0x2c, 0x2c, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x44, 0x48, 0x08, 0x10, 0x24, 0x28, 0x4c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x64, 0x28, 0x68, 0x10, 0x2c, 0x2c, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x00, 0x10, 0x20, 0x40, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x00, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x50, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x00, 0x38, 0x44, 0x7c, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x3c, 0x50, 0x50, 0x78, 0x50, 0x50, 0x5c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x40, 0x40, 0x44, 0x38, 0x08, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x00, 0x7c, 0x40, 0x78, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x7c, 0x40, 0x78, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x7c, 0x40, 0x78, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x7c, 0x40, 0x78, 0x40, 0x7c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x30, 0x00, 0x38, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x18, 0x00, 0x38, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x28, 0x38, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x38, 0x10, 0x10, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x78, 0x44, 0x44, 0x64, 0x44, 0x44, 0x78, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x14, 0x28, 0x44, 0x64, 0x54, 0x4c, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x50, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x38, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x4c, 0x54, 0x64, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x28, 0x00, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x44, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x44, 0x28, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x10, 0x18, 0x14, 0x18, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x78, 0x44, 0x58, 0x44, 0x44, 0x44, 0x58, 0x40, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x00, 0x38, 0x04, 0x3c, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x38, 0x04, 0x3c, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x38, 0x04, 0x3c, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x50, 0x38, 0x04, 0x3c, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x38, 0x04, 0x3c, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x00, 0x38, 0x04, 0x3c, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x2c, 0x52, 0x7c, 0x50, 0x2e, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x38, 0x44, 0x40, 0x44, 0x38, 0x08, 0x10, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x00, 0x38, 0x44, 0x7c, 0x40, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x38, 0x44, 0x7c, 0x40, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x38, 0x44, 0x7c, 0x40, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x38, 0x44, 0x7c, 0x40, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x30, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x18, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x08, 0x3c, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x50, 0x78, 0x44, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x38, 0x44, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x50, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x10, 0x00, 0x7c, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x00, 0x00, 0x38, 0x4c, 0x54, 0x64, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x60, 0x00, 0x44, 0x44, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x44, 0x44, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x10, 0x28, 0x00, 0x44, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x44, 0x44, 0x44, 0x44, 0x3c, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x0c, 0x00, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x78, 0x00, 0x00, },
|
|
{ 0x00, 0x30, 0x10, 0x18, 0x14, 0x18, 0x10, 0x38, 0x00, 0x00, 0x00, },
|
|
{ 0x00, 0x28, 0x00, 0x44, 0x44, 0x44, 0x3c, 0x04, 0x78, 0x00, 0x00, },
|
|
};
|