+
+
+#include "lhfont.h"
+
+static unsigned char *Image_GenerateConChars(void)
+{
+ int i;
+ unsigned char *data;
+ double random;
+
+ image_width = 256;
+ image_height = 256;
+
+ data = LoadTGA_BGRA(concharimage, sizeof(concharimage), NULL);
+ // Gold numbers
+ for (i = 0; i < 8192; i++)
+ {
+ random = lhrandom(0.0, 1.0);
+ data[i * 4 + 3] = data[i * 4 + 0];
+ data[i * 4 + 2] = 83 + (unsigned char)(random * 64);
+ data[i * 4 + 1] = 71 + (unsigned char)(random * 32);
+ data[i * 4 + 0] = 23 + (unsigned char)(random * 16);
+ }
+ // White chars
+ for (i = 8192; i < 32768; i++)
+ {
+ random = lhrandom(0.0, 1.0);
+ data[i * 4 + 3] = data[i * 4 + 0];
+ data[i * 4 + 2] = 95 + (unsigned char)(random * 64);
+ data[i * 4 + 1] = 95 + (unsigned char)(random * 64);
+ data[i * 4 + 0] = 95 + (unsigned char)(random * 64);
+ }
+ // Gold numbers
+ for (i = 32768; i < 40960; i++)
+ {
+ random = lhrandom(0.0, 1.0);
+ data[i * 4 + 3] = data[i * 4 + 0];
+ data[i * 4 + 2] = 83 + (unsigned char)(random * 64);
+ data[i * 4 + 1] = 71 + (unsigned char)(random * 32);
+ data[i * 4 + 0] = 23 + (unsigned char)(random * 16);
+ }
+ // Red chars
+ for (i = 40960; i < 65536; i++)
+ {
+ random = lhrandom(0.0, 1.0);
+ data[i * 4 + 3] = data[i * 4 + 0];
+ data[i * 4 + 2] = 96 + (unsigned char)(random * 64);
+ data[i * 4 + 1] = 43 + (unsigned char)(random * 32);
+ data[i * 4 + 0] = 27 + (unsigned char)(random * 32);
+ }
+
+#if 0
+ Image_WriteTGABGRA("gfx/generated_conchars.tga", 256, 256, data);
+#endif
+
+ return data;
+}
+
+static unsigned char *Image_GenerateDitherPattern(void)
+{
+ int x, y;
+ unsigned char *data = (unsigned char *)Mem_Alloc(tempmempool, 8 * 8 * 4);
+ image_width = 8;
+ image_height = 8;
+ for (y = 0; y < 8; y++)
+ {
+ for (x = 0; x < 8; x++)
+ {
+ data[(y * 8 + x) * 4 + 0] = ((x^y) & 4) ? 255 : 0;
+ data[(y * 8 + x) * 4 + 1] = ((x^y) & 4) ? 255 : 0;
+ data[(y * 8 + x) * 4 + 2] = ((x^y) & 4) ? 255 : 0;
+ data[(y * 8 + x) * 4 + 3] = 255;
+ }
+ }
+ return data;
+}
+
+// also used in R_SkinFrame code
+unsigned char *Image_GenerateNoTexture(void)
+{
+ int x, y;
+ unsigned char *data = (unsigned char *)Mem_Alloc(tempmempool, 16 * 16 * 4);
+ image_width = 16;
+ image_height = 16;
+ // this makes a light grey/dark grey checkerboard texture
+ for (y = 0; y < 16; y++)
+ {
+ for (x = 0; x < 16; x++)
+ {
+ data[(y * 16 + x) * 4 + 0] =
+ data[(y * 16 + x) * 4 + 1] =
+ data[(y * 16 + x) * 4 + 2] = (y < 8) ^ (x < 8) ? 128 : 64;
+ data[(y * 16 + x) * 4 + 3] = 255;
+ }
+ }
+ return data;
+}
+
+static unsigned char *Image_GenerateWhite(void)
+{
+ unsigned char *data = (unsigned char *)Mem_Alloc(tempmempool, 1 * 1 * 4);
+ image_width = 1;
+ image_height = 1;
+ data[0] = data[1] = data[2] = data[3] = 255;
+ return data;
+}
+
+typedef struct embeddedpic_s
+{
+const char *name;
+int width;
+int height;
+const char *pixels;
+}
+embeddedpic_t;
+
+static const embeddedpic_t embeddedpics[] =
+{
+ {
+ "gfx/prydoncursor001", 16, 16,
+ "477777774......."
+ "77.....6........"
+ "7.....6........."
+ "7....6.........."
+ "7.....6........."
+ "7..6...6........"
+ "7.6.6...6......."
+ "76...6...6......"
+ "4.....6.6......."
+ ".......6........"
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ },
+ {
+ "ui/mousepointer", 16, 16,
+ "477777774......."
+ "77.....6........"
+ "7.....6........."
+ "7....6.........."
+ "7.....6........."
+ "7..6...6........"
+ "7.6.6...6......."
+ "76...6...6......"
+ "4.....6.6......."
+ ".......6........"
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ },
+ {
+ "gfx/crosshair1", 16, 16,
+ "................"
+ "................"
+ "................"
+ "...33......33..."
+ "...355....553..."
+ "....577..775...."
+ ".....77..77....."
+ "................"
+ "................"
+ ".....77..77....."
+ "....577..775...."
+ "...355....553..."
+ "...33......33..."
+ "................"
+ "................"
+ "................"
+ },
+ {
+ "gfx/crosshair2", 16, 16,
+ "................"
+ "................"
+ "................"
+ "...3........3..."
+ "....5......5...."
+ ".....7....7....."
+ "......7..7......"
+ "................"
+ "................"
+ "......7..7......"
+ ".....7....7....."
+ "....5......5...."
+ "...3........3..."
+ "................"
+ "................"
+ "................"
+ },
+ {
+ "gfx/crosshair3", 16, 16,
+ "................"
+ ".......77......."
+ ".......77......."
+ "................"
+ "................"
+ ".......44......."
+ ".......44......."
+ ".77..44..44..77."
+ ".77..44..44..77."
+ ".......44......."
+ ".......44......."
+ "................"
+ "................"
+ ".......77......."
+ ".......77......."
+ "................"
+ },
+ {
+ "gfx/crosshair4", 16, 16,
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ "................"
+ "........7777777."
+ "........752....."
+ "........72......"
+ "........7......."
+ "........7......."
+ "........7......."
+ "........7......."
+ "................"
+ },
+ {
+ "gfx/crosshair5", 8, 8,
+ "........"
+ "........"
+ "....7..."
+ "........"
+ "..7.7.7."
+ "........"
+ "....7..."
+ "........"
+ },
+ {
+ "gfx/crosshair6", 2, 2,
+ "77"
+ "77"
+ },
+ {
+ "gfx/crosshair7", 16, 16,
+ "................"
+ ".3............3."
+ "..5...2332...5.."
+ "...7.3....3.7..."
+ "....7......7...."
+ "...3.7....7.3..."
+ "..2...7..7...2.."
+ "..3..........3.."
+ "..3..........3.."
+ "..2...7..7...2.."
+ "...3.7....7.3..."
+ "....7......7...."
+ "...7.3....3.7..."
+ "..5...2332...5.."
+ ".3............3."
+ "................"
+ },
+ { NULL, 0, 0, NULL }
+};
+
+unsigned char *Image_GetEmbeddedPicBGRA(const char *name)
+{
+ const embeddedpic_t *p;
+ for (p = embeddedpics; p->name; p++)
+ {
+ if (!strcmp(name, p->name))
+ {
+ int i;
+ unsigned char *data = (unsigned char *)Mem_Alloc(tempmempool, p->width * p->height * 4);
+ image_width = p->width;
+ image_height = p->height;
+ for (i = 0; i < p->width * p->height; i++)
+ {
+ const unsigned char *c = (const unsigned char *)palette_bgra_embeddedpic + 4 * p->pixels[i];
+ Vector4Copy(c, data + 4 * i);
+ }
+ return data;
+ }
+ }
+ if (!strcmp(name, "white") || !strcmp(name, "#white") || !strcmp(name, "*white") || !strcmp(name, "$whiteimage"))
+ return Image_GenerateWhite();
+ if (!strcmp(name, "gfx/conchars"))
+ return Image_GenerateConChars();
+ if (!strcmp(name, "gfx/colorcontrol/ditherpattern"))
+ return Image_GenerateDitherPattern();
+ return NULL;
+}