[
  {
    "path": ".gitignore",
    "content": "## OS X specific\n.DS_Store\n\n## Various settings\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata/\nC/blurhash_encoder\nC/blurhash_decoder\nRuby/.*\nRuby/Makefile\nPython/build/\n*.bundle\n*.so\n*.o\n*.pyc\n\n# Website\nWebsite/node_modules/\nWebsite/dist/\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"Python\"]\n\tpath = Python\n\turl = https://github.com/creditornot/blurhash-python.git\n"
  },
  {
    "path": "Algorithm.md",
    "content": "# BlurHash Algorithm\n\n## Summary\n\nBlurHash applies a simple [DCT transform](https://en.wikipedia.org/wiki/Discrete_cosine_transform) to the image data,\nkeeping only the first few components, and then encodes these components using a base 83 encoding, with a JSON,\nHTML and shell-safe character set. The DC component, which represents the average colour of the image, is stored exactly\nas an sRGB value, for easy use without implementing the full algorithm. The AC components are encoded lossily.\n\n## Reference implementation\n\n[Simplified Swift decoder implementation.](Swift/BlurHashDecode.swift)\n\n[Simplified Swift encoder implementation.](Swift/BlurHashEncode.swift)\n\n## Structure\n\nHere follows an example of a BlurHash string, with the different parts labelled:\n\n    Example: LlMF%n00%#MwS|WCWEM{R*bbWBbH\n    Legend:  12333344....................\n\n1. **Number of components, 1 digit.**\n   \n   For a BlurHash with `nx` components along the X axis and `ny` components along the Y axis, this is equal to `(nx - 1) + (ny - 1) * 9`.\n\n2. **Maximum AC component value, 1 digit.**\n   \n   All AC components are scaled by this value. It represents a floating-point value of `(max + 1) / 166`.\n\n3. **Average colour. 4 digits.**\n   \n   The average colour of the image in sRGB space, encoded as a 24-bit RGB value, with R in the most significant position. This value can\n   be used directly if you only want the average colour rather than the full DCT-encoded image.\n\n4. **AC components, 2 digits each, `nx * ny - 1` components in total.**\n   \n   The AC components of the DCT transform, ordered by increasing X first, then Y. They  are encoded as three values for `R`, `G` and `B`,\n   each between 0 and 18. They are combined together as `R * 19^2 + G * 19 + B`, for a total range of 0 to 6859.\n   \n   Each value represents a floating-point value between -1 and 1. 0-8 represent negative values, 9 represents zero, and 10-18\n   represent positive values. Positive values are encoded as `((X - 9) / 9) ^ 2`, while negative\n   values are encoded as `-((9 - X) / 9 ) ^ 2`. `^` represents exponentiation. This value is then multiplied by the maximum AC\n   component value, field 2 above.\n\n## Base 83\n\nA custom base 83 encoding is used. Values are encoded individually, using 1 to 4 digits, and concatenated together. Multiple-digit\nvalues are encoded in big-endian order, with the most significant digit first.\n\nThe character used set is `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~`.\n\n## Discrete Cosine Transform\n\nTo decode a single pixel of output, you loop over the DCT components and calculate a weighted sum of cosine functions. In\npseudocode, for a normalised pixel position `x`, `y`, with each coordinate ranging from 0 to 1, and components `Cij` ,\nyou calculate the following for each of R, G and B:\n\n    foreach j in 0 ... ny - 1\n        foreach i in 0 ... nx - 1\n            value = value + Cij * cos(x * i * pi) * cos(y * j * pi)\n\nThe `C00` component is the DC component, while the others are the AC components. The DC component must first be converted\nfrom sRGB to linear RGB space. AC components are already linear.\n\nOnce the R, G and B values have been calculated, they must be converted from linear to your output colourspace, usually sRGB.\n"
  },
  {
    "path": "C/Makefile",
    "content": "PROGRAM=blurhash_encoder\nDECODER=blurhash_decoder\n$(PROGRAM): encode_stb.c encode.c encode.h stb_image.h common.h\n\t$(CC) -o $@ encode_stb.c encode.c -lm -Ofast\n\n$(DECODER): decode_stb.c decode.c decode.h stb_writer.h common.h\n\t$(CC) -o $(DECODER) decode_stb.c decode.c -lm -Ofast\n\n.PHONY: clean\nclean:\n\trm -f $(PROGRAM)\n\trm -f $(DECODER)"
  },
  {
    "path": "C/Readme.md",
    "content": "# BlurHash encoder in portable C\n\nThis code implements an encoder for the BlurHash algorithm in C. It can be used to integrate into other language\nusing an FFI interface. Currently the Python integration uses this code.\n\n## Usage as a library\n\nInclude the `encode.c` and `encode.h` files in your project. They have no external dependencies.\n\nA single file function is defined:\n\n    const char *blurHashForPixels(int xComponents, int yComponents, int width, int height, uint8_t *rgb, size_t bytesPerRow) {\n\nThis function returns a string containing the BlurHash. This memory is managed by the function, and you should not free it.\nIt will be overwritten on the next call into the function, so be careful!\n\n* `xComponents` - The number of components in the X direction. Must be between 1 and 9. 3 to 5 is usually a good range for this.\n* `yComponents` - The number of components in the Y direction. Must be between 1 and 9. 3 to 5 is usually a good range for this.\n* `width` - The width in pixels of the supplied image.\n* `height` - The height in pixels of the supplied image.\n* `rgb` - A pointer to the pixel data. This is supplied in RGB order, with 3 bytes per pixels.\n* `bytesPerRow` - The number of bytes per row of the RGB pixel data.\n\n## Usage as a command-line tool\n\nYou can also build a command-line version to test the encoder and decoder. However, note that it uses `stb_image` to load images,\nwhich is not really security-hardened, so it is **not** recommended to use this version in production on untrusted data!\nUse one of the integrations instead, which use more robust image loading libraries.\n\nNevertheless, if you want to try it out quickly, simply run:\n\n\t$ make blurhash_encoder\n\t$ ./blurhash_encoder 4 3 ../Swift/BlurHashTest/pic1.png\n\tLaJHjmVu8_~po#smR+a~xaoLWCRj\n\nIf you want to try out the decoder, simply run:\n\n\t$ make blurhash_decoder\n\t$ ./blurhash_decoder \"LaJHjmVu8_~po#smR+a~xaoLWCRj\" 32 32 decoded_output.png\n"
  },
  {
    "path": "C/common.h",
    "content": "#ifndef __BLURHASH_COMMON_H__\n#define __BLURHASH_COMMON_H__\n\n#include<math.h>\n\n#ifndef M_PI\n#define M_PI 3.14159265358979323846\n#endif\n\nstatic inline int linearTosRGB(float value) {\n\tfloat v = fmaxf(0, fminf(1, value));\n\tif(v <= 0.0031308) return v * 12.92 * 255 + 0.5;\n\telse return (1.055 * powf(v, 1 / 2.4) - 0.055) * 255 + 0.5;\n}\n\nstatic inline float sRGBToLinear(int value) {\n\tfloat v = (float)value / 255;\n\tif(v <= 0.04045) return v / 12.92;\n\telse return powf((v + 0.055) / 1.055, 2.4);\n}\n\nstatic inline float signPow(float value, float exp) {\n\treturn copysignf(powf(fabsf(value), exp), value);\n}\n\n#endif\n"
  },
  {
    "path": "C/decode.c",
    "content": "#include \"decode.h\"\n#include \"common.h\"\n\nstatic char chars[83] = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~\";\n\nstatic inline uint8_t clampToUByte(int * src) {\n\tif( *src >= 0 && *src <= 255 )\n\t\treturn *src;\n\treturn (*src < 0) ? 0 : 255;\n}\n\nstatic inline uint8_t *  createByteArray(int size) {\n\treturn (uint8_t *)malloc(size * sizeof(uint8_t));\n}\n\nint decodeToInt(const char * string, int start, int end) {\n\tint value = 0, iter1 = 0, iter2 = 0;\n\tfor( iter1 = start; iter1 < end; iter1 ++) {\n\t\tint index = -1;\n\t\tfor(iter2 = 0; iter2 < 83; iter2 ++) {\n\t\t\tif (chars[iter2] == string[iter1]) {\n\t\t\t\tindex = iter2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (index == -1) return -1;\n\t\tvalue = value * 83 + index;\n\t}\n\treturn value;\n}\n\nbool isValidBlurhash(const char * blurhash) {\n\n\tconst int hashLength = strlen(blurhash);\n\n\tif ( !blurhash || strlen(blurhash) < 6) return false;\n\n\tint sizeFlag = decodeToInt(blurhash, 0, 1);\t//Get size from first character\n\tint numY = (int)floorf(sizeFlag / 9) + 1;\n\tint numX = (sizeFlag % 9) + 1;\n\n\tif (hashLength != 4 + 2 * numX * numY) return false;\n\treturn true;\n}\n\nvoid decodeDC(int value, float * r, float * g, float * b) {\n\t*r = sRGBToLinear(value >> 16); \t// R-component\n\t*g = sRGBToLinear((value >> 8) & 255); // G-Component\n\t*b = sRGBToLinear(value & 255);\t// B-Component\n}\n\nvoid decodeAC(int value, float maximumValue, float * r, float * g, float * b) {\n\tint quantR = (int)floorf(value / (19 * 19));\n\tint quantG = (int)floorf(value / 19) % 19;\n\tint quantB = (int)value % 19;\n\n\t*r = signPow(((float)quantR - 9) / 9, 2.0) * maximumValue;\n\t*g = signPow(((float)quantG - 9) / 9, 2.0) * maximumValue;\n\t*b = signPow(((float)quantB - 9) / 9, 2.0) * maximumValue;\n}\n\nint decodeToArray(const char * blurhash, int width, int height, int punch, int nChannels, uint8_t * pixelArray) {\n\tif (! isValidBlurhash(blurhash)) return -1;\n\tif (punch < 1) punch = 1;\n\n\tint sizeFlag = decodeToInt(blurhash, 0, 1);\n\tint numY = (int)floorf(sizeFlag / 9) + 1;\n\tint numX = (sizeFlag % 9) + 1;\n\tint iter = 0;\n\n\tfloat r = 0, g = 0, b = 0;\n\tint quantizedMaxValue = decodeToInt(blurhash, 1, 2);\n\tif (quantizedMaxValue == -1) return -1;\n\n\tfloat maxValue = ((float)(quantizedMaxValue + 1)) / 166;\n\n\tint colors_size = numX * numY;\n\tfloat colors[colors_size][3];\n\n\tfor(iter = 0; iter < colors_size; iter ++) {\n\t\tif (iter == 0) {\n\t\t\tint value = decodeToInt(blurhash, 2, 6);\n\t\t\tif (value == -1) return -1;\n\t\t\tdecodeDC(value, &r, &g, &b);\n\t\t\tcolors[iter][0] = r;\n\t\t\tcolors[iter][1] = g;\n\t\t\tcolors[iter][2] = b;\n\n\t\t} else {\n\t\t\tint value = decodeToInt(blurhash, 4 + iter * 2, 6 + iter * 2);\n\t\t\tif (value == -1) return -1;\n\t\t\tdecodeAC(value, maxValue * punch, &r, &g, &b);\n\t\t\tcolors[iter][0] = r;\n\t\t\tcolors[iter][1] = g;\n\t\t\tcolors[iter][2] = b;\n\t\t}\n\t}\n\n\tint bytesPerRow = width * nChannels;\n\tint x = 0, y = 0, i = 0, j = 0;\n\tint intR = 0, intG = 0, intB = 0;\n\n\tfor(y = 0; y < height; y ++) {\n\t\tfor(x = 0; x < width; x ++) {\n\n\t\t\tfloat r = 0, g = 0, b = 0;\n\n\t\t\tfor(j = 0; j < numY; j ++) {\n\t\t\t\tfor(i = 0; i < numX; i ++) {\n\t\t\t\t\tfloat basics = cos((M_PI * x * i) / width) * cos((M_PI * y * j) / height);\n\t\t\t\t\tint idx = i + j * numX;\n\t\t\t\t\tr += colors[idx][0] * basics;\n\t\t\t\t\tg += colors[idx][1] * basics;\n\t\t\t\t\tb += colors[idx][2] * basics;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tintR = linearTosRGB(r);\n\t\t\tintG = linearTosRGB(g);\n\t\t\tintB = linearTosRGB(b);\n\n\t\t\tpixelArray[nChannels * x + 0 + y * bytesPerRow] = clampToUByte(&intR);\n\t\t\tpixelArray[nChannels * x + 1 + y * bytesPerRow] = clampToUByte(&intG);\n\t\t\tpixelArray[nChannels * x + 2 + y * bytesPerRow] = clampToUByte(&intB);\n\n\t\t\tif (nChannels == 4)\n\t\t\t\tpixelArray[nChannels * x + 3 + y * bytesPerRow] = 255;   // If nChannels=4, treat each pixel as RGBA instead of RGB\n\n\t\t}\n\t}\n\n\treturn 0;\n}\n\nuint8_t * decode(const char * blurhash, int width, int height, int punch, int nChannels) {\n\tint bytesPerRow = width * nChannels;\n\tuint8_t * pixelArray = createByteArray(bytesPerRow * height);\n\n\tif (decodeToArray(blurhash, width, height, punch, nChannels, pixelArray) == -1)\n\t\treturn NULL;\n\treturn pixelArray;\n}\n\nvoid freePixelArray(uint8_t * pixelArray) {\n\tif (pixelArray) {\n\t\tfree(pixelArray);\n\t}\n}\n"
  },
  {
    "path": "C/decode.h",
    "content": "#ifndef __BLURHASH_DECODE_H__\n\n#define __BLURHASH_DECODE_H__\n\n#include <math.h>\n#include <stdbool.h>\n#include <string.h>\n#include <stdlib.h>\n#include <stdint.h>\n\n/*\n\tdecode : Returns the pixel array of the result image given the blurhash string,\n\tParameters : \n\t\tblurhash : A string representing the blurhash to be decoded.\n\t\twidth : Width of the resulting image\n\t\theight : Height of the resulting image\n\t\tpunch : The factor to improve the contrast, default = 1\n\t\tnChannels : Number of channels in the resulting image array, 3 = RGB, 4 = RGBA\n\tReturns : A pointer to memory region where pixels are stored in (H, W, C) format\n*/\nuint8_t * decode(const char * blurhash, int width, int height, int punch, int nChannels);\n\n/*\n\tdecodeToArray : Decodes the blurhash and copies the pixels to pixelArray,\n\t\t\t\t\tThis method is suggested if you use an external memory allocator for pixelArray.\n\t\t\t\t\tpixelArray should be of size : width * height * nChannels\n\tParameters :\n\t\tblurhash : A string representing the blurhash to be decoded.\n\t\twidth : Width of the resulting image\n\t\theight : Height of the resulting image\n\t\tpunch : The factor to improve the contrast, default = 1\n\t\tnChannels : Number of channels in the resulting image array, 3 = RGB, 4 = RGBA\n\t\tpixelArray : Pointer to memory region where pixels needs to be copied.\n\tReturns : int, -1 if error 0 if successful\n*/\nint decodeToArray(const char * blurhash, int width, int height, int punch, int nChannels, uint8_t * pixelArray);\n\n/*\n\tisValidBlurhash : Checks if the Blurhash is valid or not.\n\tParameters :\n\t\tblurhash : A string representing the blurhash\n\tReturns : bool (true if it is a valid blurhash, else false)\n*/\nbool isValidBlurhash(const char * blurhash); \n\n/*\n\tfreePixelArray : Frees the pixel array\n\tParameters :\n\t\tpixelArray : Pixel array pointer which will be freed.\n\tReturns : void (None)\n*/\nvoid freePixelArray(uint8_t * pixelArray);\n\n#endif\n"
  },
  {
    "path": "C/decode_stb.c",
    "content": "#include \"decode.h\"\n\n#define STB_IMAGE_WRITE_IMPLEMENTATION\n#include \"stb_writer.h\"\n\nint main(int argc, char **argv) {\n\tif(argc < 5) {\n\t\tfprintf(stderr, \"Usage: %s hash width height output_file [punch]\\n\", argv[0]);\n\t\treturn 1;\n\t}\n\n\tint width, height, punch = 1;\n\tchar * hash = argv[1];\n\twidth = atoi(argv[2]);\n\theight = atoi(argv[3]);\n\tchar * output_file = argv[4];\n\n\tconst int nChannels = 4;\n\n\tif(argc == 6)\n\t\tpunch = atoi(argv[5]);\n\n\tuint8_t * bytes = decode(hash, width, height, punch, nChannels);\n\n\tif (!bytes) {\n\t\tfprintf(stderr, \"%s is not a valid blurhash, decoding failed.\\n\", hash);\n\t\treturn 1;\n\t}\n\n\tif (stbi_write_png(output_file, width, height, nChannels, bytes, nChannels * width) == 0) {\n\t\tfprintf(stderr, \"Failed to write PNG file %s\\n\", output_file);\n\t\treturn 1;\n\t}\n\n\tfreePixelArray(bytes);\n\n\tfprintf(stdout, \"Decoded blurhash successfully, wrote PNG file %s\\n\", output_file);\n\treturn 0;\n}\n"
  },
  {
    "path": "C/encode.c",
    "content": "#include \"encode.h\"\n#include \"common.h\"\n\n#include <string.h>\n\nstatic float *multiplyBasisFunction(int xComponent, int yComponent, int width, int height, uint8_t *rgb, size_t bytesPerRow);\nstatic char *encode_int(int value, int length, char *destination);\n\nstatic int encodeDC(float r, float g, float b);\nstatic int encodeAC(float r, float g, float b, float maximumValue);\n\nconst char *blurHashForPixels(int xComponents, int yComponents, int width, int height, uint8_t *rgb, size_t bytesPerRow) {\n\tstatic char buffer[2 + 4 + (9 * 9 - 1) * 2 + 1];\n\n\tif(xComponents < 1 || xComponents > 9) return NULL;\n\tif(yComponents < 1 || yComponents > 9) return NULL;\n\n\tfloat factors[yComponents][xComponents][3];\n\tmemset(factors, 0, sizeof(factors));\n\n\tfor(int y = 0; y < yComponents; y++) {\n\t\tfor(int x = 0; x < xComponents; x++) {\n\t\t\tfloat *factor = multiplyBasisFunction(x, y, width, height, rgb, bytesPerRow);\n\t\t\tfactors[y][x][0] = factor[0];\n\t\t\tfactors[y][x][1] = factor[1];\n\t\t\tfactors[y][x][2] = factor[2];\n\t\t}\n\t}\n\n\tfloat *dc = factors[0][0];\n\tfloat *ac = dc + 3;\n\tint acCount = xComponents * yComponents - 1;\n\tchar *ptr = buffer;\n\n\tint sizeFlag = (xComponents - 1) + (yComponents - 1) * 9;\n\tptr = encode_int(sizeFlag, 1, ptr);\n\n\tfloat maximumValue;\n\tif(acCount > 0) {\n\t\tfloat actualMaximumValue = 0;\n\t\tfor(int i = 0; i < acCount * 3; i++) {\n\t\t\tactualMaximumValue = fmaxf(fabsf(ac[i]), actualMaximumValue);\n\t\t}\n\n\t\tint quantisedMaximumValue = fmaxf(0, fminf(82, floorf(actualMaximumValue * 166 - 0.5)));\n\t\tmaximumValue = ((float)quantisedMaximumValue + 1) / 166;\n\t\tptr = encode_int(quantisedMaximumValue, 1, ptr);\n\t} else {\n\t\tmaximumValue = 1;\n\t\tptr = encode_int(0, 1, ptr);\n\t}\n\n\tptr = encode_int(encodeDC(dc[0], dc[1], dc[2]), 4, ptr);\n\n\tfor(int i = 0; i < acCount; i++) {\n\t\tptr = encode_int(encodeAC(ac[i * 3 + 0], ac[i * 3 + 1], ac[i * 3 + 2], maximumValue), 2, ptr);\n\t}\n\n\t*ptr = 0;\n\n\treturn buffer;\n}\n\nstatic float *multiplyBasisFunction(int xComponent, int yComponent, int width, int height, uint8_t *rgb, size_t bytesPerRow) {\n\tfloat r = 0, g = 0, b = 0;\n\tfloat normalisation = (xComponent == 0 && yComponent == 0) ? 1 : 2;\n\n\tfor(int y = 0; y < height; y++) {\n\t\tfor(int x = 0; x < width; x++) {\n\t\t\tfloat basis = cosf(M_PI * xComponent * x / width) * cosf(M_PI * yComponent * y / height);\n\t\t\tr += basis * sRGBToLinear(rgb[3 * x + 0 + y * bytesPerRow]);\n\t\t\tg += basis * sRGBToLinear(rgb[3 * x + 1 + y * bytesPerRow]);\n\t\t\tb += basis * sRGBToLinear(rgb[3 * x + 2 + y * bytesPerRow]);\n\t\t}\n\t}\n\n\tfloat scale = normalisation / (width * height);\n\n\tstatic float result[3];\n\tresult[0] = r * scale;\n\tresult[1] = g * scale;\n\tresult[2] = b * scale;\n\n\treturn result;\n}\n\n\n\nstatic int encodeDC(float r, float g, float b) {\n\tint roundedR = linearTosRGB(r);\n\tint roundedG = linearTosRGB(g);\n\tint roundedB = linearTosRGB(b);\n\treturn (roundedR << 16) + (roundedG << 8) + roundedB;\n}\n\nstatic int encodeAC(float r, float g, float b, float maximumValue) {\n\tint quantR = fmaxf(0, fminf(18, floorf(signPow(r / maximumValue, 0.5) * 9 + 9.5)));\n\tint quantG = fmaxf(0, fminf(18, floorf(signPow(g / maximumValue, 0.5) * 9 + 9.5)));\n\tint quantB = fmaxf(0, fminf(18, floorf(signPow(b / maximumValue, 0.5) * 9 + 9.5)));\n\n\treturn quantR * 19 * 19 + quantG * 19 + quantB;\n}\n\nstatic char characters[83]=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~\";\n\nstatic char *encode_int(int value, int length, char *destination) {\n\tint divisor = 1;\n\tfor(int i = 0; i < length - 1; i++) divisor *= 83;\n\n\tfor(int i = 0; i < length; i++) {\n\t\tint digit = (value / divisor) % 83;\n\t\tdivisor /= 83;\n\t\t*destination++ = characters[digit];\n\t}\n\treturn destination;\n}\n"
  },
  {
    "path": "C/encode.h",
    "content": "#ifndef __BLURHASH_ENCODE_H__\n#define __BLURHASH_ENCODE_H__\n\n#include <stdint.h>\n#include <stdlib.h>\n\nconst char *blurHashForPixels(int xComponents, int yComponents, int width, int height, uint8_t *rgb, size_t bytesPerRow);\n\n#endif\n"
  },
  {
    "path": "C/encode_stb.c",
    "content": "#include \"encode.h\"\n\n#define STB_IMAGE_IMPLEMENTATION\n#include \"stb_image.h\"\n\n#include <stdio.h>\n\nconst char *blurHashForFile(int xComponents, int yComponents,const char *filename);\n\nint main(int argc, const char **argv) {\n\tif(argc != 4) {\n\t\tfprintf(stderr, \"Usage: %s x_components y_components imagefile\\n\", argv[0]);\n\t\treturn 1;\n\t}\n\n\tint xComponents = atoi(argv[1]);\n\tint yComponents = atoi(argv[2]);\n\tif(xComponents < 1 || xComponents > 8 || yComponents < 1 || yComponents > 8) {\n\t\tfprintf(stderr, \"Component counts must be between 1 and 8.\\n\");\n\t\treturn 1;\n\t}\n\n\tconst char *hash = blurHashForFile(xComponents, yComponents, argv[3]);\n\tif(!hash) {\n\t\tfprintf(stderr, \"Failed to load image file \\\"%s\\\".\\n\", argv[3]);\n\t\treturn 1;\n\t}\n\n\tprintf(\"%s\\n\", hash);\n\n\treturn 0;\n}\n\nconst char *blurHashForFile(int xComponents, int yComponents,const char *filename) {\n\tint width, height, channels;\n\tunsigned char *data = stbi_load(filename, &width, &height, &channels, 3);\n\tif(!data) return NULL;\n\n\tconst char *hash = blurHashForPixels(xComponents, yComponents, width, height, data, width * 3);\n\n\tstbi_image_free(data);\n\n\treturn hash;\n}\n"
  },
  {
    "path": "C/stb_image.h",
    "content": "/* stb_image - v2.15 - public domain image loader - http://nothings.org/stb_image.h\n                                     no warranty implied; use at your own risk\n\n   Do this:\n      #define STB_IMAGE_IMPLEMENTATION\n   before you include this file in *one* C or C++ file to create the implementation.\n\n   // i.e. it should look like this:\n   #include ...\n   #include ...\n   #include ...\n   #define STB_IMAGE_IMPLEMENTATION\n   #include \"stb_image.h\"\n\n   You can #define STBI_ASSERT(x) before the #include to avoid using assert.h.\n   And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free\n\n\n   QUICK NOTES:\n      Primarily of interest to game developers and other people who can\n          avoid problematic images and only need the trivial interface\n\n      JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib)\n      PNG 1/2/4/8/16-bit-per-channel\n\n      TGA (not sure what subset, if a subset)\n      BMP non-1bpp, non-RLE\n      PSD (composited view only, no extra channels, 8/16 bit-per-channel)\n\n      GIF (*comp always reports as 4-channel)\n      HDR (radiance rgbE format)\n      PIC (Softimage PIC)\n      PNM (PPM and PGM binary only)\n\n      Animated GIF still needs a proper API, but here's one way to do it:\n          http://gist.github.com/urraka/685d9a6340b26b830d49\n\n      - decode from memory or through FILE (define STBI_NO_STDIO to remove code)\n      - decode from arbitrary I/O callbacks\n      - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON)\n\n   Full documentation under \"DOCUMENTATION\" below.\n\n\nLICENSE\n\n  See end of file for license information.\n\nRECENT REVISION HISTORY:\n\n      2.15  (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC\n      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs\n      2.13  (2016-12-04) experimental 16-bit API, only for PNG so far; fixes\n      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes\n      2.11  (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64\n                         RGB-format JPEG; remove white matting in PSD;\n                         allocate large structures on the stack;\n                         correct channel count for PNG & BMP\n      2.10  (2016-01-22) avoid warning introduced in 2.09\n      2.09  (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED\n      2.08  (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA\n      2.07  (2015-09-13) partial animated GIF support\n                         limited 16-bit PSD support\n                         minor bugs, code cleanup, and compiler warnings\n\n   See end of file for full revision history.\n\n\n ============================    Contributors    =========================\n\n Image formats                          Extensions, features\n    Sean Barrett (jpeg, png, bmp)          Jetro Lauha (stbi_info)\n    Nicolas Schulz (hdr, psd)              Martin \"SpartanJ\" Golini (stbi_info)\n    Jonathan Dummer (tga)                  James \"moose2000\" Brown (iPhone PNG)\n    Jean-Marc Lienher (gif)                Ben \"Disch\" Wenger (io callbacks)\n    Tom Seddon (pic)                       Omar Cornut (1/2/4-bit PNG)\n    Thatcher Ulrich (psd)                  Nicolas Guillemot (vertical flip)\n    Ken Miller (pgm, ppm)                  Richard Mitton (16-bit PSD)\n    github:urraka (animated gif)           Junggon Kim (PNM comments)\n                                           Daniel Gibson (16-bit TGA)\n                                           socks-the-fox (16-bit PNG)\n                                           Jeremy Sawicki (handle all ImageNet JPGs)\n Optimizations & bugfixes\n    Fabian \"ryg\" Giesen\n    Arseny Kapoulkine\n\n Bug & warning fixes\n    Marc LeBlanc            David Woo          Guillaume George   Martins Mozeiko\n    Christpher Lloyd        Jerry Jansson      Joseph Thomson     Phil Jordan\n    Dave Moore              Roy Eltham         Hayaki Saito       Nathan Reed\n    Won Chun                Luke Graham        Johan Duparc       Nick Verigakis\n    the Horde3D community   Thomas Ruf         Ronny Chevalier    Baldur Karlsson\n    Janez Zemva             John Bartholomew   Michal Cichon      github:rlyeh\n    Jonathan Blow           Ken Hamada         Tero Hanninen      github:romigrou\n    Laurent Gomila          Cort Stratton      Sergio Gonzalez    github:svdijk\n    Aruelien Pocheville     Thibault Reuille   Cass Everitt       github:snagar\n    Ryamond Barbiero        Paul Du Bois       Engin Manap        github:Zelex\n    Michaelangel007@github  Philipp Wiesemann  Dale Weiler        github:grim210\n    Oriol Ferrer Mesia      Josh Tobin         Matthew Gregan     github:sammyhw\n    Blazej Dariusz Roszkowski                  Gregory Mullen     github:phprus\n\n*/\n\n#ifndef STBI_INCLUDE_STB_IMAGE_H\n#define STBI_INCLUDE_STB_IMAGE_H\n\n// DOCUMENTATION\n//\n// Limitations:\n//    - no 16-bit-per-channel PNG\n//    - no 12-bit-per-channel JPEG\n//    - no JPEGs with arithmetic coding\n//    - no 1-bit BMP\n//    - GIF always returns *comp=4\n//\n// Basic usage (see HDR discussion below for HDR usage):\n//    int x,y,n;\n//    unsigned char *data = stbi_load(filename, &x, &y, &n, 0);\n//    // ... process data if not NULL ...\n//    // ... x = width, y = height, n = # 8-bit components per pixel ...\n//    // ... replace '0' with '1'..'4' to force that many components per pixel\n//    // ... but 'n' will always be the number that it would have been if you said 0\n//    stbi_image_free(data)\n//\n// Standard parameters:\n//    int *x                 -- outputs image width in pixels\n//    int *y                 -- outputs image height in pixels\n//    int *channels_in_file  -- outputs # of image components in image file\n//    int desired_channels   -- if non-zero, # of image components requested in result\n//\n// The return value from an image loader is an 'unsigned char *' which points\n// to the pixel data, or NULL on an allocation failure or if the image is\n// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels,\n// with each pixel consisting of N interleaved 8-bit components; the first\n// pixel pointed to is top-left-most in the image. There is no padding between\n// image scanlines or between pixels, regardless of format. The number of\n// components N is 'req_comp' if req_comp is non-zero, or *comp otherwise.\n// If req_comp is non-zero, *comp has the number of components that _would_\n// have been output otherwise. E.g. if you set req_comp to 4, you will always\n// get RGBA output, but you can check *comp to see if it's trivially opaque\n// because e.g. there were only 3 channels in the source image.\n//\n// An output image with N components has the following components interleaved\n// in this order in each pixel:\n//\n//     N=#comp     components\n//       1           grey\n//       2           grey, alpha\n//       3           red, green, blue\n//       4           red, green, blue, alpha\n//\n// If image loading fails for any reason, the return value will be NULL,\n// and *x, *y, *comp will be unchanged. The function stbi_failure_reason()\n// can be queried for an extremely brief, end-user unfriendly explanation\n// of why the load failed. Define STBI_NO_FAILURE_STRINGS to avoid\n// compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly\n// more user-friendly ones.\n//\n// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized.\n//\n// ===========================================================================\n//\n// Philosophy\n//\n// stb libraries are designed with the following priorities:\n//\n//    1. easy to use\n//    2. easy to maintain\n//    3. good performance\n//\n// Sometimes I let \"good performance\" creep up in priority over \"easy to maintain\",\n// and for best performance I may provide less-easy-to-use APIs that give higher\n// performance, in addition to the easy to use ones. Nevertheless, it's important\n// to keep in mind that from the standpoint of you, a client of this library,\n// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all.\n//\n// Some secondary priorities arise directly from the first two, some of which\n// make more explicit reasons why performance can't be emphasized.\n//\n//    - Portable (\"ease of use\")\n//    - Small source code footprint (\"easy to maintain\")\n//    - No dependencies (\"ease of use\")\n//\n// ===========================================================================\n//\n// I/O callbacks\n//\n// I/O callbacks allow you to read from arbitrary sources, like packaged\n// files or some other source. Data read from callbacks are processed\n// through a small internal buffer (currently 128 bytes) to try to reduce\n// overhead.\n//\n// The three functions you must define are \"read\" (reads some bytes of data),\n// \"skip\" (skips some bytes of data), \"eof\" (reports if the stream is at the end).\n//\n// ===========================================================================\n//\n// SIMD support\n//\n// The JPEG decoder will try to automatically use SIMD kernels on x86 when\n// supported by the compiler. For ARM Neon support, you must explicitly\n// request it.\n//\n// (The old do-it-yourself SIMD API is no longer supported in the current\n// code.)\n//\n// On x86, SSE2 will automatically be used when available based on a run-time\n// test; if not, the generic C versions are used as a fall-back. On ARM targets,\n// the typical path is to have separate builds for NEON and non-NEON devices\n// (at least this is true for iOS and Android). Therefore, the NEON support is\n// toggled by a build flag: define STBI_NEON to get NEON loops.\n//\n// If for some reason you do not want to use any of SIMD code, or if\n// you have issues compiling it, you can disable it entirely by\n// defining STBI_NO_SIMD.\n//\n// ===========================================================================\n//\n// HDR image support   (disable by defining STBI_NO_HDR)\n//\n// stb_image now supports loading HDR images in general, and currently\n// the Radiance .HDR file format, although the support is provided\n// generically. You can still load any file through the existing interface;\n// if you attempt to load an HDR file, it will be automatically remapped to\n// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1;\n// both of these constants can be reconfigured through this interface:\n//\n//     stbi_hdr_to_ldr_gamma(2.2f);\n//     stbi_hdr_to_ldr_scale(1.0f);\n//\n// (note, do not use _inverse_ constants; stbi_image will invert them\n// appropriately).\n//\n// Additionally, there is a new, parallel interface for loading files as\n// (linear) floats to preserve the full dynamic range:\n//\n//    float *data = stbi_loadf(filename, &x, &y, &n, 0);\n//\n// If you load LDR images through this interface, those images will\n// be promoted to floating point values, run through the inverse of\n// constants corresponding to the above:\n//\n//     stbi_ldr_to_hdr_scale(1.0f);\n//     stbi_ldr_to_hdr_gamma(2.2f);\n//\n// Finally, given a filename (or an open file or memory block--see header\n// file for details) containing image data, you can query for the \"most\n// appropriate\" interface to use (that is, whether the image is HDR or\n// not), using:\n//\n//     stbi_is_hdr(char *filename);\n//\n// ===========================================================================\n//\n// iPhone PNG support:\n//\n// By default we convert iphone-formatted PNGs back to RGB, even though\n// they are internally encoded differently. You can disable this conversion\n// by by calling stbi_convert_iphone_png_to_rgb(0), in which case\n// you will always just get the native iphone \"format\" through (which\n// is BGR stored in RGB).\n//\n// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per\n// pixel to remove any premultiplied alpha *only* if the image file explicitly\n// says there's premultiplied data (currently only happens in iPhone images,\n// and only if iPhone convert-to-rgb processing is on).\n//\n// ===========================================================================\n//\n// ADDITIONAL CONFIGURATION\n//\n//  - You can suppress implementation of any of the decoders to reduce\n//    your code footprint by #defining one or more of the following\n//    symbols before creating the implementation.\n//\n//        STBI_NO_JPEG\n//        STBI_NO_PNG\n//        STBI_NO_BMP\n//        STBI_NO_PSD\n//        STBI_NO_TGA\n//        STBI_NO_GIF\n//        STBI_NO_HDR\n//        STBI_NO_PIC\n//        STBI_NO_PNM   (.ppm and .pgm)\n//\n//  - You can request *only* certain decoders and suppress all other ones\n//    (this will be more forward-compatible, as addition of new decoders\n//    doesn't require you to disable them explicitly):\n//\n//        STBI_ONLY_JPEG\n//        STBI_ONLY_PNG\n//        STBI_ONLY_BMP\n//        STBI_ONLY_PSD\n//        STBI_ONLY_TGA\n//        STBI_ONLY_GIF\n//        STBI_ONLY_HDR\n//        STBI_ONLY_PIC\n//        STBI_ONLY_PNM   (.ppm and .pgm)\n//\n//   - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still\n//     want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB\n//\n\n\n#ifndef STBI_NO_STDIO\n#include <stdio.h>\n#endif // STBI_NO_STDIO\n\n#define STBI_VERSION 1\n\nenum\n{\n   STBI_default = 0, // only used for req_comp\n\n   STBI_grey       = 1,\n   STBI_grey_alpha = 2,\n   STBI_rgb        = 3,\n   STBI_rgb_alpha  = 4\n};\n\ntypedef unsigned char stbi_uc;\ntypedef unsigned short stbi_us;\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef STB_IMAGE_STATIC\n#define STBIDEF static\n#else\n#define STBIDEF extern\n#endif\n\n//////////////////////////////////////////////////////////////////////////////\n//\n// PRIMARY API - works on images of any type\n//\n\n//\n// load image by filename, open file, or memory buffer\n//\n\ntypedef struct\n{\n   int      (*read)  (void *user,char *data,int size);   // fill 'data' with 'size' bytes.  return number of bytes actually read\n   void     (*skip)  (void *user,int n);                 // skip the next 'n' bytes, or 'unget' the last -n bytes if negative\n   int      (*eof)   (void *user);                       // returns nonzero if we are at end of file/data\n} stbi_io_callbacks;\n\n////////////////////////////////////\n//\n// 8-bits-per-channel interface\n//\n\nSTBIDEF stbi_uc *stbi_load               (char              const *filename,           int *x, int *y, int *channels_in_file, int desired_channels);\nSTBIDEF stbi_uc *stbi_load_from_memory   (stbi_uc           const *buffer, int len   , int *x, int *y, int *channels_in_file, int desired_channels);\nSTBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk  , void *user, int *x, int *y, int *channels_in_file, int desired_channels);\n\n#ifndef STBI_NO_STDIO\nSTBIDEF stbi_uc *stbi_load_from_file   (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);\n// for stbi_load_from_file, file pointer is left pointing immediately after image\n#endif\n\n////////////////////////////////////\n//\n// 16-bits-per-channel interface\n//\n\nSTBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *channels_in_file, int desired_channels);\n#ifndef STBI_NO_STDIO\nSTBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);\n#endif\n// @TODO the other variants\n\n////////////////////////////////////\n//\n// float-per-channel interface\n//\n#ifndef STBI_NO_LINEAR\n   STBIDEF float *stbi_loadf                 (char const *filename,           int *x, int *y, int *channels_in_file, int desired_channels);\n   STBIDEF float *stbi_loadf_from_memory     (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels);\n   STBIDEF float *stbi_loadf_from_callbacks  (stbi_io_callbacks const *clbk, void *user, int *x, int *y,  int *channels_in_file, int desired_channels);\n\n   #ifndef STBI_NO_STDIO\n   STBIDEF float *stbi_loadf_from_file  (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels);\n   #endif\n#endif\n\n#ifndef STBI_NO_HDR\n   STBIDEF void   stbi_hdr_to_ldr_gamma(float gamma);\n   STBIDEF void   stbi_hdr_to_ldr_scale(float scale);\n#endif // STBI_NO_HDR\n\n#ifndef STBI_NO_LINEAR\n   STBIDEF void   stbi_ldr_to_hdr_gamma(float gamma);\n   STBIDEF void   stbi_ldr_to_hdr_scale(float scale);\n#endif // STBI_NO_LINEAR\n\n// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR\nSTBIDEF int    stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user);\nSTBIDEF int    stbi_is_hdr_from_memory(stbi_uc const *buffer, int len);\n#ifndef STBI_NO_STDIO\nSTBIDEF int      stbi_is_hdr          (char const *filename);\nSTBIDEF int      stbi_is_hdr_from_file(FILE *f);\n#endif // STBI_NO_STDIO\n\n\n// get a VERY brief reason for failure\n// NOT THREADSAFE\nSTBIDEF const char *stbi_failure_reason  (void);\n\n// free the loaded image -- this is just free()\nSTBIDEF void     stbi_image_free      (void *retval_from_stbi_load);\n\n// get image dimensions & components without fully decoding\nSTBIDEF int      stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp);\nSTBIDEF int      stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp);\n\n#ifndef STBI_NO_STDIO\nSTBIDEF int      stbi_info            (char const *filename,     int *x, int *y, int *comp);\nSTBIDEF int      stbi_info_from_file  (FILE *f,                  int *x, int *y, int *comp);\n\n#endif\n\n\n\n// for image formats that explicitly notate that they have premultiplied alpha,\n// we just return the colors as stored in the file. set this flag to force\n// unpremultiplication. results are undefined if the unpremultiply overflow.\nSTBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);\n\n// indicate whether we should process iphone images back to canonical format,\n// or just pass them through \"as-is\"\nSTBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert);\n\n// flip the image vertically, so the first pixel in the output array is the bottom left\nSTBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip);\n\n// ZLIB client - used by PNG, available for other purposes\n\nSTBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);\nSTBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header);\nSTBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen);\nSTBIDEF int   stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);\n\nSTBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen);\nSTBIDEF int   stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n//\n//\n////   end header file   /////////////////////////////////////////////////////\n#endif // STBI_INCLUDE_STB_IMAGE_H\n\n#ifdef STB_IMAGE_IMPLEMENTATION\n\n#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \\\n  || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \\\n  || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \\\n  || defined(STBI_ONLY_ZLIB)\n   #ifndef STBI_ONLY_JPEG\n   #define STBI_NO_JPEG\n   #endif\n   #ifndef STBI_ONLY_PNG\n   #define STBI_NO_PNG\n   #endif\n   #ifndef STBI_ONLY_BMP\n   #define STBI_NO_BMP\n   #endif\n   #ifndef STBI_ONLY_PSD\n   #define STBI_NO_PSD\n   #endif\n   #ifndef STBI_ONLY_TGA\n   #define STBI_NO_TGA\n   #endif\n   #ifndef STBI_ONLY_GIF\n   #define STBI_NO_GIF\n   #endif\n   #ifndef STBI_ONLY_HDR\n   #define STBI_NO_HDR\n   #endif\n   #ifndef STBI_ONLY_PIC\n   #define STBI_NO_PIC\n   #endif\n   #ifndef STBI_ONLY_PNM\n   #define STBI_NO_PNM\n   #endif\n#endif\n\n#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB)\n#define STBI_NO_ZLIB\n#endif\n\n\n#include <stdarg.h>\n#include <stddef.h> // ptrdiff_t on osx\n#include <stdlib.h>\n#include <string.h>\n#include <limits.h>\n\n#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR)\n#include <math.h>  // ldexp\n#endif\n\n#ifndef STBI_NO_STDIO\n#include <stdio.h>\n#endif\n\n#ifndef STBI_ASSERT\n#include <assert.h>\n#define STBI_ASSERT(x) assert(x)\n#endif\n\n\n#ifndef _MSC_VER\n   #ifdef __cplusplus\n   #define stbi_inline inline\n   #else\n   #define stbi_inline\n   #endif\n#else\n   #define stbi_inline __forceinline\n#endif\n\n\n#ifdef _MSC_VER\ntypedef unsigned short stbi__uint16;\ntypedef   signed short stbi__int16;\ntypedef unsigned int   stbi__uint32;\ntypedef   signed int   stbi__int32;\n#else\n#include <stdint.h>\ntypedef uint16_t stbi__uint16;\ntypedef int16_t  stbi__int16;\ntypedef uint32_t stbi__uint32;\ntypedef int32_t  stbi__int32;\n#endif\n\n// should produce compiler error if size is wrong\ntypedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1];\n\n#ifdef _MSC_VER\n#define STBI_NOTUSED(v)  (void)(v)\n#else\n#define STBI_NOTUSED(v)  (void)sizeof(v)\n#endif\n\n#ifdef _MSC_VER\n#define STBI_HAS_LROTL\n#endif\n\n#ifdef STBI_HAS_LROTL\n   #define stbi_lrot(x,y)  _lrotl(x,y)\n#else\n   #define stbi_lrot(x,y)  (((x) << (y)) | ((x) >> (32 - (y))))\n#endif\n\n#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED))\n// ok\n#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED)\n// ok\n#else\n#error \"Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED).\"\n#endif\n\n#ifndef STBI_MALLOC\n#define STBI_MALLOC(sz)           malloc(sz)\n#define STBI_REALLOC(p,newsz)     realloc(p,newsz)\n#define STBI_FREE(p)              free(p)\n#endif\n\n#ifndef STBI_REALLOC_SIZED\n#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz)\n#endif\n\n// x86/x64 detection\n#if defined(__x86_64__) || defined(_M_X64)\n#define STBI__X64_TARGET\n#elif defined(__i386) || defined(_M_IX86)\n#define STBI__X86_TARGET\n#endif\n\n#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD)\n// gcc doesn't support sse2 intrinsics unless you compile with -msse2,\n// which in turn means it gets to use SSE2 everywhere. This is unfortunate,\n// but previous attempts to provide the SSE2 functions with runtime\n// detection caused numerous issues. The way architecture extensions are\n// exposed in GCC/Clang is, sadly, not really suited for one-file libs.\n// New behavior: if compiled with -msse2, we use SSE2 without any\n// detection; if not, we don't use it at all.\n#define STBI_NO_SIMD\n#endif\n\n#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD)\n// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET\n//\n// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the\n// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant.\n// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not\n// simultaneously enabling \"-mstackrealign\".\n//\n// See https://github.com/nothings/stb/issues/81 for more information.\n//\n// So default to no SSE2 on 32-bit MinGW. If you've read this far and added\n// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2.\n#define STBI_NO_SIMD\n#endif\n\n#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET))\n#define STBI_SSE2\n#include <emmintrin.h>\n\n#ifdef _MSC_VER\n\n#if _MSC_VER >= 1400  // not VC6\n#include <intrin.h> // __cpuid\nstatic int stbi__cpuid3(void)\n{\n   int info[4];\n   __cpuid(info,1);\n   return info[3];\n}\n#else\nstatic int stbi__cpuid3(void)\n{\n   int res;\n   __asm {\n      mov  eax,1\n      cpuid\n      mov  res,edx\n   }\n   return res;\n}\n#endif\n\n#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name\n\nstatic int stbi__sse2_available()\n{\n   int info3 = stbi__cpuid3();\n   return ((info3 >> 26) & 1) != 0;\n}\n#else // assume GCC-style if not VC++\n#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))\n\nstatic int stbi__sse2_available()\n{\n   // If we're even attempting to compile this on GCC/Clang, that means\n   // -msse2 is on, which means the compiler is allowed to use SSE2\n   // instructions at will, and so are we.\n   return 1;\n}\n#endif\n#endif\n\n// ARM NEON\n#if defined(STBI_NO_SIMD) && defined(STBI_NEON)\n#undef STBI_NEON\n#endif\n\n#ifdef STBI_NEON\n#include <arm_neon.h>\n// assume GCC or Clang on ARM targets\n#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16)))\n#endif\n\n#ifndef STBI_SIMD_ALIGN\n#define STBI_SIMD_ALIGN(type, name) type name\n#endif\n\n///////////////////////////////////////////////\n//\n//  stbi__context struct and start_xxx functions\n\n// stbi__context structure is our basic context used by all images, so it\n// contains all the IO context, plus some basic image information\ntypedef struct\n{\n   stbi__uint32 img_x, img_y;\n   int img_n, img_out_n;\n\n   stbi_io_callbacks io;\n   void *io_user_data;\n\n   int read_from_callbacks;\n   int buflen;\n   stbi_uc buffer_start[128];\n\n   stbi_uc *img_buffer, *img_buffer_end;\n   stbi_uc *img_buffer_original, *img_buffer_original_end;\n} stbi__context;\n\n\nstatic void stbi__refill_buffer(stbi__context *s);\n\n// initialize a memory-decode context\nstatic void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len)\n{\n   s->io.read = NULL;\n   s->read_from_callbacks = 0;\n   s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer;\n   s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len;\n}\n\n// initialize a callback-based context\nstatic void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user)\n{\n   s->io = *c;\n   s->io_user_data = user;\n   s->buflen = sizeof(s->buffer_start);\n   s->read_from_callbacks = 1;\n   s->img_buffer_original = s->buffer_start;\n   stbi__refill_buffer(s);\n   s->img_buffer_original_end = s->img_buffer_end;\n}\n\n#ifndef STBI_NO_STDIO\n\nstatic int stbi__stdio_read(void *user, char *data, int size)\n{\n   return (int) fread(data,1,size,(FILE*) user);\n}\n\nstatic void stbi__stdio_skip(void *user, int n)\n{\n   fseek((FILE*) user, n, SEEK_CUR);\n}\n\nstatic int stbi__stdio_eof(void *user)\n{\n   return feof((FILE*) user);\n}\n\nstatic stbi_io_callbacks stbi__stdio_callbacks =\n{\n   stbi__stdio_read,\n   stbi__stdio_skip,\n   stbi__stdio_eof,\n};\n\nstatic void stbi__start_file(stbi__context *s, FILE *f)\n{\n   stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f);\n}\n\n//static void stop_file(stbi__context *s) { }\n\n#endif // !STBI_NO_STDIO\n\nstatic void stbi__rewind(stbi__context *s)\n{\n   // conceptually rewind SHOULD rewind to the beginning of the stream,\n   // but we just rewind to the beginning of the initial buffer, because\n   // we only use it after doing 'test', which only ever looks at at most 92 bytes\n   s->img_buffer = s->img_buffer_original;\n   s->img_buffer_end = s->img_buffer_original_end;\n}\n\nenum\n{\n   STBI_ORDER_RGB,\n   STBI_ORDER_BGR\n};\n\ntypedef struct\n{\n   int bits_per_channel;\n   int num_channels;\n   int channel_order;\n} stbi__result_info;\n\n#ifndef STBI_NO_JPEG\nstatic int      stbi__jpeg_test(stbi__context *s);\nstatic void    *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_PNG\nstatic int      stbi__png_test(stbi__context *s);\nstatic void    *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__png_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_BMP\nstatic int      stbi__bmp_test(stbi__context *s);\nstatic void    *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_TGA\nstatic int      stbi__tga_test(stbi__context *s);\nstatic void    *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__tga_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_PSD\nstatic int      stbi__psd_test(stbi__context *s);\nstatic void    *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc);\nstatic int      stbi__psd_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_HDR\nstatic int      stbi__hdr_test(stbi__context *s);\nstatic float   *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_PIC\nstatic int      stbi__pic_test(stbi__context *s);\nstatic void    *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__pic_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_GIF\nstatic int      stbi__gif_test(stbi__context *s);\nstatic void    *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__gif_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n#ifndef STBI_NO_PNM\nstatic int      stbi__pnm_test(stbi__context *s);\nstatic void    *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);\nstatic int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);\n#endif\n\n// this is not threadsafe\nstatic const char *stbi__g_failure_reason;\n\nSTBIDEF const char *stbi_failure_reason(void)\n{\n   return stbi__g_failure_reason;\n}\n\nstatic int stbi__err(const char *str)\n{\n   stbi__g_failure_reason = str;\n   return 0;\n}\n\nstatic void *stbi__malloc(size_t size)\n{\n    return STBI_MALLOC(size);\n}\n\n// stb_image uses ints pervasively, including for offset calculations.\n// therefore the largest decoded image size we can support with the\n// current code, even on 64-bit targets, is INT_MAX. this is not a\n// significant limitation for the intended use case.\n//\n// we do, however, need to make sure our size calculations don't\n// overflow. hence a few helper functions for size calculations that\n// multiply integers together, making sure that they're non-negative\n// and no overflow occurs.\n\n// return 1 if the sum is valid, 0 on overflow.\n// negative terms are considered invalid.\nstatic int stbi__addsizes_valid(int a, int b)\n{\n   if (b < 0) return 0;\n   // now 0 <= b <= INT_MAX, hence also\n   // 0 <= INT_MAX - b <= INTMAX.\n   // And \"a + b <= INT_MAX\" (which might overflow) is the\n   // same as a <= INT_MAX - b (no overflow)\n   return a <= INT_MAX - b;\n}\n\n// returns 1 if the product is valid, 0 on overflow.\n// negative factors are considered invalid.\nstatic int stbi__mul2sizes_valid(int a, int b)\n{\n   if (a < 0 || b < 0) return 0;\n   if (b == 0) return 1; // mul-by-0 is always safe\n   // portable way to check for no overflows in a*b\n   return a <= INT_MAX/b;\n}\n\n// returns 1 if \"a*b + add\" has no negative terms/factors and doesn't overflow\nstatic int stbi__mad2sizes_valid(int a, int b, int add)\n{\n   return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add);\n}\n\n// returns 1 if \"a*b*c + add\" has no negative terms/factors and doesn't overflow\nstatic int stbi__mad3sizes_valid(int a, int b, int c, int add)\n{\n   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&\n      stbi__addsizes_valid(a*b*c, add);\n}\n\n// returns 1 if \"a*b*c*d + add\" has no negative terms/factors and doesn't overflow\nstatic int stbi__mad4sizes_valid(int a, int b, int c, int d, int add)\n{\n   return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) &&\n      stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add);\n}\n\n// mallocs with size overflow checking\nstatic void *stbi__malloc_mad2(int a, int b, int add)\n{\n   if (!stbi__mad2sizes_valid(a, b, add)) return NULL;\n   return stbi__malloc(a*b + add);\n}\n\nstatic void *stbi__malloc_mad3(int a, int b, int c, int add)\n{\n   if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL;\n   return stbi__malloc(a*b*c + add);\n}\n\nstatic void *stbi__malloc_mad4(int a, int b, int c, int d, int add)\n{\n   if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL;\n   return stbi__malloc(a*b*c*d + add);\n}\n\n// stbi__err - error\n// stbi__errpf - error returning pointer to float\n// stbi__errpuc - error returning pointer to unsigned char\n\n#ifdef STBI_NO_FAILURE_STRINGS\n   #define stbi__err(x,y)  0\n#elif defined(STBI_FAILURE_USERMSG)\n   #define stbi__err(x,y)  stbi__err(y)\n#else\n   #define stbi__err(x,y)  stbi__err(x)\n#endif\n\n#define stbi__errpf(x,y)   ((float *)(size_t) (stbi__err(x,y)?NULL:NULL))\n#define stbi__errpuc(x,y)  ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL))\n\nSTBIDEF void stbi_image_free(void *retval_from_stbi_load)\n{\n   STBI_FREE(retval_from_stbi_load);\n}\n\n#ifndef STBI_NO_LINEAR\nstatic float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp);\n#endif\n\n#ifndef STBI_NO_HDR\nstatic stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp);\n#endif\n\nstatic int stbi__vertically_flip_on_load = 0;\n\nSTBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip)\n{\n    stbi__vertically_flip_on_load = flag_true_if_should_flip;\n}\n\nstatic void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)\n{\n   memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields\n   ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed\n   ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order\n   ri->num_channels = 0;\n\n   #ifndef STBI_NO_JPEG\n   if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri);\n   #endif\n   #ifndef STBI_NO_PNG\n   if (stbi__png_test(s))  return stbi__png_load(s,x,y,comp,req_comp, ri);\n   #endif\n   #ifndef STBI_NO_BMP\n   if (stbi__bmp_test(s))  return stbi__bmp_load(s,x,y,comp,req_comp, ri);\n   #endif\n   #ifndef STBI_NO_GIF\n   if (stbi__gif_test(s))  return stbi__gif_load(s,x,y,comp,req_comp, ri);\n   #endif\n   #ifndef STBI_NO_PSD\n   if (stbi__psd_test(s))  return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc);\n   #endif\n   #ifndef STBI_NO_PIC\n   if (stbi__pic_test(s))  return stbi__pic_load(s,x,y,comp,req_comp, ri);\n   #endif\n   #ifndef STBI_NO_PNM\n   if (stbi__pnm_test(s))  return stbi__pnm_load(s,x,y,comp,req_comp, ri);\n   #endif\n\n   #ifndef STBI_NO_HDR\n   if (stbi__hdr_test(s)) {\n      float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri);\n      return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp);\n   }\n   #endif\n\n   #ifndef STBI_NO_TGA\n   // test tga last because it's a crappy test!\n   if (stbi__tga_test(s))\n      return stbi__tga_load(s,x,y,comp,req_comp, ri);\n   #endif\n\n   return stbi__errpuc(\"unknown image type\", \"Image not of any known type, or corrupt\");\n}\n\nstatic stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels)\n{\n   int i;\n   int img_len = w * h * channels;\n   stbi_uc *reduced;\n\n   reduced = (stbi_uc *) stbi__malloc(img_len);\n   if (reduced == NULL) return stbi__errpuc(\"outofmem\", \"Out of memory\");\n\n   for (i = 0; i < img_len; ++i)\n      reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling\n\n   STBI_FREE(orig);\n   return reduced;\n}\n\nstatic stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels)\n{\n   int i;\n   int img_len = w * h * channels;\n   stbi__uint16 *enlarged;\n\n   enlarged = (stbi__uint16 *) stbi__malloc(img_len*2);\n   if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc(\"outofmem\", \"Out of memory\");\n\n   for (i = 0; i < img_len; ++i)\n      enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff\n\n   STBI_FREE(orig);\n   return enlarged;\n}\n\nstatic unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__result_info ri;\n   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8);\n\n   if (result == NULL)\n      return NULL;\n\n   if (ri.bits_per_channel != 8) {\n      STBI_ASSERT(ri.bits_per_channel == 16);\n      result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp);\n      ri.bits_per_channel = 8;\n   }\n\n   // @TODO: move stbi__convert_format to here\n\n   if (stbi__vertically_flip_on_load) {\n      int w = *x, h = *y;\n      int channels = req_comp ? req_comp : *comp;\n      int row,col,z;\n      stbi_uc *image = (stbi_uc *) result;\n\n      // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once\n      for (row = 0; row < (h>>1); row++) {\n         for (col = 0; col < w; col++) {\n            for (z = 0; z < channels; z++) {\n               stbi_uc temp = image[(row * w + col) * channels + z];\n               image[(row * w + col) * channels + z] = image[((h - row - 1) * w + col) * channels + z];\n               image[((h - row - 1) * w + col) * channels + z] = temp;\n            }\n         }\n      }\n   }\n\n   return (unsigned char *) result;\n}\n\nstatic stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__result_info ri;\n   void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16);\n\n   if (result == NULL)\n      return NULL;\n\n   if (ri.bits_per_channel != 16) {\n      STBI_ASSERT(ri.bits_per_channel == 8);\n      result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp);\n      ri.bits_per_channel = 16;\n   }\n\n   // @TODO: move stbi__convert_format16 to here\n   // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision\n\n   if (stbi__vertically_flip_on_load) {\n      int w = *x, h = *y;\n      int channels = req_comp ? req_comp : *comp;\n      int row,col,z;\n      stbi__uint16 *image = (stbi__uint16 *) result;\n\n      // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once\n      for (row = 0; row < (h>>1); row++) {\n         for (col = 0; col < w; col++) {\n            for (z = 0; z < channels; z++) {\n               stbi__uint16 temp = image[(row * w + col) * channels + z];\n               image[(row * w + col) * channels + z] = image[((h - row - 1) * w + col) * channels + z];\n               image[((h - row - 1) * w + col) * channels + z] = temp;\n            }\n         }\n      }\n   }\n\n   return (stbi__uint16 *) result;\n}\n\n#ifndef STBI_NO_HDR\nstatic void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp)\n{\n   if (stbi__vertically_flip_on_load && result != NULL) {\n      int w = *x, h = *y;\n      int depth = req_comp ? req_comp : *comp;\n      int row,col,z;\n      float temp;\n\n      // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once\n      for (row = 0; row < (h>>1); row++) {\n         for (col = 0; col < w; col++) {\n            for (z = 0; z < depth; z++) {\n               temp = result[(row * w + col) * depth + z];\n               result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z];\n               result[((h - row - 1) * w + col) * depth + z] = temp;\n            }\n         }\n      }\n   }\n}\n#endif\n\n#ifndef STBI_NO_STDIO\n\nstatic FILE *stbi__fopen(char const *filename, char const *mode)\n{\n   FILE *f;\n#if defined(_MSC_VER) && _MSC_VER >= 1400\n   if (0 != fopen_s(&f, filename, mode))\n      f=0;\n#else\n   f = fopen(filename, mode);\n#endif\n   return f;\n}\n\n\nSTBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp)\n{\n   FILE *f = stbi__fopen(filename, \"rb\");\n   unsigned char *result;\n   if (!f) return stbi__errpuc(\"can't fopen\", \"Unable to open file\");\n   result = stbi_load_from_file(f,x,y,comp,req_comp);\n   fclose(f);\n   return result;\n}\n\nSTBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)\n{\n   unsigned char *result;\n   stbi__context s;\n   stbi__start_file(&s,f);\n   result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);\n   if (result) {\n      // need to 'unget' all the characters in the IO buffer\n      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);\n   }\n   return result;\n}\n\nSTBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__uint16 *result;\n   stbi__context s;\n   stbi__start_file(&s,f);\n   result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp);\n   if (result) {\n      // need to 'unget' all the characters in the IO buffer\n      fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR);\n   }\n   return result;\n}\n\nSTBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp)\n{\n   FILE *f = stbi__fopen(filename, \"rb\");\n   stbi__uint16 *result;\n   if (!f) return (stbi_us *) stbi__errpuc(\"can't fopen\", \"Unable to open file\");\n   result = stbi_load_from_file_16(f,x,y,comp,req_comp);\n   fclose(f);\n   return result;\n}\n\n\n#endif //!STBI_NO_STDIO\n\nSTBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__context s;\n   stbi__start_mem(&s,buffer,len);\n   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);\n}\n\nSTBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__context s;\n   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);\n   return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp);\n}\n\n#ifndef STBI_NO_LINEAR\nstatic float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp)\n{\n   unsigned char *data;\n   #ifndef STBI_NO_HDR\n   if (stbi__hdr_test(s)) {\n      stbi__result_info ri;\n      float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri);\n      if (hdr_data)\n         stbi__float_postprocess(hdr_data,x,y,comp,req_comp);\n      return hdr_data;\n   }\n   #endif\n   data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp);\n   if (data)\n      return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp);\n   return stbi__errpf(\"unknown image type\", \"Image not of any known type, or corrupt\");\n}\n\nSTBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__context s;\n   stbi__start_mem(&s,buffer,len);\n   return stbi__loadf_main(&s,x,y,comp,req_comp);\n}\n\nSTBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__context s;\n   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);\n   return stbi__loadf_main(&s,x,y,comp,req_comp);\n}\n\n#ifndef STBI_NO_STDIO\nSTBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp)\n{\n   float *result;\n   FILE *f = stbi__fopen(filename, \"rb\");\n   if (!f) return stbi__errpf(\"can't fopen\", \"Unable to open file\");\n   result = stbi_loadf_from_file(f,x,y,comp,req_comp);\n   fclose(f);\n   return result;\n}\n\nSTBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp)\n{\n   stbi__context s;\n   stbi__start_file(&s,f);\n   return stbi__loadf_main(&s,x,y,comp,req_comp);\n}\n#endif // !STBI_NO_STDIO\n\n#endif // !STBI_NO_LINEAR\n\n// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is\n// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always\n// reports false!\n\nSTBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len)\n{\n   #ifndef STBI_NO_HDR\n   stbi__context s;\n   stbi__start_mem(&s,buffer,len);\n   return stbi__hdr_test(&s);\n   #else\n   STBI_NOTUSED(buffer);\n   STBI_NOTUSED(len);\n   return 0;\n   #endif\n}\n\n#ifndef STBI_NO_STDIO\nSTBIDEF int      stbi_is_hdr          (char const *filename)\n{\n   FILE *f = stbi__fopen(filename, \"rb\");\n   int result=0;\n   if (f) {\n      result = stbi_is_hdr_from_file(f);\n      fclose(f);\n   }\n   return result;\n}\n\nSTBIDEF int      stbi_is_hdr_from_file(FILE *f)\n{\n   #ifndef STBI_NO_HDR\n   stbi__context s;\n   stbi__start_file(&s,f);\n   return stbi__hdr_test(&s);\n   #else\n   STBI_NOTUSED(f);\n   return 0;\n   #endif\n}\n#endif // !STBI_NO_STDIO\n\nSTBIDEF int      stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user)\n{\n   #ifndef STBI_NO_HDR\n   stbi__context s;\n   stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);\n   return stbi__hdr_test(&s);\n   #else\n   STBI_NOTUSED(clbk);\n   STBI_NOTUSED(user);\n   return 0;\n   #endif\n}\n\n#ifndef STBI_NO_LINEAR\nstatic float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f;\n\nSTBIDEF void   stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; }\nSTBIDEF void   stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; }\n#endif\n\nstatic float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f;\n\nSTBIDEF void   stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; }\nSTBIDEF void   stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; }\n\n\n//////////////////////////////////////////////////////////////////////////////\n//\n// Common code used by all image loaders\n//\n\nenum\n{\n   STBI__SCAN_load=0,\n   STBI__SCAN_type,\n   STBI__SCAN_header\n};\n\nstatic void stbi__refill_buffer(stbi__context *s)\n{\n   int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen);\n   if (n == 0) {\n      // at end of file, treat same as if from memory, but need to handle case\n      // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file\n      s->read_from_callbacks = 0;\n      s->img_buffer = s->buffer_start;\n      s->img_buffer_end = s->buffer_start+1;\n      *s->img_buffer = 0;\n   } else {\n      s->img_buffer = s->buffer_start;\n      s->img_buffer_end = s->buffer_start + n;\n   }\n}\n\nstbi_inline static stbi_uc stbi__get8(stbi__context *s)\n{\n   if (s->img_buffer < s->img_buffer_end)\n      return *s->img_buffer++;\n   if (s->read_from_callbacks) {\n      stbi__refill_buffer(s);\n      return *s->img_buffer++;\n   }\n   return 0;\n}\n\nstbi_inline static int stbi__at_eof(stbi__context *s)\n{\n   if (s->io.read) {\n      if (!(s->io.eof)(s->io_user_data)) return 0;\n      // if feof() is true, check if buffer = end\n      // special case: we've only got the special 0 character at the end\n      if (s->read_from_callbacks == 0) return 1;\n   }\n\n   return s->img_buffer >= s->img_buffer_end;\n}\n\nstatic void stbi__skip(stbi__context *s, int n)\n{\n   if (n < 0) {\n      s->img_buffer = s->img_buffer_end;\n      return;\n   }\n   if (s->io.read) {\n      int blen = (int) (s->img_buffer_end - s->img_buffer);\n      if (blen < n) {\n         s->img_buffer = s->img_buffer_end;\n         (s->io.skip)(s->io_user_data, n - blen);\n         return;\n      }\n   }\n   s->img_buffer += n;\n}\n\nstatic int stbi__getn(stbi__context *s, stbi_uc *buffer, int n)\n{\n   if (s->io.read) {\n      int blen = (int) (s->img_buffer_end - s->img_buffer);\n      if (blen < n) {\n         int res, count;\n\n         memcpy(buffer, s->img_buffer, blen);\n\n         count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen);\n         res = (count == (n-blen));\n         s->img_buffer = s->img_buffer_end;\n         return res;\n      }\n   }\n\n   if (s->img_buffer+n <= s->img_buffer_end) {\n      memcpy(buffer, s->img_buffer, n);\n      s->img_buffer += n;\n      return 1;\n   } else\n      return 0;\n}\n\nstatic int stbi__get16be(stbi__context *s)\n{\n   int z = stbi__get8(s);\n   return (z << 8) + stbi__get8(s);\n}\n\nstatic stbi__uint32 stbi__get32be(stbi__context *s)\n{\n   stbi__uint32 z = stbi__get16be(s);\n   return (z << 16) + stbi__get16be(s);\n}\n\n#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF)\n// nothing\n#else\nstatic int stbi__get16le(stbi__context *s)\n{\n   int z = stbi__get8(s);\n   return z + (stbi__get8(s) << 8);\n}\n#endif\n\n#ifndef STBI_NO_BMP\nstatic stbi__uint32 stbi__get32le(stbi__context *s)\n{\n   stbi__uint32 z = stbi__get16le(s);\n   return z + (stbi__get16le(s) << 16);\n}\n#endif\n\n#define STBI__BYTECAST(x)  ((stbi_uc) ((x) & 255))  // truncate int to byte without warnings\n\n\n//////////////////////////////////////////////////////////////////////////////\n//\n//  generic converter from built-in img_n to req_comp\n//    individual types do this automatically as much as possible (e.g. jpeg\n//    does all cases internally since it needs to colorspace convert anyway,\n//    and it never has alpha, so very few cases ). png can automatically\n//    interleave an alpha=255 channel, but falls back to this for other cases\n//\n//  assume data buffer is malloced, so malloc a new one and free that one\n//  only failure mode is malloc failing\n\nstatic stbi_uc stbi__compute_y(int r, int g, int b)\n{\n   return (stbi_uc) (((r*77) + (g*150) +  (29*b)) >> 8);\n}\n\nstatic unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y)\n{\n   int i,j;\n   unsigned char *good;\n\n   if (req_comp == img_n) return data;\n   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);\n\n   good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0);\n   if (good == NULL) {\n      STBI_FREE(data);\n      return stbi__errpuc(\"outofmem\", \"Out of memory\");\n   }\n\n   for (j=0; j < (int) y; ++j) {\n      unsigned char *src  = data + j * x * img_n   ;\n      unsigned char *dest = good + j * x * req_comp;\n\n      #define STBI__COMBO(a,b)  ((a)*8+(b))\n      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)\n      // convert source image with img_n components to one with req_comp components;\n      // avoid switch per pixel, so use switch per scanline and massive macros\n      switch (STBI__COMBO(img_n, req_comp)) {\n         STBI__CASE(1,2) { dest[0]=src[0], dest[1]=255;                                     } break;\n         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;\n         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=255;                     } break;\n         STBI__CASE(2,1) { dest[0]=src[0];                                                  } break;\n         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                  } break;\n         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1];                  } break;\n         STBI__CASE(3,4) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255;        } break;\n         STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;\n         STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = 255;    } break;\n         STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]);                   } break;\n         STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]), dest[1] = src[3]; } break;\n         STBI__CASE(4,3) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2];                    } break;\n         default: STBI_ASSERT(0);\n      }\n      #undef STBI__CASE\n   }\n\n   STBI_FREE(data);\n   return good;\n}\n\nstatic stbi__uint16 stbi__compute_y_16(int r, int g, int b)\n{\n   return (stbi__uint16) (((r*77) + (g*150) +  (29*b)) >> 8);\n}\n\nstatic stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y)\n{\n   int i,j;\n   stbi__uint16 *good;\n\n   if (req_comp == img_n) return data;\n   STBI_ASSERT(req_comp >= 1 && req_comp <= 4);\n\n   good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2);\n   if (good == NULL) {\n      STBI_FREE(data);\n      return (stbi__uint16 *) stbi__errpuc(\"outofmem\", \"Out of memory\");\n   }\n\n   for (j=0; j < (int) y; ++j) {\n      stbi__uint16 *src  = data + j * x * img_n   ;\n      stbi__uint16 *dest = good + j * x * req_comp;\n\n      #define STBI__COMBO(a,b)  ((a)*8+(b))\n      #define STBI__CASE(a,b)   case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b)\n      // convert source image with img_n components to one with req_comp components;\n      // avoid switch per pixel, so use switch per scanline and massive macros\n      switch (STBI__COMBO(img_n, req_comp)) {\n         STBI__CASE(1,2) { dest[0]=src[0], dest[1]=0xffff;                                     } break;\n         STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;\n         STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=0xffff;                     } break;\n         STBI__CASE(2,1) { dest[0]=src[0];                                                     } break;\n         STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0];                                     } break;\n         STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1];                     } break;\n         STBI__CASE(3,4) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=0xffff;        } break;\n         STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;\n         STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]), dest[1] = 0xffff; } break;\n         STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]);                   } break;\n         STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]), dest[1] = src[3]; } break;\n         STBI__CASE(4,3) { dest[0]=src[0],dest[1]=src[1],dest[2]=src[2];                       } break;\n         default: STBI_ASSERT(0);\n      }\n      #undef STBI__CASE\n   }\n\n   STBI_FREE(data);\n   return good;\n}\n\n#ifndef STBI_NO_LINEAR\nstatic float   *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp)\n{\n   int i,k,n;\n   float *output;\n   if (!data) return NULL;\n   output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0);\n   if (output == NULL) { STBI_FREE(data); return stbi__errpf(\"outofmem\", \"Out of memory\"); }\n   // compute number of non-alpha components\n   if (comp & 1) n = comp; else n = comp-1;\n   for (i=0; i < x*y; ++i) {\n      for (k=0; k < n; ++k) {\n         output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale);\n      }\n      if (k < comp) output[i*comp + k] = data[i*comp+k]/255.0f;\n   }\n   STBI_FREE(data);\n   return output;\n}\n#endif\n\n#ifndef STBI_NO_HDR\n#define stbi__float2int(x)   ((int) (x))\nstatic stbi_uc *stbi__hdr_to_ldr(float   *data, int x, int y, int comp)\n{\n   int i,k,n;\n   stbi_uc *output;\n   if (!data) return NULL;\n   output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0);\n   if (output == NULL) { STBI_FREE(data); return stbi__errpuc(\"outofmem\", \"Out of memory\"); }\n   // compute number of non-alpha components\n   if (comp & 1) n = comp; else n = comp-1;\n   for (i=0; i < x*y; ++i) {\n      for (k=0; k < n; ++k) {\n         float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f;\n         if (z < 0) z = 0;\n         if (z > 255) z = 255;\n         output[i*comp + k] = (stbi_uc) stbi__float2int(z);\n      }\n      if (k < comp) {\n         float z = data[i*comp+k] * 255 + 0.5f;\n         if (z < 0) z = 0;\n         if (z > 255) z = 255;\n         output[i*comp + k] = (stbi_uc) stbi__float2int(z);\n      }\n   }\n   STBI_FREE(data);\n   return output;\n}\n#endif\n\n//////////////////////////////////////////////////////////////////////////////\n//\n//  \"baseline\" JPEG/JFIF decoder\n//\n//    simple implementation\n//      - doesn't support delayed output of y-dimension\n//      - simple interface (only one output format: 8-bit interleaved RGB)\n//      - doesn't try to recover corrupt jpegs\n//      - doesn't allow partial loading, loading multiple at once\n//      - still fast on x86 (copying globals into locals doesn't help x86)\n//      - allocates lots of intermediate memory (full size of all components)\n//        - non-interleaved case requires this anyway\n//        - allows good upsampling (see next)\n//    high-quality\n//      - upsampled channels are bilinearly interpolated, even across blocks\n//      - quality integer IDCT derived from IJG's 'slow'\n//    performance\n//      - fast huffman; reasonable integer IDCT\n//      - some SIMD kernels for common paths on targets with SSE2/NEON\n//      - uses a lot of intermediate memory, could cache poorly\n\n#ifndef STBI_NO_JPEG\n\n// huffman decoding acceleration\n#define FAST_BITS   9  // larger handles more cases; smaller stomps less cache\n\ntypedef struct\n{\n   stbi_uc  fast[1 << FAST_BITS];\n   // weirdly, repacking this into AoS is a 10% speed loss, instead of a win\n   stbi__uint16 code[256];\n   stbi_uc  values[256];\n   stbi_uc  size[257];\n   unsigned int maxcode[18];\n   int    delta[17];   // old 'firstsymbol' - old 'firstcode'\n} stbi__huffman;\n\ntypedef struct\n{\n   stbi__context *s;\n   stbi__huffman huff_dc[4];\n   stbi__huffman huff_ac[4];\n   stbi__uint16 dequant[4][64];\n   stbi__int16 fast_ac[4][1 << FAST_BITS];\n\n// sizes for components, interleaved MCUs\n   int img_h_max, img_v_max;\n   int img_mcu_x, img_mcu_y;\n   int img_mcu_w, img_mcu_h;\n\n// definition of jpeg image component\n   struct\n   {\n      int id;\n      int h,v;\n      int tq;\n      int hd,ha;\n      int dc_pred;\n\n      int x,y,w2,h2;\n      stbi_uc *data;\n      void *raw_data, *raw_coeff;\n      stbi_uc *linebuf;\n      short   *coeff;   // progressive only\n      int      coeff_w, coeff_h; // number of 8x8 coefficient blocks\n   } img_comp[4];\n\n   stbi__uint32   code_buffer; // jpeg entropy-coded buffer\n   int            code_bits;   // number of valid bits\n   unsigned char  marker;      // marker seen while filling entropy buffer\n   int            nomore;      // flag if we saw a marker so must stop\n\n   int            progressive;\n   int            spec_start;\n   int            spec_end;\n   int            succ_high;\n   int            succ_low;\n   int            eob_run;\n   int            jfif;\n   int            app14_color_transform; // Adobe APP14 tag\n   int            rgb;\n\n   int scan_n, order[4];\n   int restart_interval, todo;\n\n// kernels\n   void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]);\n   void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step);\n   stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs);\n} stbi__jpeg;\n\nstatic int stbi__build_huffman(stbi__huffman *h, int *count)\n{\n   int i,j,k=0,code;\n   // build size list for each symbol (from JPEG spec)\n   for (i=0; i < 16; ++i)\n      for (j=0; j < count[i]; ++j)\n         h->size[k++] = (stbi_uc) (i+1);\n   h->size[k] = 0;\n\n   // compute actual symbols (from jpeg spec)\n   code = 0;\n   k = 0;\n   for(j=1; j <= 16; ++j) {\n      // compute delta to add to code to compute symbol id\n      h->delta[j] = k - code;\n      if (h->size[k] == j) {\n         while (h->size[k] == j)\n            h->code[k++] = (stbi__uint16) (code++);\n         if (code-1 >= (1 << j)) return stbi__err(\"bad code lengths\",\"Corrupt JPEG\");\n      }\n      // compute largest code + 1 for this size, preshifted as needed later\n      h->maxcode[j] = code << (16-j);\n      code <<= 1;\n   }\n   h->maxcode[j] = 0xffffffff;\n\n   // build non-spec acceleration table; 255 is flag for not-accelerated\n   memset(h->fast, 255, 1 << FAST_BITS);\n   for (i=0; i < k; ++i) {\n      int s = h->size[i];\n      if (s <= FAST_BITS) {\n         int c = h->code[i] << (FAST_BITS-s);\n         int m = 1 << (FAST_BITS-s);\n         for (j=0; j < m; ++j) {\n            h->fast[c+j] = (stbi_uc) i;\n         }\n      }\n   }\n   return 1;\n}\n\n// build a table that decodes both magnitude and value of small ACs in\n// one go.\nstatic void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h)\n{\n   int i;\n   for (i=0; i < (1 << FAST_BITS); ++i) {\n      stbi_uc fast = h->fast[i];\n      fast_ac[i] = 0;\n      if (fast < 255) {\n         int rs = h->values[fast];\n         int run = (rs >> 4) & 15;\n         int magbits = rs & 15;\n         int len = h->size[fast];\n\n         if (magbits && len + magbits <= FAST_BITS) {\n            // magnitude code followed by receive_extend code\n            int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits);\n            int m = 1 << (magbits - 1);\n            if (k < m) k += (~0U << magbits) + 1;\n            // if the result is small enough, we can fit it in fast_ac table\n            if (k >= -128 && k <= 127)\n               fast_ac[i] = (stbi__int16) ((k << 8) + (run << 4) + (len + magbits));\n         }\n      }\n   }\n}\n\nstatic void stbi__grow_buffer_unsafe(stbi__jpeg *j)\n{\n   do {\n      int b = j->nomore ? 0 : stbi__get8(j->s);\n      if (b == 0xff) {\n         int c = stbi__get8(j->s);\n         while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes\n         if (c != 0) {\n            j->marker = (unsigned char) c;\n            j->nomore = 1;\n            return;\n         }\n      }\n      j->code_buffer |= b << (24 - j->code_bits);\n      j->code_bits += 8;\n   } while (j->code_bits <= 24);\n}\n\n// (1 << n) - 1\nstatic stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};\n\n// decode a jpeg huffman value from the bitstream\nstbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)\n{\n   unsigned int temp;\n   int c,k;\n\n   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);\n\n   // look at the top FAST_BITS and determine what symbol ID it is,\n   // if the code is <= FAST_BITS\n   c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);\n   k = h->fast[c];\n   if (k < 255) {\n      int s = h->size[k];\n      if (s > j->code_bits)\n         return -1;\n      j->code_buffer <<= s;\n      j->code_bits -= s;\n      return h->values[k];\n   }\n\n   // naive test is to shift the code_buffer down so k bits are\n   // valid, then test against maxcode. To speed this up, we've\n   // preshifted maxcode left so that it has (16-k) 0s at the\n   // end; in other words, regardless of the number of bits, it\n   // wants to be compared against something shifted to have 16;\n   // that way we don't need to shift inside the loop.\n   temp = j->code_buffer >> 16;\n   for (k=FAST_BITS+1 ; ; ++k)\n      if (temp < h->maxcode[k])\n         break;\n   if (k == 17) {\n      // error! code not found\n      j->code_bits -= 16;\n      return -1;\n   }\n\n   if (k > j->code_bits)\n      return -1;\n\n   // convert the huffman code to the symbol id\n   c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k];\n   STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]);\n\n   // convert the id to a symbol\n   j->code_bits -= k;\n   j->code_buffer <<= k;\n   return h->values[c];\n}\n\n// bias[n] = (-1<<n) + 1\nstatic int const stbi__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023,-2047,-4095,-8191,-16383,-32767};\n\n// combined JPEG 'receive' and JPEG 'extend', since baseline\n// always extends everything it receives.\nstbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n)\n{\n   unsigned int k;\n   int sgn;\n   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);\n\n   sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB\n   k = stbi_lrot(j->code_buffer, n);\n   STBI_ASSERT(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask)));\n   j->code_buffer = k & ~stbi__bmask[n];\n   k &= stbi__bmask[n];\n   j->code_bits -= n;\n   return k + (stbi__jbias[n] & ~sgn);\n}\n\n// get some unsigned bits\nstbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n)\n{\n   unsigned int k;\n   if (j->code_bits < n) stbi__grow_buffer_unsafe(j);\n   k = stbi_lrot(j->code_buffer, n);\n   j->code_buffer = k & ~stbi__bmask[n];\n   k &= stbi__bmask[n];\n   j->code_bits -= n;\n   return k;\n}\n\nstbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j)\n{\n   unsigned int k;\n   if (j->code_bits < 1) stbi__grow_buffer_unsafe(j);\n   k = j->code_buffer;\n   j->code_buffer <<= 1;\n   --j->code_bits;\n   return k & 0x80000000;\n}\n\n// given a value that's at position X in the zigzag stream,\n// where does it appear in the 8x8 matrix coded as row-major?\nstatic stbi_uc stbi__jpeg_dezigzag[64+15] =\n{\n    0,  1,  8, 16,  9,  2,  3, 10,\n   17, 24, 32, 25, 18, 11,  4,  5,\n   12, 19, 26, 33, 40, 48, 41, 34,\n   27, 20, 13,  6,  7, 14, 21, 28,\n   35, 42, 49, 56, 57, 50, 43, 36,\n   29, 22, 15, 23, 30, 37, 44, 51,\n   58, 59, 52, 45, 38, 31, 39, 46,\n   53, 60, 61, 54, 47, 55, 62, 63,\n   // let corrupt input sample past end\n   63, 63, 63, 63, 63, 63, 63, 63,\n   63, 63, 63, 63, 63, 63, 63\n};\n\n// decode one 64-entry block--\nstatic int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant)\n{\n   int diff,dc,k;\n   int t;\n\n   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);\n   t = stbi__jpeg_huff_decode(j, hdc);\n   if (t < 0) return stbi__err(\"bad huffman code\",\"Corrupt JPEG\");\n\n   // 0 all the ac values now so we can do it 32-bits at a time\n   memset(data,0,64*sizeof(data[0]));\n\n   diff = t ? stbi__extend_receive(j, t) : 0;\n   dc = j->img_comp[b].dc_pred + diff;\n   j->img_comp[b].dc_pred = dc;\n   data[0] = (short) (dc * dequant[0]);\n\n   // decode AC components, see JPEG spec\n   k = 1;\n   do {\n      unsigned int zig;\n      int c,r,s;\n      if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);\n      c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);\n      r = fac[c];\n      if (r) { // fast-AC path\n         k += (r >> 4) & 15; // run\n         s = r & 15; // combined length\n         j->code_buffer <<= s;\n         j->code_bits -= s;\n         // decode into unzigzag'd location\n         zig = stbi__jpeg_dezigzag[k++];\n         data[zig] = (short) ((r >> 8) * dequant[zig]);\n      } else {\n         int rs = stbi__jpeg_huff_decode(j, hac);\n         if (rs < 0) return stbi__err(\"bad huffman code\",\"Corrupt JPEG\");\n         s = rs & 15;\n         r = rs >> 4;\n         if (s == 0) {\n            if (rs != 0xf0) break; // end block\n            k += 16;\n         } else {\n            k += r;\n            // decode into unzigzag'd location\n            zig = stbi__jpeg_dezigzag[k++];\n            data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]);\n         }\n      }\n   } while (k < 64);\n   return 1;\n}\n\nstatic int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b)\n{\n   int diff,dc;\n   int t;\n   if (j->spec_end != 0) return stbi__err(\"can't merge dc and ac\", \"Corrupt JPEG\");\n\n   if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);\n\n   if (j->succ_high == 0) {\n      // first scan for DC coefficient, must be first\n      memset(data,0,64*sizeof(data[0])); // 0 all the ac values now\n      t = stbi__jpeg_huff_decode(j, hdc);\n      diff = t ? stbi__extend_receive(j, t) : 0;\n\n      dc = j->img_comp[b].dc_pred + diff;\n      j->img_comp[b].dc_pred = dc;\n      data[0] = (short) (dc << j->succ_low);\n   } else {\n      // refinement scan for DC coefficient\n      if (stbi__jpeg_get_bit(j))\n         data[0] += (short) (1 << j->succ_low);\n   }\n   return 1;\n}\n\n// @OPTIMIZE: store non-zigzagged during the decode passes,\n// and only de-zigzag when dequantizing\nstatic int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac)\n{\n   int k;\n   if (j->spec_start == 0) return stbi__err(\"can't merge dc and ac\", \"Corrupt JPEG\");\n\n   if (j->succ_high == 0) {\n      int shift = j->succ_low;\n\n      if (j->eob_run) {\n         --j->eob_run;\n         return 1;\n      }\n\n      k = j->spec_start;\n      do {\n         unsigned int zig;\n         int c,r,s;\n         if (j->code_bits < 16) stbi__grow_buffer_unsafe(j);\n         c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1);\n         r = fac[c];\n         if (r) { // fast-AC path\n            k += (r >> 4) & 15; // run\n            s = r & 15; // combined length\n            j->code_buffer <<= s;\n            j->code_bits -= s;\n            zig = stbi__jpeg_dezigzag[k++];\n            data[zig] = (short) ((r >> 8) << shift);\n         } else {\n            int rs = stbi__jpeg_huff_decode(j, hac);\n            if (rs < 0) return stbi__err(\"bad huffman code\",\"Corrupt JPEG\");\n            s = rs & 15;\n            r = rs >> 4;\n            if (s == 0) {\n               if (r < 15) {\n                  j->eob_run = (1 << r);\n                  if (r)\n                     j->eob_run += stbi__jpeg_get_bits(j, r);\n                  --j->eob_run;\n                  break;\n               }\n               k += 16;\n            } else {\n               k += r;\n               zig = stbi__jpeg_dezigzag[k++];\n               data[zig] = (short) (stbi__extend_receive(j,s) << shift);\n            }\n         }\n      } while (k <= j->spec_end);\n   } else {\n      // refinement scan for these AC coefficients\n\n      short bit = (short) (1 << j->succ_low);\n\n      if (j->eob_run) {\n         --j->eob_run;\n         for (k = j->spec_start; k <= j->spec_end; ++k) {\n            short *p = &data[stbi__jpeg_dezigzag[k]];\n            if (*p != 0)\n               if (stbi__jpeg_get_bit(j))\n                  if ((*p & bit)==0) {\n                     if (*p > 0)\n                        *p += bit;\n                     else\n                        *p -= bit;\n                  }\n         }\n      } else {\n         k = j->spec_start;\n         do {\n            int r,s;\n            int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh\n            if (rs < 0) return stbi__err(\"bad huffman code\",\"Corrupt JPEG\");\n            s = rs & 15;\n            r = rs >> 4;\n            if (s == 0) {\n               if (r < 15) {\n                  j->eob_run = (1 << r) - 1;\n                  if (r)\n                     j->eob_run += stbi__jpeg_get_bits(j, r);\n                  r = 64; // force end of block\n               } else {\n                  // r=15 s=0 should write 16 0s, so we just do\n                  // a run of 15 0s and then write s (which is 0),\n                  // so we don't have to do anything special here\n               }\n            } else {\n               if (s != 1) return stbi__err(\"bad huffman code\", \"Corrupt JPEG\");\n               // sign bit\n               if (stbi__jpeg_get_bit(j))\n                  s = bit;\n               else\n                  s = -bit;\n            }\n\n            // advance by r\n            while (k <= j->spec_end) {\n               short *p = &data[stbi__jpeg_dezigzag[k++]];\n               if (*p != 0) {\n                  if (stbi__jpeg_get_bit(j))\n                     if ((*p & bit)==0) {\n                        if (*p > 0)\n                           *p += bit;\n                        else\n                           *p -= bit;\n                     }\n               } else {\n                  if (r == 0) {\n                     *p = (short) s;\n                     break;\n                  }\n                  --r;\n               }\n            }\n         } while (k <= j->spec_end);\n      }\n   }\n   return 1;\n}\n\n// take a -128..127 value and stbi__clamp it and convert to 0..255\nstbi_inline static stbi_uc stbi__clamp(int x)\n{\n   // trick to use a single test to catch both cases\n   if ((unsigned int) x > 255) {\n      if (x < 0) return 0;\n      if (x > 255) return 255;\n   }\n   return (stbi_uc) x;\n}\n\n#define stbi__f2f(x)  ((int) (((x) * 4096 + 0.5)))\n#define stbi__fsh(x)  ((x) << 12)\n\n// derived from jidctint -- DCT_ISLOW\n#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \\\n   int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \\\n   p2 = s2;                                    \\\n   p3 = s6;                                    \\\n   p1 = (p2+p3) * stbi__f2f(0.5411961f);       \\\n   t2 = p1 + p3*stbi__f2f(-1.847759065f);      \\\n   t3 = p1 + p2*stbi__f2f( 0.765366865f);      \\\n   p2 = s0;                                    \\\n   p3 = s4;                                    \\\n   t0 = stbi__fsh(p2+p3);                      \\\n   t1 = stbi__fsh(p2-p3);                      \\\n   x0 = t0+t3;                                 \\\n   x3 = t0-t3;                                 \\\n   x1 = t1+t2;                                 \\\n   x2 = t1-t2;                                 \\\n   t0 = s7;                                    \\\n   t1 = s5;                                    \\\n   t2 = s3;                                    \\\n   t3 = s1;                                    \\\n   p3 = t0+t2;                                 \\\n   p4 = t1+t3;                                 \\\n   p1 = t0+t3;                                 \\\n   p2 = t1+t2;                                 \\\n   p5 = (p3+p4)*stbi__f2f( 1.175875602f);      \\\n   t0 = t0*stbi__f2f( 0.298631336f);           \\\n   t1 = t1*stbi__f2f( 2.053119869f);           \\\n   t2 = t2*stbi__f2f( 3.072711026f);           \\\n   t3 = t3*stbi__f2f( 1.501321110f);           \\\n   p1 = p5 + p1*stbi__f2f(-0.899976223f);      \\\n   p2 = p5 + p2*stbi__f2f(-2.562915447f);      \\\n   p3 = p3*stbi__f2f(-1.961570560f);           \\\n   p4 = p4*stbi__f2f(-0.390180644f);           \\\n   t3 += p1+p4;                                \\\n   t2 += p2+p3;                                \\\n   t1 += p2+p4;                                \\\n   t0 += p1+p3;\n\nstatic void stbi__idct_block(stbi_uc *out, int out_stride, short data[64])\n{\n   int i,val[64],*v=val;\n   stbi_uc *o;\n   short *d = data;\n\n   // columns\n   for (i=0; i < 8; ++i,++d, ++v) {\n      // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing\n      if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0\n           && d[40]==0 && d[48]==0 && d[56]==0) {\n         //    no shortcut                 0     seconds\n         //    (1|2|3|4|5|6|7)==0          0     seconds\n         //    all separate               -0.047 seconds\n         //    1 && 2|3 && 4|5 && 6|7:    -0.047 seconds\n         int dcterm = d[0] << 2;\n         v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm;\n      } else {\n         STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56])\n         // constants scaled things up by 1<<12; let's bring them back\n         // down, but keep 2 extra bits of precision\n         x0 += 512; x1 += 512; x2 += 512; x3 += 512;\n         v[ 0] = (x0+t3) >> 10;\n         v[56] = (x0-t3) >> 10;\n         v[ 8] = (x1+t2) >> 10;\n         v[48] = (x1-t2) >> 10;\n         v[16] = (x2+t1) >> 10;\n         v[40] = (x2-t1) >> 10;\n         v[24] = (x3+t0) >> 10;\n         v[32] = (x3-t0) >> 10;\n      }\n   }\n\n   for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) {\n      // no fast case since the first 1D IDCT spread components out\n      STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7])\n      // constants scaled things up by 1<<12, plus we had 1<<2 from first\n      // loop, plus horizontal and vertical each scale by sqrt(8) so together\n      // we've got an extra 1<<3, so 1<<17 total we need to remove.\n      // so we want to round that, which means adding 0.5 * 1<<17,\n      // aka 65536. Also, we'll end up with -128 to 127 that we want\n      // to encode as 0..255 by adding 128, so we'll add that before the shift\n      x0 += 65536 + (128<<17);\n      x1 += 65536 + (128<<17);\n      x2 += 65536 + (128<<17);\n      x3 += 65536 + (128<<17);\n      // tried computing the shifts into temps, or'ing the temps to see\n      // if any were out of range, but that was slower\n      o[0] = stbi__clamp((x0+t3) >> 17);\n      o[7] = stbi__clamp((x0-t3) >> 17);\n      o[1] = stbi__clamp((x1+t2) >> 17);\n      o[6] = stbi__clamp((x1-t2) >> 17);\n      o[2] = stbi__clamp((x2+t1) >> 17);\n      o[5] = stbi__clamp((x2-t1) >> 17);\n      o[3] = stbi__clamp((x3+t0) >> 17);\n      o[4] = stbi__clamp((x3-t0) >> 17);\n   }\n}\n\n#ifdef STBI_SSE2\n// sse2 integer IDCT. not the fastest possible implementation but it\n// produces bit-identical results to the generic C version so it's\n// fully \"transparent\".\nstatic void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])\n{\n   // This is constructed to match our regular (generic) integer IDCT exactly.\n   __m128i row0, row1, row2, row3, row4, row5, row6, row7;\n   __m128i tmp;\n\n   // dot product constant: even elems=x, odd elems=y\n   #define dct_const(x,y)  _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y))\n\n   // out(0) = c0[even]*x + c0[odd]*y   (c0, x, y 16-bit, out 32-bit)\n   // out(1) = c1[even]*x + c1[odd]*y\n   #define dct_rot(out0,out1, x,y,c0,c1) \\\n      __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \\\n      __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \\\n      __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \\\n      __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \\\n      __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \\\n      __m128i out1##_h = _mm_madd_epi16(c0##hi, c1)\n\n   // out = in << 12  (in 16-bit, out 32-bit)\n   #define dct_widen(out, in) \\\n      __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \\\n      __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4)\n\n   // wide add\n   #define dct_wadd(out, a, b) \\\n      __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \\\n      __m128i out##_h = _mm_add_epi32(a##_h, b##_h)\n\n   // wide sub\n   #define dct_wsub(out, a, b) \\\n      __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \\\n      __m128i out##_h = _mm_sub_epi32(a##_h, b##_h)\n\n   // butterfly a/b, add bias, then shift by \"s\" and pack\n   #define dct_bfly32o(out0, out1, a,b,bias,s) \\\n      { \\\n         __m128i abiased_l = _mm_add_epi32(a##_l, bias); \\\n         __m128i abiased_h = _mm_add_epi32(a##_h, bias); \\\n         dct_wadd(sum, abiased, b); \\\n         dct_wsub(dif, abiased, b); \\\n         out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \\\n         out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \\\n      }\n\n   // 8-bit interleave step (for transposes)\n   #define dct_interleave8(a, b) \\\n      tmp = a; \\\n      a = _mm_unpacklo_epi8(a, b); \\\n      b = _mm_unpackhi_epi8(tmp, b)\n\n   // 16-bit interleave step (for transposes)\n   #define dct_interleave16(a, b) \\\n      tmp = a; \\\n      a = _mm_unpacklo_epi16(a, b); \\\n      b = _mm_unpackhi_epi16(tmp, b)\n\n   #define dct_pass(bias,shift) \\\n      { \\\n         /* even part */ \\\n         dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \\\n         __m128i sum04 = _mm_add_epi16(row0, row4); \\\n         __m128i dif04 = _mm_sub_epi16(row0, row4); \\\n         dct_widen(t0e, sum04); \\\n         dct_widen(t1e, dif04); \\\n         dct_wadd(x0, t0e, t3e); \\\n         dct_wsub(x3, t0e, t3e); \\\n         dct_wadd(x1, t1e, t2e); \\\n         dct_wsub(x2, t1e, t2e); \\\n         /* odd part */ \\\n         dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \\\n         dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \\\n         __m128i sum17 = _mm_add_epi16(row1, row7); \\\n         __m128i sum35 = _mm_add_epi16(row3, row5); \\\n         dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \\\n         dct_wadd(x4, y0o, y4o); \\\n         dct_wadd(x5, y1o, y5o); \\\n         dct_wadd(x6, y2o, y5o); \\\n         dct_wadd(x7, y3o, y4o); \\\n         dct_bfly32o(row0,row7, x0,x7,bias,shift); \\\n         dct_bfly32o(row1,row6, x1,x6,bias,shift); \\\n         dct_bfly32o(row2,row5, x2,x5,bias,shift); \\\n         dct_bfly32o(row3,row4, x3,x4,bias,shift); \\\n      }\n\n   __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f));\n   __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f));\n   __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f));\n   __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f));\n   __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f));\n   __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f));\n   __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f));\n   __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f));\n\n   // rounding biases in column/row passes, see stbi__idct_block for explanation.\n   __m128i bias_0 = _mm_set1_epi32(512);\n   __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17));\n\n   // load\n   row0 = _mm_load_si128((const __m128i *) (data + 0*8));\n   row1 = _mm_load_si128((const __m128i *) (data + 1*8));\n   row2 = _mm_load_si128((const __m128i *) (data + 2*8));\n   row3 = _mm_load_si128((const __m128i *) (data + 3*8));\n   row4 = _mm_load_si128((const __m128i *) (data + 4*8));\n   row5 = _mm_load_si128((const __m128i *) (data + 5*8));\n   row6 = _mm_load_si128((const __m128i *) (data + 6*8));\n   row7 = _mm_load_si128((const __m128i *) (data + 7*8));\n\n   // column pass\n   dct_pass(bias_0, 10);\n\n   {\n      // 16bit 8x8 transpose pass 1\n      dct_interleave16(row0, row4);\n      dct_interleave16(row1, row5);\n      dct_interleave16(row2, row6);\n      dct_interleave16(row3, row7);\n\n      // transpose pass 2\n      dct_interleave16(row0, row2);\n      dct_interleave16(row1, row3);\n      dct_interleave16(row4, row6);\n      dct_interleave16(row5, row7);\n\n      // transpose pass 3\n      dct_interleave16(row0, row1);\n      dct_interleave16(row2, row3);\n      dct_interleave16(row4, row5);\n      dct_interleave16(row6, row7);\n   }\n\n   // row pass\n   dct_pass(bias_1, 17);\n\n   {\n      // pack\n      __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7\n      __m128i p1 = _mm_packus_epi16(row2, row3);\n      __m128i p2 = _mm_packus_epi16(row4, row5);\n      __m128i p3 = _mm_packus_epi16(row6, row7);\n\n      // 8bit 8x8 transpose pass 1\n      dct_interleave8(p0, p2); // a0e0a1e1...\n      dct_interleave8(p1, p3); // c0g0c1g1...\n\n      // transpose pass 2\n      dct_interleave8(p0, p1); // a0c0e0g0...\n      dct_interleave8(p2, p3); // b0d0f0h0...\n\n      // transpose pass 3\n      dct_interleave8(p0, p2); // a0b0c0d0...\n      dct_interleave8(p1, p3); // a4b4c4d4...\n\n      // store\n      _mm_storel_epi64((__m128i *) out, p0); out += out_stride;\n      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride;\n      _mm_storel_epi64((__m128i *) out, p2); out += out_stride;\n      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride;\n      _mm_storel_epi64((__m128i *) out, p1); out += out_stride;\n      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride;\n      _mm_storel_epi64((__m128i *) out, p3); out += out_stride;\n      _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e));\n   }\n\n#undef dct_const\n#undef dct_rot\n#undef dct_widen\n#undef dct_wadd\n#undef dct_wsub\n#undef dct_bfly32o\n#undef dct_interleave8\n#undef dct_interleave16\n#undef dct_pass\n}\n\n#endif // STBI_SSE2\n\n#ifdef STBI_NEON\n\n// NEON integer IDCT. should produce bit-identical\n// results to the generic C version.\nstatic void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64])\n{\n   int16x8_t row0, row1, row2, row3, row4, row5, row6, row7;\n\n   int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f));\n   int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f));\n   int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f));\n   int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f));\n   int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f));\n   int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f));\n   int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f));\n   int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f));\n   int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f));\n   int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f));\n   int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f));\n   int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f));\n\n#define dct_long_mul(out, inq, coeff) \\\n   int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \\\n   int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff)\n\n#define dct_long_mac(out, acc, inq, coeff) \\\n   int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \\\n   int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff)\n\n#define dct_widen(out, inq) \\\n   int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \\\n   int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12)\n\n// wide add\n#define dct_wadd(out, a, b) \\\n   int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \\\n   int32x4_t out##_h = vaddq_s32(a##_h, b##_h)\n\n// wide sub\n#define dct_wsub(out, a, b) \\\n   int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \\\n   int32x4_t out##_h = vsubq_s32(a##_h, b##_h)\n\n// butterfly a/b, then shift using \"shiftop\" by \"s\" and pack\n#define dct_bfly32o(out0,out1, a,b,shiftop,s) \\\n   { \\\n      dct_wadd(sum, a, b); \\\n      dct_wsub(dif, a, b); \\\n      out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \\\n      out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \\\n   }\n\n#define dct_pass(shiftop, shift) \\\n   { \\\n      /* even part */ \\\n      int16x8_t sum26 = vaddq_s16(row2, row6); \\\n      dct_long_mul(p1e, sum26, rot0_0); \\\n      dct_long_mac(t2e, p1e, row6, rot0_1); \\\n      dct_long_mac(t3e, p1e, row2, rot0_2); \\\n      int16x8_t sum04 = vaddq_s16(row0, row4); \\\n      int16x8_t dif04 = vsubq_s16(row0, row4); \\\n      dct_widen(t0e, sum04); \\\n      dct_widen(t1e, dif04); \\\n      dct_wadd(x0, t0e, t3e); \\\n      dct_wsub(x3, t0e, t3e); \\\n      dct_wadd(x1, t1e, t2e); \\\n      dct_wsub(x2, t1e, t2e); \\\n      /* odd part */ \\\n      int16x8_t sum15 = vaddq_s16(row1, row5); \\\n      int16x8_t sum17 = vaddq_s16(row1, row7); \\\n      int16x8_t sum35 = vaddq_s16(row3, row5); \\\n      int16x8_t sum37 = vaddq_s16(row3, row7); \\\n      int16x8_t sumodd = vaddq_s16(sum17, sum35); \\\n      dct_long_mul(p5o, sumodd, rot1_0); \\\n      dct_long_mac(p1o, p5o, sum17, rot1_1); \\\n      dct_long_mac(p2o, p5o, sum35, rot1_2); \\\n      dct_long_mul(p3o, sum37, rot2_0); \\\n      dct_long_mul(p4o, sum15, rot2_1); \\\n      dct_wadd(sump13o, p1o, p3o); \\\n      dct_wadd(sump24o, p2o, p4o); \\\n      dct_wadd(sump23o, p2o, p3o); \\\n      dct_wadd(sump14o, p1o, p4o); \\\n      dct_long_mac(x4, sump13o, row7, rot3_0); \\\n      dct_long_mac(x5, sump24o, row5, rot3_1); \\\n      dct_long_mac(x6, sump23o, row3, rot3_2); \\\n      dct_long_mac(x7, sump14o, row1, rot3_3); \\\n      dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \\\n      dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \\\n      dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \\\n      dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \\\n   }\n\n   // load\n   row0 = vld1q_s16(data + 0*8);\n   row1 = vld1q_s16(data + 1*8);\n   row2 = vld1q_s16(data + 2*8);\n   row3 = vld1q_s16(data + 3*8);\n   row4 = vld1q_s16(data + 4*8);\n   row5 = vld1q_s16(data + 5*8);\n   row6 = vld1q_s16(data + 6*8);\n   row7 = vld1q_s16(data + 7*8);\n\n   // add DC bias\n   row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0));\n\n   // column pass\n   dct_pass(vrshrn_n_s32, 10);\n\n   // 16bit 8x8 transpose\n   {\n// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively.\n// whether compilers actually get this is another story, sadly.\n#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; }\n#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); }\n#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); }\n\n      // pass 1\n      dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6\n      dct_trn16(row2, row3);\n      dct_trn16(row4, row5);\n      dct_trn16(row6, row7);\n\n      // pass 2\n      dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4\n      dct_trn32(row1, row3);\n      dct_trn32(row4, row6);\n      dct_trn32(row5, row7);\n\n      // pass 3\n      dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0\n      dct_trn64(row1, row5);\n      dct_trn64(row2, row6);\n      dct_trn64(row3, row7);\n\n#undef dct_trn16\n#undef dct_trn32\n#undef dct_trn64\n   }\n\n   // row pass\n   // vrshrn_n_s32 only supports shifts up to 16, we need\n   // 17. so do a non-rounding shift of 16 first then follow\n   // up with a rounding shift by 1.\n   dct_pass(vshrn_n_s32, 16);\n\n   {\n      // pack and round\n      uint8x8_t p0 = vqrshrun_n_s16(row0, 1);\n      uint8x8_t p1 = vqrshrun_n_s16(row1, 1);\n      uint8x8_t p2 = vqrshrun_n_s16(row2, 1);\n      uint8x8_t p3 = vqrshrun_n_s16(row3, 1);\n      uint8x8_t p4 = vqrshrun_n_s16(row4, 1);\n      uint8x8_t p5 = vqrshrun_n_s16(row5, 1);\n      uint8x8_t p6 = vqrshrun_n_s16(row6, 1);\n      uint8x8_t p7 = vqrshrun_n_s16(row7, 1);\n\n      // again, these can translate into one instruction, but often don't.\n#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; }\n#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); }\n#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); }\n\n      // sadly can't use interleaved stores here since we only write\n      // 8 bytes to each scan line!\n\n      // 8x8 8-bit transpose pass 1\n      dct_trn8_8(p0, p1);\n      dct_trn8_8(p2, p3);\n      dct_trn8_8(p4, p5);\n      dct_trn8_8(p6, p7);\n\n      // pass 2\n      dct_trn8_16(p0, p2);\n      dct_trn8_16(p1, p3);\n      dct_trn8_16(p4, p6);\n      dct_trn8_16(p5, p7);\n\n      // pass 3\n      dct_trn8_32(p0, p4);\n      dct_trn8_32(p1, p5);\n      dct_trn8_32(p2, p6);\n      dct_trn8_32(p3, p7);\n\n      // store\n      vst1_u8(out, p0); out += out_stride;\n      vst1_u8(out, p1); out += out_stride;\n      vst1_u8(out, p2); out += out_stride;\n      vst1_u8(out, p3); out += out_stride;\n      vst1_u8(out, p4); out += out_stride;\n      vst1_u8(out, p5); out += out_stride;\n      vst1_u8(out, p6); out += out_stride;\n      vst1_u8(out, p7);\n\n#undef dct_trn8_8\n#undef dct_trn8_16\n#undef dct_trn8_32\n   }\n\n#undef dct_long_mul\n#undef dct_long_mac\n#undef dct_widen\n#undef dct_wadd\n#undef dct_wsub\n#undef dct_bfly32o\n#undef dct_pass\n}\n\n#endif // STBI_NEON\n\n#define STBI__MARKER_none  0xff\n// if there's a pending marker from the entropy stream, return that\n// otherwise, fetch from the stream and get a marker. if there's no\n// marker, return 0xff, which is never a valid marker value\nstatic stbi_uc stbi__get_marker(stbi__jpeg *j)\n{\n   stbi_uc x;\n   if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; }\n   x = stbi__get8(j->s);\n   if (x != 0xff) return STBI__MARKER_none;\n   while (x == 0xff)\n      x = stbi__get8(j->s); // consume repeated 0xff fill bytes\n   return x;\n}\n\n// in each scan, we'll have scan_n components, and the order\n// of the components is specified by order[]\n#define STBI__RESTART(x)     ((x) >= 0xd0 && (x) <= 0xd7)\n\n// after a restart interval, stbi__jpeg_reset the entropy decoder and\n// the dc prediction\nstatic void stbi__jpeg_reset(stbi__jpeg *j)\n{\n   j->code_bits = 0;\n   j->code_buffer = 0;\n   j->nomore = 0;\n   j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0;\n   j->marker = STBI__MARKER_none;\n   j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff;\n   j->eob_run = 0;\n   // no more than 1<<31 MCUs if no restart_interal? that's plenty safe,\n   // since we don't even allow 1<<30 pixels\n}\n\nstatic int stbi__parse_entropy_coded_data(stbi__jpeg *z)\n{\n   stbi__jpeg_reset(z);\n   if (!z->progressive) {\n      if (z->scan_n == 1) {\n         int i,j;\n         STBI_SIMD_ALIGN(short, data[64]);\n         int n = z->order[0];\n         // non-interleaved data, we just need to process one block at a time,\n         // in trivial scanline order\n         // number of blocks to do just depends on how many actual \"pixels\" this\n         // component has, independent of interleaved MCU blocking and such\n         int w = (z->img_comp[n].x+7) >> 3;\n         int h = (z->img_comp[n].y+7) >> 3;\n         for (j=0; j < h; ++j) {\n            for (i=0; i < w; ++i) {\n               int ha = z->img_comp[n].ha;\n               if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;\n               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);\n               // every data block is an MCU, so countdown the restart interval\n               if (--z->todo <= 0) {\n                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);\n                  // if it's NOT a restart, then just bail, so we get corrupt data\n                  // rather than no data\n                  if (!STBI__RESTART(z->marker)) return 1;\n                  stbi__jpeg_reset(z);\n               }\n            }\n         }\n         return 1;\n      } else { // interleaved\n         int i,j,k,x,y;\n         STBI_SIMD_ALIGN(short, data[64]);\n         for (j=0; j < z->img_mcu_y; ++j) {\n            for (i=0; i < z->img_mcu_x; ++i) {\n               // scan an interleaved mcu... process scan_n components in order\n               for (k=0; k < z->scan_n; ++k) {\n                  int n = z->order[k];\n                  // scan out an mcu's worth of this component; that's just determined\n                  // by the basic H and V specified for the component\n                  for (y=0; y < z->img_comp[n].v; ++y) {\n                     for (x=0; x < z->img_comp[n].h; ++x) {\n                        int x2 = (i*z->img_comp[n].h + x)*8;\n                        int y2 = (j*z->img_comp[n].v + y)*8;\n                        int ha = z->img_comp[n].ha;\n                        if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0;\n                        z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data);\n                     }\n                  }\n               }\n               // after all interleaved components, that's an interleaved MCU,\n               // so now count down the restart interval\n               if (--z->todo <= 0) {\n                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);\n                  if (!STBI__RESTART(z->marker)) return 1;\n                  stbi__jpeg_reset(z);\n               }\n            }\n         }\n         return 1;\n      }\n   } else {\n      if (z->scan_n == 1) {\n         int i,j;\n         int n = z->order[0];\n         // non-interleaved data, we just need to process one block at a time,\n         // in trivial scanline order\n         // number of blocks to do just depends on how many actual \"pixels\" this\n         // component has, independent of interleaved MCU blocking and such\n         int w = (z->img_comp[n].x+7) >> 3;\n         int h = (z->img_comp[n].y+7) >> 3;\n         for (j=0; j < h; ++j) {\n            for (i=0; i < w; ++i) {\n               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);\n               if (z->spec_start == 0) {\n                  if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))\n                     return 0;\n               } else {\n                  int ha = z->img_comp[n].ha;\n                  if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha]))\n                     return 0;\n               }\n               // every data block is an MCU, so countdown the restart interval\n               if (--z->todo <= 0) {\n                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);\n                  if (!STBI__RESTART(z->marker)) return 1;\n                  stbi__jpeg_reset(z);\n               }\n            }\n         }\n         return 1;\n      } else { // interleaved\n         int i,j,k,x,y;\n         for (j=0; j < z->img_mcu_y; ++j) {\n            for (i=0; i < z->img_mcu_x; ++i) {\n               // scan an interleaved mcu... process scan_n components in order\n               for (k=0; k < z->scan_n; ++k) {\n                  int n = z->order[k];\n                  // scan out an mcu's worth of this component; that's just determined\n                  // by the basic H and V specified for the component\n                  for (y=0; y < z->img_comp[n].v; ++y) {\n                     for (x=0; x < z->img_comp[n].h; ++x) {\n                        int x2 = (i*z->img_comp[n].h + x);\n                        int y2 = (j*z->img_comp[n].v + y);\n                        short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w);\n                        if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n))\n                           return 0;\n                     }\n                  }\n               }\n               // after all interleaved components, that's an interleaved MCU,\n               // so now count down the restart interval\n               if (--z->todo <= 0) {\n                  if (z->code_bits < 24) stbi__grow_buffer_unsafe(z);\n                  if (!STBI__RESTART(z->marker)) return 1;\n                  stbi__jpeg_reset(z);\n               }\n            }\n         }\n         return 1;\n      }\n   }\n}\n\nstatic void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant)\n{\n   int i;\n   for (i=0; i < 64; ++i)\n      data[i] *= dequant[i];\n}\n\nstatic void stbi__jpeg_finish(stbi__jpeg *z)\n{\n   if (z->progressive) {\n      // dequantize and idct the data\n      int i,j,n;\n      for (n=0; n < z->s->img_n; ++n) {\n         int w = (z->img_comp[n].x+7) >> 3;\n         int h = (z->img_comp[n].y+7) >> 3;\n         for (j=0; j < h; ++j) {\n            for (i=0; i < w; ++i) {\n               short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w);\n               stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]);\n               z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data);\n            }\n         }\n      }\n   }\n}\n\nstatic int stbi__process_marker(stbi__jpeg *z, int m)\n{\n   int L;\n   switch (m) {\n      case STBI__MARKER_none: // no marker found\n         return stbi__err(\"expected marker\",\"Corrupt JPEG\");\n\n      case 0xDD: // DRI - specify restart interval\n         if (stbi__get16be(z->s) != 4) return stbi__err(\"bad DRI len\",\"Corrupt JPEG\");\n         z->restart_interval = stbi__get16be(z->s);\n         return 1;\n\n      case 0xDB: // DQT - define quantization table\n         L = stbi__get16be(z->s)-2;\n         while (L > 0) {\n            int q = stbi__get8(z->s);\n            int p = q >> 4, sixteen = (p != 0);\n            int t = q & 15,i;\n            if (p != 0 && p != 1) return stbi__err(\"bad DQT type\",\"Corrupt JPEG\");\n            if (t > 3) return stbi__err(\"bad DQT table\",\"Corrupt JPEG\");\n\n            for (i=0; i < 64; ++i)\n               z->dequant[t][stbi__jpeg_dezigzag[i]] = sixteen ? stbi__get16be(z->s) : stbi__get8(z->s);\n            L -= (sixteen ? 129 : 65);\n         }\n         return L==0;\n\n      case 0xC4: // DHT - define huffman table\n         L = stbi__get16be(z->s)-2;\n         while (L > 0) {\n            stbi_uc *v;\n            int sizes[16],i,n=0;\n            int q = stbi__get8(z->s);\n            int tc = q >> 4;\n            int th = q & 15;\n            if (tc > 1 || th > 3) return stbi__err(\"bad DHT header\",\"Corrupt JPEG\");\n            for (i=0; i < 16; ++i) {\n               sizes[i] = stbi__get8(z->s);\n               n += sizes[i];\n            }\n            L -= 17;\n            if (tc == 0) {\n               if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0;\n               v = z->huff_dc[th].values;\n            } else {\n               if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0;\n               v = z->huff_ac[th].values;\n            }\n            for (i=0; i < n; ++i)\n               v[i] = stbi__get8(z->s);\n            if (tc != 0)\n               stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th);\n            L -= n;\n         }\n         return L==0;\n   }\n\n   // check for comment block or APP blocks\n   if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) {\n      L = stbi__get16be(z->s);\n      if (L < 2) {\n         if (m == 0xFE)\n            return stbi__err(\"bad COM len\",\"Corrupt JPEG\");\n         else\n            return stbi__err(\"bad APP len\",\"Corrupt JPEG\");\n      }\n      L -= 2;\n\n      if (m == 0xE0 && L >= 5) { // JFIF APP0 segment\n         static const unsigned char tag[5] = {'J','F','I','F','\\0'};\n         int ok = 1;\n         int i;\n         for (i=0; i < 5; ++i)\n            if (stbi__get8(z->s) != tag[i])\n               ok = 0;\n         L -= 5;\n         if (ok)\n            z->jfif = 1;\n      } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment\n         static const unsigned char tag[6] = {'A','d','o','b','e','\\0'};\n         int ok = 1;\n         int i;\n         for (i=0; i < 6; ++i)\n            if (stbi__get8(z->s) != tag[i])\n               ok = 0;\n         L -= 6;\n         if (ok) {\n            stbi__get8(z->s); // version\n            stbi__get16be(z->s); // flags0\n            stbi__get16be(z->s); // flags1\n            z->app14_color_transform = stbi__get8(z->s); // color transform\n            L -= 6;\n         }\n      }\n\n      stbi__skip(z->s, L);\n      return 1;\n   }\n\n   return stbi__err(\"unknown marker\",\"Corrupt JPEG\");\n}\n\n// after we see SOS\nstatic int stbi__process_scan_header(stbi__jpeg *z)\n{\n   int i;\n   int Ls = stbi__get16be(z->s);\n   z->scan_n = stbi__get8(z->s);\n   if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err(\"bad SOS component count\",\"Corrupt JPEG\");\n   if (Ls != 6+2*z->scan_n) return stbi__err(\"bad SOS len\",\"Corrupt JPEG\");\n   for (i=0; i < z->scan_n; ++i) {\n      int id = stbi__get8(z->s), which;\n      int q = stbi__get8(z->s);\n      for (which = 0; which < z->s->img_n; ++which)\n         if (z->img_comp[which].id == id)\n            break;\n      if (which == z->s->img_n) return 0; // no match\n      z->img_comp[which].hd = q >> 4;   if (z->img_comp[which].hd > 3) return stbi__err(\"bad DC huff\",\"Corrupt JPEG\");\n      z->img_comp[which].ha = q & 15;   if (z->img_comp[which].ha > 3) return stbi__err(\"bad AC huff\",\"Corrupt JPEG\");\n      z->order[i] = which;\n   }\n\n   {\n      int aa;\n      z->spec_start = stbi__get8(z->s);\n      z->spec_end   = stbi__get8(z->s); // should be 63, but might be 0\n      aa = stbi__get8(z->s);\n      z->succ_high = (aa >> 4);\n      z->succ_low  = (aa & 15);\n      if (z->progressive) {\n         if (z->spec_start > 63 || z->spec_end > 63  || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13)\n            return stbi__err(\"bad SOS\", \"Corrupt JPEG\");\n      } else {\n         if (z->spec_start != 0) return stbi__err(\"bad SOS\",\"Corrupt JPEG\");\n         if (z->succ_high != 0 || z->succ_low != 0) return stbi__err(\"bad SOS\",\"Corrupt JPEG\");\n         z->spec_end = 63;\n      }\n   }\n\n   return 1;\n}\n\nstatic int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why)\n{\n   int i;\n   for (i=0; i < ncomp; ++i) {\n      if (z->img_comp[i].raw_data) {\n         STBI_FREE(z->img_comp[i].raw_data);\n         z->img_comp[i].raw_data = NULL;\n         z->img_comp[i].data = NULL;\n      }\n      if (z->img_comp[i].raw_coeff) {\n         STBI_FREE(z->img_comp[i].raw_coeff);\n         z->img_comp[i].raw_coeff = 0;\n         z->img_comp[i].coeff = 0;\n      }\n      if (z->img_comp[i].linebuf) {\n         STBI_FREE(z->img_comp[i].linebuf);\n         z->img_comp[i].linebuf = NULL;\n      }\n   }\n   return why;\n}\n\nstatic int stbi__process_frame_header(stbi__jpeg *z, int scan)\n{\n   stbi__context *s = z->s;\n   int Lf,p,i,q, h_max=1,v_max=1,c;\n   Lf = stbi__get16be(s);         if (Lf < 11) return stbi__err(\"bad SOF len\",\"Corrupt JPEG\"); // JPEG\n   p  = stbi__get8(s);            if (p != 8) return stbi__err(\"only 8-bit\",\"JPEG format not supported: 8-bit only\"); // JPEG baseline\n   s->img_y = stbi__get16be(s);   if (s->img_y == 0) return stbi__err(\"no header height\", \"JPEG format not supported: delayed height\"); // Legal, but we don't handle it--but neither does IJG\n   s->img_x = stbi__get16be(s);   if (s->img_x == 0) return stbi__err(\"0 width\",\"Corrupt JPEG\"); // JPEG requires\n   c = stbi__get8(s);\n   if (c != 3 && c != 1 && c != 4) return stbi__err(\"bad component count\",\"Corrupt JPEG\");\n   s->img_n = c;\n   for (i=0; i < c; ++i) {\n      z->img_comp[i].data = NULL;\n      z->img_comp[i].linebuf = NULL;\n   }\n\n   if (Lf != 8+3*s->img_n) return stbi__err(\"bad SOF len\",\"Corrupt JPEG\");\n\n   z->rgb = 0;\n   for (i=0; i < s->img_n; ++i) {\n      static unsigned char rgb[3] = { 'R', 'G', 'B' };\n      z->img_comp[i].id = stbi__get8(s);\n      if (s->img_n == 3 && z->img_comp[i].id == rgb[i])\n         ++z->rgb;\n      q = stbi__get8(s);\n      z->img_comp[i].h = (q >> 4);  if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err(\"bad H\",\"Corrupt JPEG\");\n      z->img_comp[i].v = q & 15;    if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err(\"bad V\",\"Corrupt JPEG\");\n      z->img_comp[i].tq = stbi__get8(s);  if (z->img_comp[i].tq > 3) return stbi__err(\"bad TQ\",\"Corrupt JPEG\");\n   }\n\n   if (scan != STBI__SCAN_load) return 1;\n\n   if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err(\"too large\", \"Image too large to decode\");\n\n   for (i=0; i < s->img_n; ++i) {\n      if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h;\n      if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v;\n   }\n\n   // compute interleaved mcu info\n   z->img_h_max = h_max;\n   z->img_v_max = v_max;\n   z->img_mcu_w = h_max * 8;\n   z->img_mcu_h = v_max * 8;\n   // these sizes can't be more than 17 bits\n   z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w;\n   z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h;\n\n   for (i=0; i < s->img_n; ++i) {\n      // number of effective pixels (e.g. for non-interleaved MCU)\n      z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max;\n      z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max;\n      // to simplify generation, we'll allocate enough memory to decode\n      // the bogus oversized data from using interleaved MCUs and their\n      // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't\n      // discard the extra data until colorspace conversion\n      //\n      // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier)\n      // so these muls can't overflow with 32-bit ints (which we require)\n      z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8;\n      z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8;\n      z->img_comp[i].coeff = 0;\n      z->img_comp[i].raw_coeff = 0;\n      z->img_comp[i].linebuf = NULL;\n      z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15);\n      if (z->img_comp[i].raw_data == NULL)\n         return stbi__free_jpeg_components(z, i+1, stbi__err(\"outofmem\", \"Out of memory\"));\n      // align blocks for idct using mmx/sse\n      z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15);\n      if (z->progressive) {\n         // w2, h2 are multiples of 8 (see above)\n         z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8;\n         z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8;\n         z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15);\n         if (z->img_comp[i].raw_coeff == NULL)\n            return stbi__free_jpeg_components(z, i+1, stbi__err(\"outofmem\", \"Out of memory\"));\n         z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15);\n      }\n   }\n\n   return 1;\n}\n\n// use comparisons since in some cases we handle more than one case (e.g. SOF)\n#define stbi__DNL(x)         ((x) == 0xdc)\n#define stbi__SOI(x)         ((x) == 0xd8)\n#define stbi__EOI(x)         ((x) == 0xd9)\n#define stbi__SOF(x)         ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2)\n#define stbi__SOS(x)         ((x) == 0xda)\n\n#define stbi__SOF_progressive(x)   ((x) == 0xc2)\n\nstatic int stbi__decode_jpeg_header(stbi__jpeg *z, int scan)\n{\n   int m;\n   z->jfif = 0;\n   z->app14_color_transform = -1; // valid values are 0,1,2\n   z->marker = STBI__MARKER_none; // initialize cached marker to empty\n   m = stbi__get_marker(z);\n   if (!stbi__SOI(m)) return stbi__err(\"no SOI\",\"Corrupt JPEG\");\n   if (scan == STBI__SCAN_type) return 1;\n   m = stbi__get_marker(z);\n   while (!stbi__SOF(m)) {\n      if (!stbi__process_marker(z,m)) return 0;\n      m = stbi__get_marker(z);\n      while (m == STBI__MARKER_none) {\n         // some files have extra padding after their blocks, so ok, we'll scan\n         if (stbi__at_eof(z->s)) return stbi__err(\"no SOF\", \"Corrupt JPEG\");\n         m = stbi__get_marker(z);\n      }\n   }\n   z->progressive = stbi__SOF_progressive(m);\n   if (!stbi__process_frame_header(z, scan)) return 0;\n   return 1;\n}\n\n// decode image to YCbCr format\nstatic int stbi__decode_jpeg_image(stbi__jpeg *j)\n{\n   int m;\n   for (m = 0; m < 4; m++) {\n      j->img_comp[m].raw_data = NULL;\n      j->img_comp[m].raw_coeff = NULL;\n   }\n   j->restart_interval = 0;\n   if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0;\n   m = stbi__get_marker(j);\n   while (!stbi__EOI(m)) {\n      if (stbi__SOS(m)) {\n         if (!stbi__process_scan_header(j)) return 0;\n         if (!stbi__parse_entropy_coded_data(j)) return 0;\n         if (j->marker == STBI__MARKER_none ) {\n            // handle 0s at the end of image data from IP Kamera 9060\n            while (!stbi__at_eof(j->s)) {\n               int x = stbi__get8(j->s);\n               if (x == 255) {\n                  j->marker = stbi__get8(j->s);\n                  break;\n               }\n            }\n            // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0\n         }\n      } else if (stbi__DNL(m)) {\n         int Ld = stbi__get16be(j->s);\n         stbi__uint32 NL = stbi__get16be(j->s);\n         if (Ld != 4) stbi__err(\"bad DNL len\", \"Corrupt JPEG\");\n         if (NL != j->s->img_y) stbi__err(\"bad DNL height\", \"Corrupt JPEG\");\n      } else {\n         if (!stbi__process_marker(j, m)) return 0;\n      }\n      m = stbi__get_marker(j);\n   }\n   if (j->progressive)\n      stbi__jpeg_finish(j);\n   return 1;\n}\n\n// static jfif-centered resampling (across block boundaries)\n\ntypedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1,\n                                    int w, int hs);\n\n#define stbi__div4(x) ((stbi_uc) ((x) >> 2))\n\nstatic stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)\n{\n   STBI_NOTUSED(out);\n   STBI_NOTUSED(in_far);\n   STBI_NOTUSED(w);\n   STBI_NOTUSED(hs);\n   return in_near;\n}\n\nstatic stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)\n{\n   // need to generate two samples vertically for every one in input\n   int i;\n   STBI_NOTUSED(hs);\n   for (i=0; i < w; ++i)\n      out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2);\n   return out;\n}\n\nstatic stbi_uc*  stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)\n{\n   // need to generate two samples horizontally for every one in input\n   int i;\n   stbi_uc *input = in_near;\n\n   if (w == 1) {\n      // if only one sample, can't do any interpolation\n      out[0] = out[1] = input[0];\n      return out;\n   }\n\n   out[0] = input[0];\n   out[1] = stbi__div4(input[0]*3 + input[1] + 2);\n   for (i=1; i < w-1; ++i) {\n      int n = 3*input[i]+2;\n      out[i*2+0] = stbi__div4(n+input[i-1]);\n      out[i*2+1] = stbi__div4(n+input[i+1]);\n   }\n   out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2);\n   out[i*2+1] = input[w-1];\n\n   STBI_NOTUSED(in_far);\n   STBI_NOTUSED(hs);\n\n   return out;\n}\n\n#define stbi__div16(x) ((stbi_uc) ((x) >> 4))\n\nstatic stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)\n{\n   // need to generate 2x2 samples for every one in input\n   int i,t0,t1;\n   if (w == 1) {\n      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);\n      return out;\n   }\n\n   t1 = 3*in_near[0] + in_far[0];\n   out[0] = stbi__div4(t1+2);\n   for (i=1; i < w; ++i) {\n      t0 = t1;\n      t1 = 3*in_near[i]+in_far[i];\n      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);\n      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);\n   }\n   out[w*2-1] = stbi__div4(t1+2);\n\n   STBI_NOTUSED(hs);\n\n   return out;\n}\n\n#if defined(STBI_SSE2) || defined(STBI_NEON)\nstatic stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)\n{\n   // need to generate 2x2 samples for every one in input\n   int i=0,t0,t1;\n\n   if (w == 1) {\n      out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2);\n      return out;\n   }\n\n   t1 = 3*in_near[0] + in_far[0];\n   // process groups of 8 pixels for as long as we can.\n   // note we can't handle the last pixel in a row in this loop\n   // because we need to handle the filter boundary conditions.\n   for (; i < ((w-1) & ~7); i += 8) {\n#if defined(STBI_SSE2)\n      // load and perform the vertical filtering pass\n      // this uses 3*x + y = 4*x + (y - x)\n      __m128i zero  = _mm_setzero_si128();\n      __m128i farb  = _mm_loadl_epi64((__m128i *) (in_far + i));\n      __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i));\n      __m128i farw  = _mm_unpacklo_epi8(farb, zero);\n      __m128i nearw = _mm_unpacklo_epi8(nearb, zero);\n      __m128i diff  = _mm_sub_epi16(farw, nearw);\n      __m128i nears = _mm_slli_epi16(nearw, 2);\n      __m128i curr  = _mm_add_epi16(nears, diff); // current row\n\n      // horizontal filter works the same based on shifted vers of current\n      // row. \"prev\" is current row shifted right by 1 pixel; we need to\n      // insert the previous pixel value (from t1).\n      // \"next\" is current row shifted left by 1 pixel, with first pixel\n      // of next block of 8 pixels added in.\n      __m128i prv0 = _mm_slli_si128(curr, 2);\n      __m128i nxt0 = _mm_srli_si128(curr, 2);\n      __m128i prev = _mm_insert_epi16(prv0, t1, 0);\n      __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7);\n\n      // horizontal filter, polyphase implementation since it's convenient:\n      // even pixels = 3*cur + prev = cur*4 + (prev - cur)\n      // odd  pixels = 3*cur + next = cur*4 + (next - cur)\n      // note the shared term.\n      __m128i bias  = _mm_set1_epi16(8);\n      __m128i curs = _mm_slli_epi16(curr, 2);\n      __m128i prvd = _mm_sub_epi16(prev, curr);\n      __m128i nxtd = _mm_sub_epi16(next, curr);\n      __m128i curb = _mm_add_epi16(curs, bias);\n      __m128i even = _mm_add_epi16(prvd, curb);\n      __m128i odd  = _mm_add_epi16(nxtd, curb);\n\n      // interleave even and odd pixels, then undo scaling.\n      __m128i int0 = _mm_unpacklo_epi16(even, odd);\n      __m128i int1 = _mm_unpackhi_epi16(even, odd);\n      __m128i de0  = _mm_srli_epi16(int0, 4);\n      __m128i de1  = _mm_srli_epi16(int1, 4);\n\n      // pack and write output\n      __m128i outv = _mm_packus_epi16(de0, de1);\n      _mm_storeu_si128((__m128i *) (out + i*2), outv);\n#elif defined(STBI_NEON)\n      // load and perform the vertical filtering pass\n      // this uses 3*x + y = 4*x + (y - x)\n      uint8x8_t farb  = vld1_u8(in_far + i);\n      uint8x8_t nearb = vld1_u8(in_near + i);\n      int16x8_t diff  = vreinterpretq_s16_u16(vsubl_u8(farb, nearb));\n      int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2));\n      int16x8_t curr  = vaddq_s16(nears, diff); // current row\n\n      // horizontal filter works the same based on shifted vers of current\n      // row. \"prev\" is current row shifted right by 1 pixel; we need to\n      // insert the previous pixel value (from t1).\n      // \"next\" is current row shifted left by 1 pixel, with first pixel\n      // of next block of 8 pixels added in.\n      int16x8_t prv0 = vextq_s16(curr, curr, 7);\n      int16x8_t nxt0 = vextq_s16(curr, curr, 1);\n      int16x8_t prev = vsetq_lane_s16(t1, prv0, 0);\n      int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7);\n\n      // horizontal filter, polyphase implementation since it's convenient:\n      // even pixels = 3*cur + prev = cur*4 + (prev - cur)\n      // odd  pixels = 3*cur + next = cur*4 + (next - cur)\n      // note the shared term.\n      int16x8_t curs = vshlq_n_s16(curr, 2);\n      int16x8_t prvd = vsubq_s16(prev, curr);\n      int16x8_t nxtd = vsubq_s16(next, curr);\n      int16x8_t even = vaddq_s16(curs, prvd);\n      int16x8_t odd  = vaddq_s16(curs, nxtd);\n\n      // undo scaling and round, then store with even/odd phases interleaved\n      uint8x8x2_t o;\n      o.val[0] = vqrshrun_n_s16(even, 4);\n      o.val[1] = vqrshrun_n_s16(odd,  4);\n      vst2_u8(out + i*2, o);\n#endif\n\n      // \"previous\" value for next iter\n      t1 = 3*in_near[i+7] + in_far[i+7];\n   }\n\n   t0 = t1;\n   t1 = 3*in_near[i] + in_far[i];\n   out[i*2] = stbi__div16(3*t1 + t0 + 8);\n\n   for (++i; i < w; ++i) {\n      t0 = t1;\n      t1 = 3*in_near[i]+in_far[i];\n      out[i*2-1] = stbi__div16(3*t0 + t1 + 8);\n      out[i*2  ] = stbi__div16(3*t1 + t0 + 8);\n   }\n   out[w*2-1] = stbi__div4(t1+2);\n\n   STBI_NOTUSED(hs);\n\n   return out;\n}\n#endif\n\nstatic stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs)\n{\n   // resample with nearest-neighbor\n   int i,j;\n   STBI_NOTUSED(in_far);\n   for (i=0; i < w; ++i)\n      for (j=0; j < hs; ++j)\n         out[i*hs+j] = in_near[i];\n   return out;\n}\n\n// this is a reduced-precision calculation of YCbCr-to-RGB introduced\n// to make sure the code produces the same results in both SIMD and scalar\n#define stbi__float2fixed(x)  (((int) ((x) * 4096.0f + 0.5f)) << 8)\nstatic void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)\n{\n   int i;\n   for (i=0; i < count; ++i) {\n      int y_fixed = (y[i] << 20) + (1<<19); // rounding\n      int r,g,b;\n      int cr = pcr[i] - 128;\n      int cb = pcb[i] - 128;\n      r = y_fixed +  cr* stbi__float2fixed(1.40200f);\n      g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);\n      b = y_fixed                                     +   cb* stbi__float2fixed(1.77200f);\n      r >>= 20;\n      g >>= 20;\n      b >>= 20;\n      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }\n      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }\n      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }\n      out[0] = (stbi_uc)r;\n      out[1] = (stbi_uc)g;\n      out[2] = (stbi_uc)b;\n      out[3] = 255;\n      out += step;\n   }\n}\n\n#if defined(STBI_SSE2) || defined(STBI_NEON)\nstatic void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step)\n{\n   int i = 0;\n\n#ifdef STBI_SSE2\n   // step == 3 is pretty ugly on the final interleave, and i'm not convinced\n   // it's useful in practice (you wouldn't use it for textures, for example).\n   // so just accelerate step == 4 case.\n   if (step == 4) {\n      // this is a fairly straightforward implementation and not super-optimized.\n      __m128i signflip  = _mm_set1_epi8(-0x80);\n      __m128i cr_const0 = _mm_set1_epi16(   (short) ( 1.40200f*4096.0f+0.5f));\n      __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f));\n      __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f));\n      __m128i cb_const1 = _mm_set1_epi16(   (short) ( 1.77200f*4096.0f+0.5f));\n      __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128);\n      __m128i xw = _mm_set1_epi16(255); // alpha channel\n\n      for (; i+7 < count; i += 8) {\n         // load\n         __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i));\n         __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i));\n         __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i));\n         __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128\n         __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128\n\n         // unpack to short (and left-shift cr, cb by 8)\n         __m128i yw  = _mm_unpacklo_epi8(y_bias, y_bytes);\n         __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased);\n         __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased);\n\n         // color transform\n         __m128i yws = _mm_srli_epi16(yw, 4);\n         __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw);\n         __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw);\n         __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1);\n         __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1);\n         __m128i rws = _mm_add_epi16(cr0, yws);\n         __m128i gwt = _mm_add_epi16(cb0, yws);\n         __m128i bws = _mm_add_epi16(yws, cb1);\n         __m128i gws = _mm_add_epi16(gwt, cr1);\n\n         // descale\n         __m128i rw = _mm_srai_epi16(rws, 4);\n         __m128i bw = _mm_srai_epi16(bws, 4);\n         __m128i gw = _mm_srai_epi16(gws, 4);\n\n         // back to byte, set up for transpose\n         __m128i brb = _mm_packus_epi16(rw, bw);\n         __m128i gxb = _mm_packus_epi16(gw, xw);\n\n         // transpose to interleave channels\n         __m128i t0 = _mm_unpacklo_epi8(brb, gxb);\n         __m128i t1 = _mm_unpackhi_epi8(brb, gxb);\n         __m128i o0 = _mm_unpacklo_epi16(t0, t1);\n         __m128i o1 = _mm_unpackhi_epi16(t0, t1);\n\n         // store\n         _mm_storeu_si128((__m128i *) (out + 0), o0);\n         _mm_storeu_si128((__m128i *) (out + 16), o1);\n         out += 32;\n      }\n   }\n#endif\n\n#ifdef STBI_NEON\n   // in this version, step=3 support would be easy to add. but is there demand?\n   if (step == 4) {\n      // this is a fairly straightforward implementation and not super-optimized.\n      uint8x8_t signflip = vdup_n_u8(0x80);\n      int16x8_t cr_const0 = vdupq_n_s16(   (short) ( 1.40200f*4096.0f+0.5f));\n      int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f));\n      int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f));\n      int16x8_t cb_const1 = vdupq_n_s16(   (short) ( 1.77200f*4096.0f+0.5f));\n\n      for (; i+7 < count; i += 8) {\n         // load\n         uint8x8_t y_bytes  = vld1_u8(y + i);\n         uint8x8_t cr_bytes = vld1_u8(pcr + i);\n         uint8x8_t cb_bytes = vld1_u8(pcb + i);\n         int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip));\n         int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip));\n\n         // expand to s16\n         int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4));\n         int16x8_t crw = vshll_n_s8(cr_biased, 7);\n         int16x8_t cbw = vshll_n_s8(cb_biased, 7);\n\n         // color transform\n         int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0);\n         int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0);\n         int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1);\n         int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1);\n         int16x8_t rws = vaddq_s16(yws, cr0);\n         int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1);\n         int16x8_t bws = vaddq_s16(yws, cb1);\n\n         // undo scaling, round, convert to byte\n         uint8x8x4_t o;\n         o.val[0] = vqrshrun_n_s16(rws, 4);\n         o.val[1] = vqrshrun_n_s16(gws, 4);\n         o.val[2] = vqrshrun_n_s16(bws, 4);\n         o.val[3] = vdup_n_u8(255);\n\n         // store, interleaving r/g/b/a\n         vst4_u8(out, o);\n         out += 8*4;\n      }\n   }\n#endif\n\n   for (; i < count; ++i) {\n      int y_fixed = (y[i] << 20) + (1<<19); // rounding\n      int r,g,b;\n      int cr = pcr[i] - 128;\n      int cb = pcb[i] - 128;\n      r = y_fixed + cr* stbi__float2fixed(1.40200f);\n      g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000);\n      b = y_fixed                                   +   cb* stbi__float2fixed(1.77200f);\n      r >>= 20;\n      g >>= 20;\n      b >>= 20;\n      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }\n      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }\n      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }\n      out[0] = (stbi_uc)r;\n      out[1] = (stbi_uc)g;\n      out[2] = (stbi_uc)b;\n      out[3] = 255;\n      out += step;\n   }\n}\n#endif\n\n// set up the kernels\nstatic void stbi__setup_jpeg(stbi__jpeg *j)\n{\n   j->idct_block_kernel = stbi__idct_block;\n   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row;\n   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2;\n\n#ifdef STBI_SSE2\n   if (stbi__sse2_available()) {\n      j->idct_block_kernel = stbi__idct_simd;\n      j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;\n      j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;\n   }\n#endif\n\n#ifdef STBI_NEON\n   j->idct_block_kernel = stbi__idct_simd;\n   j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd;\n   j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd;\n#endif\n}\n\n// clean up the temporary component buffers\nstatic void stbi__cleanup_jpeg(stbi__jpeg *j)\n{\n   stbi__free_jpeg_components(j, j->s->img_n, 0);\n}\n\ntypedef struct\n{\n   resample_row_func resample;\n   stbi_uc *line0,*line1;\n   int hs,vs;   // expansion factor in each axis\n   int w_lores; // horizontal pixels pre-expansion\n   int ystep;   // how far through vertical expansion we are\n   int ypos;    // which pre-expansion row we're on\n} stbi__resample;\n\n// fast 0..255 * 0..255 => 0..255 rounded multiplication\nstatic stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y)\n{\n   unsigned int t = x*y + 128;\n   return (stbi_uc) ((t + (t >>8)) >> 8);\n}\n\nstatic stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp)\n{\n   int n, decode_n, is_rgb;\n   z->s->img_n = 0; // make stbi__cleanup_jpeg safe\n\n   // validate req_comp\n   if (req_comp < 0 || req_comp > 4) return stbi__errpuc(\"bad req_comp\", \"Internal error\");\n\n   // load a jpeg image from whichever source, but leave in YCbCr format\n   if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; }\n\n   // determine actual number of components to generate\n   n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1;\n\n   is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif));\n\n   if (z->s->img_n == 3 && n < 3 && !is_rgb)\n      decode_n = 1;\n   else\n      decode_n = z->s->img_n;\n\n   // resample and color-convert\n   {\n      int k;\n      unsigned int i,j;\n      stbi_uc *output;\n      stbi_uc *coutput[4];\n\n      stbi__resample res_comp[4];\n\n      for (k=0; k < decode_n; ++k) {\n         stbi__resample *r = &res_comp[k];\n\n         // allocate line buffer big enough for upsampling off the edges\n         // with upsample factor of 4\n         z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3);\n         if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc(\"outofmem\", \"Out of memory\"); }\n\n         r->hs      = z->img_h_max / z->img_comp[k].h;\n         r->vs      = z->img_v_max / z->img_comp[k].v;\n         r->ystep   = r->vs >> 1;\n         r->w_lores = (z->s->img_x + r->hs-1) / r->hs;\n         r->ypos    = 0;\n         r->line0   = r->line1 = z->img_comp[k].data;\n\n         if      (r->hs == 1 && r->vs == 1) r->resample = resample_row_1;\n         else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2;\n         else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2;\n         else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel;\n         else                               r->resample = stbi__resample_row_generic;\n      }\n\n      // can't error after this so, this is safe\n      output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1);\n      if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc(\"outofmem\", \"Out of memory\"); }\n\n      // now go ahead and resample\n      for (j=0; j < z->s->img_y; ++j) {\n         stbi_uc *out = output + n * z->s->img_x * j;\n         for (k=0; k < decode_n; ++k) {\n            stbi__resample *r = &res_comp[k];\n            int y_bot = r->ystep >= (r->vs >> 1);\n            coutput[k] = r->resample(z->img_comp[k].linebuf,\n                                     y_bot ? r->line1 : r->line0,\n                                     y_bot ? r->line0 : r->line1,\n                                     r->w_lores, r->hs);\n            if (++r->ystep >= r->vs) {\n               r->ystep = 0;\n               r->line0 = r->line1;\n               if (++r->ypos < z->img_comp[k].y)\n                  r->line1 += z->img_comp[k].w2;\n            }\n         }\n         if (n >= 3) {\n            stbi_uc *y = coutput[0];\n            if (z->s->img_n == 3) {\n               if (is_rgb) {\n                  for (i=0; i < z->s->img_x; ++i) {\n                     out[0] = y[i];\n                     out[1] = coutput[1][i];\n                     out[2] = coutput[2][i];\n                     out[3] = 255;\n                     out += n;\n                  }\n               } else {\n                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);\n               }\n            } else if (z->s->img_n == 4) {\n               if (z->app14_color_transform == 0) { // CMYK\n                  for (i=0; i < z->s->img_x; ++i) {\n                     stbi_uc k = coutput[3][i];\n                     out[0] = stbi__blinn_8x8(coutput[0][i], k);\n                     out[1] = stbi__blinn_8x8(coutput[1][i], k);\n                     out[2] = stbi__blinn_8x8(coutput[2][i], k);\n                     out[3] = 255;\n                     out += n;\n                  }\n               } else if (z->app14_color_transform == 2) { // YCCK\n                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);\n                  for (i=0; i < z->s->img_x; ++i) {\n                     stbi_uc k = coutput[3][i];\n                     out[0] = stbi__blinn_8x8(255 - out[0], k);\n                     out[1] = stbi__blinn_8x8(255 - out[1], k);\n                     out[2] = stbi__blinn_8x8(255 - out[2], k);\n                     out += n;\n                  }\n               } else { // YCbCr + alpha?  Ignore the fourth channel for now\n                  z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n);\n               }\n            } else\n               for (i=0; i < z->s->img_x; ++i) {\n                  out[0] = out[1] = out[2] = y[i];\n                  out[3] = 255; // not used if n==3\n                  out += n;\n               }\n         } else {\n            if (is_rgb) {\n               if (n == 1)\n                  for (i=0; i < z->s->img_x; ++i)\n                     *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);\n               else {\n                  for (i=0; i < z->s->img_x; ++i, out += 2) {\n                     out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]);\n                     out[1] = 255;\n                  }\n               }\n            } else if (z->s->img_n == 4 && z->app14_color_transform == 0) {\n               for (i=0; i < z->s->img_x; ++i) {\n                  stbi_uc k = coutput[3][i];\n                  stbi_uc r = stbi__blinn_8x8(coutput[0][i], k);\n                  stbi_uc g = stbi__blinn_8x8(coutput[1][i], k);\n                  stbi_uc b = stbi__blinn_8x8(coutput[2][i], k);\n                  out[0] = stbi__compute_y(r, g, b);\n                  out[1] = 255;\n                  out += n;\n               }\n            } else if (z->s->img_n == 4 && z->app14_color_transform == 2) {\n               for (i=0; i < z->s->img_x; ++i) {\n                  out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]);\n                  out[1] = 255;\n                  out += n;\n               }\n            } else {\n               stbi_uc *y = coutput[0];\n               if (n == 1)\n                  for (i=0; i < z->s->img_x; ++i) out[i] = y[i];\n               else\n                  for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255;\n            }\n         }\n      }\n      stbi__cleanup_jpeg(z);\n      *out_x = z->s->img_x;\n      *out_y = z->s->img_y;\n      if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output\n      return output;\n   }\n}\n\nstatic void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)\n{\n   unsigned char* result;\n   stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));\n   STBI_NOTUSED(ri);\n   j->s = s;\n   stbi__setup_jpeg(j);\n   result = load_jpeg_image(j, x,y,comp,req_comp);\n   STBI_FREE(j);\n   return result;\n}\n\nstatic int stbi__jpeg_test(stbi__context *s)\n{\n   int r;\n   stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));\n   j->s = s;\n   stbi__setup_jpeg(j);\n   r = stbi__decode_jpeg_header(j, STBI__SCAN_type);\n   stbi__rewind(s);\n   STBI_FREE(j);\n   return r;\n}\n\nstatic int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp)\n{\n   if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) {\n      stbi__rewind( j->s );\n      return 0;\n   }\n   if (x) *x = j->s->img_x;\n   if (y) *y = j->s->img_y;\n   if (comp) *comp = j->s->img_n >= 3 ? 3 : 1;\n   return 1;\n}\n\nstatic int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   int result;\n   stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));\n   j->s = s;\n   result = stbi__jpeg_info_raw(j, x, y, comp);\n   STBI_FREE(j);\n   return result;\n}\n#endif\n\n// public domain zlib decode    v0.2  Sean Barrett 2006-11-18\n//    simple implementation\n//      - all input must be provided in an upfront buffer\n//      - all output is written to a single output buffer (can malloc/realloc)\n//    performance\n//      - fast huffman\n\n#ifndef STBI_NO_ZLIB\n\n// fast-way is faster to check than jpeg huffman, but slow way is slower\n#define STBI__ZFAST_BITS  9 // accelerate all cases in default tables\n#define STBI__ZFAST_MASK  ((1 << STBI__ZFAST_BITS) - 1)\n\n// zlib-style huffman encoding\n// (jpegs packs from left, zlib from right, so can't share code)\ntypedef struct\n{\n   stbi__uint16 fast[1 << STBI__ZFAST_BITS];\n   stbi__uint16 firstcode[16];\n   int maxcode[17];\n   stbi__uint16 firstsymbol[16];\n   stbi_uc  size[288];\n   stbi__uint16 value[288];\n} stbi__zhuffman;\n\nstbi_inline static int stbi__bitreverse16(int n)\n{\n  n = ((n & 0xAAAA) >>  1) | ((n & 0x5555) << 1);\n  n = ((n & 0xCCCC) >>  2) | ((n & 0x3333) << 2);\n  n = ((n & 0xF0F0) >>  4) | ((n & 0x0F0F) << 4);\n  n = ((n & 0xFF00) >>  8) | ((n & 0x00FF) << 8);\n  return n;\n}\n\nstbi_inline static int stbi__bit_reverse(int v, int bits)\n{\n   STBI_ASSERT(bits <= 16);\n   // to bit reverse n bits, reverse 16 and shift\n   // e.g. 11 bits, bit reverse and shift away 5\n   return stbi__bitreverse16(v) >> (16-bits);\n}\n\nstatic int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num)\n{\n   int i,k=0;\n   int code, next_code[16], sizes[17];\n\n   // DEFLATE spec for generating codes\n   memset(sizes, 0, sizeof(sizes));\n   memset(z->fast, 0, sizeof(z->fast));\n   for (i=0; i < num; ++i)\n      ++sizes[sizelist[i]];\n   sizes[0] = 0;\n   for (i=1; i < 16; ++i)\n      if (sizes[i] > (1 << i))\n         return stbi__err(\"bad sizes\", \"Corrupt PNG\");\n   code = 0;\n   for (i=1; i < 16; ++i) {\n      next_code[i] = code;\n      z->firstcode[i] = (stbi__uint16) code;\n      z->firstsymbol[i] = (stbi__uint16) k;\n      code = (code + sizes[i]);\n      if (sizes[i])\n         if (code-1 >= (1 << i)) return stbi__err(\"bad codelengths\",\"Corrupt PNG\");\n      z->maxcode[i] = code << (16-i); // preshift for inner loop\n      code <<= 1;\n      k += sizes[i];\n   }\n   z->maxcode[16] = 0x10000; // sentinel\n   for (i=0; i < num; ++i) {\n      int s = sizelist[i];\n      if (s) {\n         int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s];\n         stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i);\n         z->size [c] = (stbi_uc     ) s;\n         z->value[c] = (stbi__uint16) i;\n         if (s <= STBI__ZFAST_BITS) {\n            int j = stbi__bit_reverse(next_code[s],s);\n            while (j < (1 << STBI__ZFAST_BITS)) {\n               z->fast[j] = fastv;\n               j += (1 << s);\n            }\n         }\n         ++next_code[s];\n      }\n   }\n   return 1;\n}\n\n// zlib-from-memory implementation for PNG reading\n//    because PNG allows splitting the zlib stream arbitrarily,\n//    and it's annoying structurally to have PNG call ZLIB call PNG,\n//    we require PNG read all the IDATs and combine them into a single\n//    memory buffer\n\ntypedef struct\n{\n   stbi_uc *zbuffer, *zbuffer_end;\n   int num_bits;\n   stbi__uint32 code_buffer;\n\n   char *zout;\n   char *zout_start;\n   char *zout_end;\n   int   z_expandable;\n\n   stbi__zhuffman z_length, z_distance;\n} stbi__zbuf;\n\nstbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z)\n{\n   if (z->zbuffer >= z->zbuffer_end) return 0;\n   return *z->zbuffer++;\n}\n\nstatic void stbi__fill_bits(stbi__zbuf *z)\n{\n   do {\n      STBI_ASSERT(z->code_buffer < (1U << z->num_bits));\n      z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits;\n      z->num_bits += 8;\n   } while (z->num_bits <= 24);\n}\n\nstbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n)\n{\n   unsigned int k;\n   if (z->num_bits < n) stbi__fill_bits(z);\n   k = z->code_buffer & ((1 << n) - 1);\n   z->code_buffer >>= n;\n   z->num_bits -= n;\n   return k;\n}\n\nstatic int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z)\n{\n   int b,s,k;\n   // not resolved by fast table, so compute it the slow way\n   // use jpeg approach, which requires MSbits at top\n   k = stbi__bit_reverse(a->code_buffer, 16);\n   for (s=STBI__ZFAST_BITS+1; ; ++s)\n      if (k < z->maxcode[s])\n         break;\n   if (s == 16) return -1; // invalid code!\n   // code size is s, so:\n   b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s];\n   STBI_ASSERT(z->size[b] == s);\n   a->code_buffer >>= s;\n   a->num_bits -= s;\n   return z->value[b];\n}\n\nstbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z)\n{\n   int b,s;\n   if (a->num_bits < 16) stbi__fill_bits(a);\n   b = z->fast[a->code_buffer & STBI__ZFAST_MASK];\n   if (b) {\n      s = b >> 9;\n      a->code_buffer >>= s;\n      a->num_bits -= s;\n      return b & 511;\n   }\n   return stbi__zhuffman_decode_slowpath(a, z);\n}\n\nstatic int stbi__zexpand(stbi__zbuf *z, char *zout, int n)  // need to make room for n bytes\n{\n   char *q;\n   int cur, limit, old_limit;\n   z->zout = zout;\n   if (!z->z_expandable) return stbi__err(\"output buffer limit\",\"Corrupt PNG\");\n   cur   = (int) (z->zout     - z->zout_start);\n   limit = old_limit = (int) (z->zout_end - z->zout_start);\n   while (cur + n > limit)\n      limit *= 2;\n   q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit);\n   STBI_NOTUSED(old_limit);\n   if (q == NULL) return stbi__err(\"outofmem\", \"Out of memory\");\n   z->zout_start = q;\n   z->zout       = q + cur;\n   z->zout_end   = q + limit;\n   return 1;\n}\n\nstatic int stbi__zlength_base[31] = {\n   3,4,5,6,7,8,9,10,11,13,\n   15,17,19,23,27,31,35,43,51,59,\n   67,83,99,115,131,163,195,227,258,0,0 };\n\nstatic int stbi__zlength_extra[31]=\n{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 };\n\nstatic int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,\n257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0};\n\nstatic int stbi__zdist_extra[32] =\n{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};\n\nstatic int stbi__parse_huffman_block(stbi__zbuf *a)\n{\n   char *zout = a->zout;\n   for(;;) {\n      int z = stbi__zhuffman_decode(a, &a->z_length);\n      if (z < 256) {\n         if (z < 0) return stbi__err(\"bad huffman code\",\"Corrupt PNG\"); // error in huffman codes\n         if (zout >= a->zout_end) {\n            if (!stbi__zexpand(a, zout, 1)) return 0;\n            zout = a->zout;\n         }\n         *zout++ = (char) z;\n      } else {\n         stbi_uc *p;\n         int len,dist;\n         if (z == 256) {\n            a->zout = zout;\n            return 1;\n         }\n         z -= 257;\n         len = stbi__zlength_base[z];\n         if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]);\n         z = stbi__zhuffman_decode(a, &a->z_distance);\n         if (z < 0) return stbi__err(\"bad huffman code\",\"Corrupt PNG\");\n         dist = stbi__zdist_base[z];\n         if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]);\n         if (zout - a->zout_start < dist) return stbi__err(\"bad dist\",\"Corrupt PNG\");\n         if (zout + len > a->zout_end) {\n            if (!stbi__zexpand(a, zout, len)) return 0;\n            zout = a->zout;\n         }\n         p = (stbi_uc *) (zout - dist);\n         if (dist == 1) { // run of one byte; common in images.\n            stbi_uc v = *p;\n            if (len) { do *zout++ = v; while (--len); }\n         } else {\n            if (len) { do *zout++ = *p++; while (--len); }\n         }\n      }\n   }\n}\n\nstatic int stbi__compute_huffman_codes(stbi__zbuf *a)\n{\n   static stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };\n   stbi__zhuffman z_codelength;\n   stbi_uc lencodes[286+32+137];//padding for maximum single op\n   stbi_uc codelength_sizes[19];\n   int i,n;\n\n   int hlit  = stbi__zreceive(a,5) + 257;\n   int hdist = stbi__zreceive(a,5) + 1;\n   int hclen = stbi__zreceive(a,4) + 4;\n   int ntot  = hlit + hdist;\n\n   memset(codelength_sizes, 0, sizeof(codelength_sizes));\n   for (i=0; i < hclen; ++i) {\n      int s = stbi__zreceive(a,3);\n      codelength_sizes[length_dezigzag[i]] = (stbi_uc) s;\n   }\n   if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0;\n\n   n = 0;\n   while (n < ntot) {\n      int c = stbi__zhuffman_decode(a, &z_codelength);\n      if (c < 0 || c >= 19) return stbi__err(\"bad codelengths\", \"Corrupt PNG\");\n      if (c < 16)\n         lencodes[n++] = (stbi_uc) c;\n      else {\n         stbi_uc fill = 0;\n         if (c == 16) {\n            c = stbi__zreceive(a,2)+3;\n            if (n == 0) return stbi__err(\"bad codelengths\", \"Corrupt PNG\");\n            fill = lencodes[n-1];\n         } else if (c == 17)\n            c = stbi__zreceive(a,3)+3;\n         else {\n            STBI_ASSERT(c == 18);\n            c = stbi__zreceive(a,7)+11;\n         }\n         if (ntot - n < c) return stbi__err(\"bad codelengths\", \"Corrupt PNG\");\n         memset(lencodes+n, fill, c);\n         n += c;\n      }\n   }\n   if (n != ntot) return stbi__err(\"bad codelengths\",\"Corrupt PNG\");\n   if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0;\n   if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0;\n   return 1;\n}\n\nstatic int stbi__parse_uncompressed_block(stbi__zbuf *a)\n{\n   stbi_uc header[4];\n   int len,nlen,k;\n   if (a->num_bits & 7)\n      stbi__zreceive(a, a->num_bits & 7); // discard\n   // drain the bit-packed data into header\n   k = 0;\n   while (a->num_bits > 0) {\n      header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check\n      a->code_buffer >>= 8;\n      a->num_bits -= 8;\n   }\n   STBI_ASSERT(a->num_bits == 0);\n   // now fill header the normal way\n   while (k < 4)\n      header[k++] = stbi__zget8(a);\n   len  = header[1] * 256 + header[0];\n   nlen = header[3] * 256 + header[2];\n   if (nlen != (len ^ 0xffff)) return stbi__err(\"zlib corrupt\",\"Corrupt PNG\");\n   if (a->zbuffer + len > a->zbuffer_end) return stbi__err(\"read past buffer\",\"Corrupt PNG\");\n   if (a->zout + len > a->zout_end)\n      if (!stbi__zexpand(a, a->zout, len)) return 0;\n   memcpy(a->zout, a->zbuffer, len);\n   a->zbuffer += len;\n   a->zout += len;\n   return 1;\n}\n\nstatic int stbi__parse_zlib_header(stbi__zbuf *a)\n{\n   int cmf   = stbi__zget8(a);\n   int cm    = cmf & 15;\n   /* int cinfo = cmf >> 4; */\n   int flg   = stbi__zget8(a);\n   if ((cmf*256+flg) % 31 != 0) return stbi__err(\"bad zlib header\",\"Corrupt PNG\"); // zlib spec\n   if (flg & 32) return stbi__err(\"no preset dict\",\"Corrupt PNG\"); // preset dictionary not allowed in png\n   if (cm != 8) return stbi__err(\"bad compression\",\"Corrupt PNG\"); // DEFLATE required for png\n   // window = 1 << (8 + cinfo)... but who cares, we fully buffer output\n   return 1;\n}\n\nstatic const stbi_uc stbi__zdefault_length[288] =\n{\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,\n   8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n   7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8\n};\nstatic const stbi_uc stbi__zdefault_distance[32] =\n{\n   5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5\n};\n/*\nInit algorithm:\n{\n   int i;   // use <= to match clearly with spec\n   for (i=0; i <= 143; ++i)     stbi__zdefault_length[i]   = 8;\n   for (   ; i <= 255; ++i)     stbi__zdefault_length[i]   = 9;\n   for (   ; i <= 279; ++i)     stbi__zdefault_length[i]   = 7;\n   for (   ; i <= 287; ++i)     stbi__zdefault_length[i]   = 8;\n\n   for (i=0; i <=  31; ++i)     stbi__zdefault_distance[i] = 5;\n}\n*/\n\nstatic int stbi__parse_zlib(stbi__zbuf *a, int parse_header)\n{\n   int final, type;\n   if (parse_header)\n      if (!stbi__parse_zlib_header(a)) return 0;\n   a->num_bits = 0;\n   a->code_buffer = 0;\n   do {\n      final = stbi__zreceive(a,1);\n      type = stbi__zreceive(a,2);\n      if (type == 0) {\n         if (!stbi__parse_uncompressed_block(a)) return 0;\n      } else if (type == 3) {\n         return 0;\n      } else {\n         if (type == 1) {\n            // use fixed code lengths\n            if (!stbi__zbuild_huffman(&a->z_length  , stbi__zdefault_length  , 288)) return 0;\n            if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance,  32)) return 0;\n         } else {\n            if (!stbi__compute_huffman_codes(a)) return 0;\n         }\n         if (!stbi__parse_huffman_block(a)) return 0;\n      }\n   } while (!final);\n   return 1;\n}\n\nstatic int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header)\n{\n   a->zout_start = obuf;\n   a->zout       = obuf;\n   a->zout_end   = obuf + olen;\n   a->z_expandable = exp;\n\n   return stbi__parse_zlib(a, parse_header);\n}\n\nSTBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen)\n{\n   stbi__zbuf a;\n   char *p = (char *) stbi__malloc(initial_size);\n   if (p == NULL) return NULL;\n   a.zbuffer = (stbi_uc *) buffer;\n   a.zbuffer_end = (stbi_uc *) buffer + len;\n   if (stbi__do_zlib(&a, p, initial_size, 1, 1)) {\n      if (outlen) *outlen = (int) (a.zout - a.zout_start);\n      return a.zout_start;\n   } else {\n      STBI_FREE(a.zout_start);\n      return NULL;\n   }\n}\n\nSTBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen)\n{\n   return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen);\n}\n\nSTBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header)\n{\n   stbi__zbuf a;\n   char *p = (char *) stbi__malloc(initial_size);\n   if (p == NULL) return NULL;\n   a.zbuffer = (stbi_uc *) buffer;\n   a.zbuffer_end = (stbi_uc *) buffer + len;\n   if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) {\n      if (outlen) *outlen = (int) (a.zout - a.zout_start);\n      return a.zout_start;\n   } else {\n      STBI_FREE(a.zout_start);\n      return NULL;\n   }\n}\n\nSTBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen)\n{\n   stbi__zbuf a;\n   a.zbuffer = (stbi_uc *) ibuffer;\n   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;\n   if (stbi__do_zlib(&a, obuffer, olen, 0, 1))\n      return (int) (a.zout - a.zout_start);\n   else\n      return -1;\n}\n\nSTBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen)\n{\n   stbi__zbuf a;\n   char *p = (char *) stbi__malloc(16384);\n   if (p == NULL) return NULL;\n   a.zbuffer = (stbi_uc *) buffer;\n   a.zbuffer_end = (stbi_uc *) buffer+len;\n   if (stbi__do_zlib(&a, p, 16384, 1, 0)) {\n      if (outlen) *outlen = (int) (a.zout - a.zout_start);\n      return a.zout_start;\n   } else {\n      STBI_FREE(a.zout_start);\n      return NULL;\n   }\n}\n\nSTBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen)\n{\n   stbi__zbuf a;\n   a.zbuffer = (stbi_uc *) ibuffer;\n   a.zbuffer_end = (stbi_uc *) ibuffer + ilen;\n   if (stbi__do_zlib(&a, obuffer, olen, 0, 0))\n      return (int) (a.zout - a.zout_start);\n   else\n      return -1;\n}\n#endif\n\n// public domain \"baseline\" PNG decoder   v0.10  Sean Barrett 2006-11-18\n//    simple implementation\n//      - only 8-bit samples\n//      - no CRC checking\n//      - allocates lots of intermediate memory\n//        - avoids problem of streaming data between subsystems\n//        - avoids explicit window management\n//    performance\n//      - uses stb_zlib, a PD zlib implementation with fast huffman decoding\n\n#ifndef STBI_NO_PNG\ntypedef struct\n{\n   stbi__uint32 length;\n   stbi__uint32 type;\n} stbi__pngchunk;\n\nstatic stbi__pngchunk stbi__get_chunk_header(stbi__context *s)\n{\n   stbi__pngchunk c;\n   c.length = stbi__get32be(s);\n   c.type   = stbi__get32be(s);\n   return c;\n}\n\nstatic int stbi__check_png_header(stbi__context *s)\n{\n   static stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 };\n   int i;\n   for (i=0; i < 8; ++i)\n      if (stbi__get8(s) != png_sig[i]) return stbi__err(\"bad png sig\",\"Not a PNG\");\n   return 1;\n}\n\ntypedef struct\n{\n   stbi__context *s;\n   stbi_uc *idata, *expanded, *out;\n   int depth;\n} stbi__png;\n\n\nenum {\n   STBI__F_none=0,\n   STBI__F_sub=1,\n   STBI__F_up=2,\n   STBI__F_avg=3,\n   STBI__F_paeth=4,\n   // synthetic filters used for first scanline to avoid needing a dummy row of 0s\n   STBI__F_avg_first,\n   STBI__F_paeth_first\n};\n\nstatic stbi_uc first_row_filter[5] =\n{\n   STBI__F_none,\n   STBI__F_sub,\n   STBI__F_none,\n   STBI__F_avg_first,\n   STBI__F_paeth_first\n};\n\nstatic int stbi__paeth(int a, int b, int c)\n{\n   int p = a + b - c;\n   int pa = abs(p-a);\n   int pb = abs(p-b);\n   int pc = abs(p-c);\n   if (pa <= pb && pa <= pc) return a;\n   if (pb <= pc) return b;\n   return c;\n}\n\nstatic stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 };\n\n// create the png data from post-deflated data\nstatic int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color)\n{\n   int bytes = (depth == 16? 2 : 1);\n   stbi__context *s = a->s;\n   stbi__uint32 i,j,stride = x*out_n*bytes;\n   stbi__uint32 img_len, img_width_bytes;\n   int k;\n   int img_n = s->img_n; // copy it into a local for later\n\n   int output_bytes = out_n*bytes;\n   int filter_bytes = img_n*bytes;\n   int width = x;\n\n   STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1);\n   a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into\n   if (!a->out) return stbi__err(\"outofmem\", \"Out of memory\");\n\n   img_width_bytes = (((img_n * x * depth) + 7) >> 3);\n   img_len = (img_width_bytes + 1) * y;\n   if (s->img_x == x && s->img_y == y) {\n      if (raw_len != img_len) return stbi__err(\"not enough pixels\",\"Corrupt PNG\");\n   } else { // interlaced:\n      if (raw_len < img_len) return stbi__err(\"not enough pixels\",\"Corrupt PNG\");\n   }\n\n   for (j=0; j < y; ++j) {\n      stbi_uc *cur = a->out + stride*j;\n      stbi_uc *prior;\n      int filter = *raw++;\n\n      if (filter > 4)\n         return stbi__err(\"invalid filter\",\"Corrupt PNG\");\n\n      if (depth < 8) {\n         STBI_ASSERT(img_width_bytes <= x);\n         cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place\n         filter_bytes = 1;\n         width = img_width_bytes;\n      }\n      prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above\n\n      // if first row, use special filter that doesn't sample previous row\n      if (j == 0) filter = first_row_filter[filter];\n\n      // handle first byte explicitly\n      for (k=0; k < filter_bytes; ++k) {\n         switch (filter) {\n            case STBI__F_none       : cur[k] = raw[k]; break;\n            case STBI__F_sub        : cur[k] = raw[k]; break;\n            case STBI__F_up         : cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break;\n            case STBI__F_avg        : cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); break;\n            case STBI__F_paeth      : cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0,prior[k],0)); break;\n            case STBI__F_avg_first  : cur[k] = raw[k]; break;\n            case STBI__F_paeth_first: cur[k] = raw[k]; break;\n         }\n      }\n\n      if (depth == 8) {\n         if (img_n != out_n)\n            cur[img_n] = 255; // first pixel\n         raw += img_n;\n         cur += out_n;\n         prior += out_n;\n      } else if (depth == 16) {\n         if (img_n != out_n) {\n            cur[filter_bytes]   = 255; // first pixel top byte\n            cur[filter_bytes+1] = 255; // first pixel bottom byte\n         }\n         raw += filter_bytes;\n         cur += output_bytes;\n         prior += output_bytes;\n      } else {\n         raw += 1;\n         cur += 1;\n         prior += 1;\n      }\n\n      // this is a little gross, so that we don't switch per-pixel or per-component\n      if (depth < 8 || img_n == out_n) {\n         int nk = (width - 1)*filter_bytes;\n         #define STBI__CASE(f) \\\n             case f:     \\\n                for (k=0; k < nk; ++k)\n         switch (filter) {\n            // \"none\" filter turns into a memcpy here; make that explicit.\n            case STBI__F_none:         memcpy(cur, raw, nk); break;\n            STBI__CASE(STBI__F_sub)          { cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); } break;\n            STBI__CASE(STBI__F_up)           { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;\n            STBI__CASE(STBI__F_avg)          { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); } break;\n            STBI__CASE(STBI__F_paeth)        { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],prior[k],prior[k-filter_bytes])); } break;\n            STBI__CASE(STBI__F_avg_first)    { cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); } break;\n            STBI__CASE(STBI__F_paeth_first)  { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes],0,0)); } break;\n         }\n         #undef STBI__CASE\n         raw += nk;\n      } else {\n         STBI_ASSERT(img_n+1 == out_n);\n         #define STBI__CASE(f) \\\n             case f:     \\\n                for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \\\n                   for (k=0; k < filter_bytes; ++k)\n         switch (filter) {\n            STBI__CASE(STBI__F_none)         { cur[k] = raw[k]; } break;\n            STBI__CASE(STBI__F_sub)          { cur[k] = STBI__BYTECAST(raw[k] + cur[k- output_bytes]); } break;\n            STBI__CASE(STBI__F_up)           { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break;\n            STBI__CASE(STBI__F_avg)          { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k- output_bytes])>>1)); } break;\n            STBI__CASE(STBI__F_paeth)        { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],prior[k],prior[k- output_bytes])); } break;\n            STBI__CASE(STBI__F_avg_first)    { cur[k] = STBI__BYTECAST(raw[k] + (cur[k- output_bytes] >> 1)); } break;\n            STBI__CASE(STBI__F_paeth_first)  { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k- output_bytes],0,0)); } break;\n         }\n         #undef STBI__CASE\n\n         // the loop above sets the high byte of the pixels' alpha, but for\n         // 16 bit png files we also need the low byte set. we'll do that here.\n         if (depth == 16) {\n            cur = a->out + stride*j; // start at the beginning of the row again\n            for (i=0; i < x; ++i,cur+=output_bytes) {\n               cur[filter_bytes+1] = 255;\n            }\n         }\n      }\n   }\n\n   // we make a separate pass to expand bits to pixels; for performance,\n   // this could run two scanlines behind the above code, so it won't\n   // intefere with filtering but will still be in the cache.\n   if (depth < 8) {\n      for (j=0; j < y; ++j) {\n         stbi_uc *cur = a->out + stride*j;\n         stbi_uc *in  = a->out + stride*j + x*out_n - img_width_bytes;\n         // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit\n         // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop\n         stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range\n\n         // note that the final byte might overshoot and write more data than desired.\n         // we can allocate enough data that this never writes out of memory, but it\n         // could also overwrite the next scanline. can it overwrite non-empty data\n         // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel.\n         // so we need to explicitly clamp the final ones\n\n         if (depth == 4) {\n            for (k=x*img_n; k >= 2; k-=2, ++in) {\n               *cur++ = scale * ((*in >> 4)       );\n               *cur++ = scale * ((*in     ) & 0x0f);\n            }\n            if (k > 0) *cur++ = scale * ((*in >> 4)       );\n         } else if (depth == 2) {\n            for (k=x*img_n; k >= 4; k-=4, ++in) {\n               *cur++ = scale * ((*in >> 6)       );\n               *cur++ = scale * ((*in >> 4) & 0x03);\n               *cur++ = scale * ((*in >> 2) & 0x03);\n               *cur++ = scale * ((*in     ) & 0x03);\n            }\n            if (k > 0) *cur++ = scale * ((*in >> 6)       );\n            if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03);\n            if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03);\n         } else if (depth == 1) {\n            for (k=x*img_n; k >= 8; k-=8, ++in) {\n               *cur++ = scale * ((*in >> 7)       );\n               *cur++ = scale * ((*in >> 6) & 0x01);\n               *cur++ = scale * ((*in >> 5) & 0x01);\n               *cur++ = scale * ((*in >> 4) & 0x01);\n               *cur++ = scale * ((*in >> 3) & 0x01);\n               *cur++ = scale * ((*in >> 2) & 0x01);\n               *cur++ = scale * ((*in >> 1) & 0x01);\n               *cur++ = scale * ((*in     ) & 0x01);\n            }\n            if (k > 0) *cur++ = scale * ((*in >> 7)       );\n            if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01);\n            if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01);\n            if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01);\n            if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01);\n            if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01);\n            if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01);\n         }\n         if (img_n != out_n) {\n            int q;\n            // insert alpha = 255\n            cur = a->out + stride*j;\n            if (img_n == 1) {\n               for (q=x-1; q >= 0; --q) {\n                  cur[q*2+1] = 255;\n                  cur[q*2+0] = cur[q];\n               }\n            } else {\n               STBI_ASSERT(img_n == 3);\n               for (q=x-1; q >= 0; --q) {\n                  cur[q*4+3] = 255;\n                  cur[q*4+2] = cur[q*3+2];\n                  cur[q*4+1] = cur[q*3+1];\n                  cur[q*4+0] = cur[q*3+0];\n               }\n            }\n         }\n      }\n   } else if (depth == 16) {\n      // force the image data from big-endian to platform-native.\n      // this is done in a separate pass due to the decoding relying\n      // on the data being untouched, but could probably be done\n      // per-line during decode if care is taken.\n      stbi_uc *cur = a->out;\n      stbi__uint16 *cur16 = (stbi__uint16*)cur;\n\n      for(i=0; i < x*y*out_n; ++i,cur16++,cur+=2) {\n         *cur16 = (cur[0] << 8) | cur[1];\n      }\n   }\n\n   return 1;\n}\n\nstatic int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced)\n{\n   int bytes = (depth == 16 ? 2 : 1);\n   int out_bytes = out_n * bytes;\n   stbi_uc *final;\n   int p;\n   if (!interlaced)\n      return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color);\n\n   // de-interlacing\n   final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0);\n   for (p=0; p < 7; ++p) {\n      int xorig[] = { 0,4,0,2,0,1,0 };\n      int yorig[] = { 0,0,4,0,2,0,1 };\n      int xspc[]  = { 8,8,4,4,2,2,1 };\n      int yspc[]  = { 8,8,8,4,4,2,2 };\n      int i,j,x,y;\n      // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1\n      x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p];\n      y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p];\n      if (x && y) {\n         stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y;\n         if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) {\n            STBI_FREE(final);\n            return 0;\n         }\n         for (j=0; j < y; ++j) {\n            for (i=0; i < x; ++i) {\n               int out_y = j*yspc[p]+yorig[p];\n               int out_x = i*xspc[p]+xorig[p];\n               memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes,\n                      a->out + (j*x+i)*out_bytes, out_bytes);\n            }\n         }\n         STBI_FREE(a->out);\n         image_data += img_len;\n         image_data_len -= img_len;\n      }\n   }\n   a->out = final;\n\n   return 1;\n}\n\nstatic int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n)\n{\n   stbi__context *s = z->s;\n   stbi__uint32 i, pixel_count = s->img_x * s->img_y;\n   stbi_uc *p = z->out;\n\n   // compute color-based transparency, assuming we've\n   // already got 255 as the alpha value in the output\n   STBI_ASSERT(out_n == 2 || out_n == 4);\n\n   if (out_n == 2) {\n      for (i=0; i < pixel_count; ++i) {\n         p[1] = (p[0] == tc[0] ? 0 : 255);\n         p += 2;\n      }\n   } else {\n      for (i=0; i < pixel_count; ++i) {\n         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])\n            p[3] = 0;\n         p += 4;\n      }\n   }\n   return 1;\n}\n\nstatic int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n)\n{\n   stbi__context *s = z->s;\n   stbi__uint32 i, pixel_count = s->img_x * s->img_y;\n   stbi__uint16 *p = (stbi__uint16*) z->out;\n\n   // compute color-based transparency, assuming we've\n   // already got 65535 as the alpha value in the output\n   STBI_ASSERT(out_n == 2 || out_n == 4);\n\n   if (out_n == 2) {\n      for (i = 0; i < pixel_count; ++i) {\n         p[1] = (p[0] == tc[0] ? 0 : 65535);\n         p += 2;\n      }\n   } else {\n      for (i = 0; i < pixel_count; ++i) {\n         if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2])\n            p[3] = 0;\n         p += 4;\n      }\n   }\n   return 1;\n}\n\nstatic int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n)\n{\n   stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y;\n   stbi_uc *p, *temp_out, *orig = a->out;\n\n   p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0);\n   if (p == NULL) return stbi__err(\"outofmem\", \"Out of memory\");\n\n   // between here and free(out) below, exitting would leak\n   temp_out = p;\n\n   if (pal_img_n == 3) {\n      for (i=0; i < pixel_count; ++i) {\n         int n = orig[i]*4;\n         p[0] = palette[n  ];\n         p[1] = palette[n+1];\n         p[2] = palette[n+2];\n         p += 3;\n      }\n   } else {\n      for (i=0; i < pixel_count; ++i) {\n         int n = orig[i]*4;\n         p[0] = palette[n  ];\n         p[1] = palette[n+1];\n         p[2] = palette[n+2];\n         p[3] = palette[n+3];\n         p += 4;\n      }\n   }\n   STBI_FREE(a->out);\n   a->out = temp_out;\n\n   STBI_NOTUSED(len);\n\n   return 1;\n}\n\nstatic int stbi__unpremultiply_on_load = 0;\nstatic int stbi__de_iphone_flag = 0;\n\nSTBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply)\n{\n   stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply;\n}\n\nSTBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert)\n{\n   stbi__de_iphone_flag = flag_true_if_should_convert;\n}\n\nstatic void stbi__de_iphone(stbi__png *z)\n{\n   stbi__context *s = z->s;\n   stbi__uint32 i, pixel_count = s->img_x * s->img_y;\n   stbi_uc *p = z->out;\n\n   if (s->img_out_n == 3) {  // convert bgr to rgb\n      for (i=0; i < pixel_count; ++i) {\n         stbi_uc t = p[0];\n         p[0] = p[2];\n         p[2] = t;\n         p += 3;\n      }\n   } else {\n      STBI_ASSERT(s->img_out_n == 4);\n      if (stbi__unpremultiply_on_load) {\n         // convert bgr to rgb and unpremultiply\n         for (i=0; i < pixel_count; ++i) {\n            stbi_uc a = p[3];\n            stbi_uc t = p[0];\n            if (a) {\n               p[0] = p[2] * 255 / a;\n               p[1] = p[1] * 255 / a;\n               p[2] =  t   * 255 / a;\n            } else {\n               p[0] = p[2];\n               p[2] = t;\n            }\n            p += 4;\n         }\n      } else {\n         // convert bgr to rgb\n         for (i=0; i < pixel_count; ++i) {\n            stbi_uc t = p[0];\n            p[0] = p[2];\n            p[2] = t;\n            p += 4;\n         }\n      }\n   }\n}\n\n#define STBI__PNG_TYPE(a,b,c,d)  (((a) << 24) + ((b) << 16) + ((c) << 8) + (d))\n\nstatic int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)\n{\n   stbi_uc palette[1024], pal_img_n=0;\n   stbi_uc has_trans=0, tc[3];\n   stbi__uint16 tc16[3];\n   stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0;\n   int first=1,k,interlace=0, color=0, is_iphone=0;\n   stbi__context *s = z->s;\n\n   z->expanded = NULL;\n   z->idata = NULL;\n   z->out = NULL;\n\n   if (!stbi__check_png_header(s)) return 0;\n\n   if (scan == STBI__SCAN_type) return 1;\n\n   for (;;) {\n      stbi__pngchunk c = stbi__get_chunk_header(s);\n      switch (c.type) {\n         case STBI__PNG_TYPE('C','g','B','I'):\n            is_iphone = 1;\n            stbi__skip(s, c.length);\n            break;\n         case STBI__PNG_TYPE('I','H','D','R'): {\n            int comp,filter;\n            if (!first) return stbi__err(\"multiple IHDR\",\"Corrupt PNG\");\n            first = 0;\n            if (c.length != 13) return stbi__err(\"bad IHDR len\",\"Corrupt PNG\");\n            s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err(\"too large\",\"Very large image (corrupt?)\");\n            s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err(\"too large\",\"Very large image (corrupt?)\");\n            z->depth = stbi__get8(s);  if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16)  return stbi__err(\"1/2/4/8/16-bit only\",\"PNG not supported: 1/2/4/8/16-bit only\");\n            color = stbi__get8(s);  if (color > 6)         return stbi__err(\"bad ctype\",\"Corrupt PNG\");\n            if (color == 3 && z->depth == 16)                  return stbi__err(\"bad ctype\",\"Corrupt PNG\");\n            if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err(\"bad ctype\",\"Corrupt PNG\");\n            comp  = stbi__get8(s);  if (comp) return stbi__err(\"bad comp method\",\"Corrupt PNG\");\n            filter= stbi__get8(s);  if (filter) return stbi__err(\"bad filter method\",\"Corrupt PNG\");\n            interlace = stbi__get8(s); if (interlace>1) return stbi__err(\"bad interlace method\",\"Corrupt PNG\");\n            if (!s->img_x || !s->img_y) return stbi__err(\"0-pixel image\",\"Corrupt PNG\");\n            if (!pal_img_n) {\n               s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0);\n               if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err(\"too large\", \"Image too large to decode\");\n               if (scan == STBI__SCAN_header) return 1;\n            } else {\n               // if paletted, then pal_n is our final components, and\n               // img_n is # components to decompress/filter.\n               s->img_n = 1;\n               if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err(\"too large\",\"Corrupt PNG\");\n               // if SCAN_header, have to scan to see if we have a tRNS\n            }\n            break;\n         }\n\n         case STBI__PNG_TYPE('P','L','T','E'):  {\n            if (first) return stbi__err(\"first not IHDR\", \"Corrupt PNG\");\n            if (c.length > 256*3) return stbi__err(\"invalid PLTE\",\"Corrupt PNG\");\n            pal_len = c.length / 3;\n            if (pal_len * 3 != c.length) return stbi__err(\"invalid PLTE\",\"Corrupt PNG\");\n            for (i=0; i < pal_len; ++i) {\n               palette[i*4+0] = stbi__get8(s);\n               palette[i*4+1] = stbi__get8(s);\n               palette[i*4+2] = stbi__get8(s);\n               palette[i*4+3] = 255;\n            }\n            break;\n         }\n\n         case STBI__PNG_TYPE('t','R','N','S'): {\n            if (first) return stbi__err(\"first not IHDR\", \"Corrupt PNG\");\n            if (z->idata) return stbi__err(\"tRNS after IDAT\",\"Corrupt PNG\");\n            if (pal_img_n) {\n               if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; }\n               if (pal_len == 0) return stbi__err(\"tRNS before PLTE\",\"Corrupt PNG\");\n               if (c.length > pal_len) return stbi__err(\"bad tRNS len\",\"Corrupt PNG\");\n               pal_img_n = 4;\n               for (i=0; i < c.length; ++i)\n                  palette[i*4+3] = stbi__get8(s);\n            } else {\n               if (!(s->img_n & 1)) return stbi__err(\"tRNS with alpha\",\"Corrupt PNG\");\n               if (c.length != (stbi__uint32) s->img_n*2) return stbi__err(\"bad tRNS len\",\"Corrupt PNG\");\n               has_trans = 1;\n               if (z->depth == 16) {\n                  for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is\n               } else {\n                  for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger\n               }\n            }\n            break;\n         }\n\n         case STBI__PNG_TYPE('I','D','A','T'): {\n            if (first) return stbi__err(\"first not IHDR\", \"Corrupt PNG\");\n            if (pal_img_n && !pal_len) return stbi__err(\"no PLTE\",\"Corrupt PNG\");\n            if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; }\n            if ((int)(ioff + c.length) < (int)ioff) return 0;\n            if (ioff + c.length > idata_limit) {\n               stbi__uint32 idata_limit_old = idata_limit;\n               stbi_uc *p;\n               if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096;\n               while (ioff + c.length > idata_limit)\n                  idata_limit *= 2;\n               STBI_NOTUSED(idata_limit_old);\n               p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err(\"outofmem\", \"Out of memory\");\n               z->idata = p;\n            }\n            if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err(\"outofdata\",\"Corrupt PNG\");\n            ioff += c.length;\n            break;\n         }\n\n         case STBI__PNG_TYPE('I','E','N','D'): {\n            stbi__uint32 raw_len, bpl;\n            if (first) return stbi__err(\"first not IHDR\", \"Corrupt PNG\");\n            if (scan != STBI__SCAN_load) return 1;\n            if (z->idata == NULL) return stbi__err(\"no IDAT\",\"Corrupt PNG\");\n            // initial guess for decoded data size to avoid unnecessary reallocs\n            bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component\n            raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */;\n            z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone);\n            if (z->expanded == NULL) return 0; // zlib should set error\n            STBI_FREE(z->idata); z->idata = NULL;\n            if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans)\n               s->img_out_n = s->img_n+1;\n            else\n               s->img_out_n = s->img_n;\n            if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0;\n            if (has_trans) {\n               if (z->depth == 16) {\n                  if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0;\n               } else {\n                  if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0;\n               }\n            }\n            if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2)\n               stbi__de_iphone(z);\n            if (pal_img_n) {\n               // pal_img_n == 3 or 4\n               s->img_n = pal_img_n; // record the actual colors we had\n               s->img_out_n = pal_img_n;\n               if (req_comp >= 3) s->img_out_n = req_comp;\n               if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n))\n                  return 0;\n            }\n            STBI_FREE(z->expanded); z->expanded = NULL;\n            return 1;\n         }\n\n         default:\n            // if critical, fail\n            if (first) return stbi__err(\"first not IHDR\", \"Corrupt PNG\");\n            if ((c.type & (1 << 29)) == 0) {\n               #ifndef STBI_NO_FAILURE_STRINGS\n               // not threadsafe\n               static char invalid_chunk[] = \"XXXX PNG chunk not known\";\n               invalid_chunk[0] = STBI__BYTECAST(c.type >> 24);\n               invalid_chunk[1] = STBI__BYTECAST(c.type >> 16);\n               invalid_chunk[2] = STBI__BYTECAST(c.type >>  8);\n               invalid_chunk[3] = STBI__BYTECAST(c.type >>  0);\n               #endif\n               return stbi__err(invalid_chunk, \"PNG not supported: unknown PNG chunk type\");\n            }\n            stbi__skip(s, c.length);\n            break;\n      }\n      // end of PNG chunk, read and skip CRC\n      stbi__get32be(s);\n   }\n}\n\nstatic void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri)\n{\n   void *result=NULL;\n   if (req_comp < 0 || req_comp > 4) return stbi__errpuc(\"bad req_comp\", \"Internal error\");\n   if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) {\n      if (p->depth < 8)\n         ri->bits_per_channel = 8;\n      else\n         ri->bits_per_channel = p->depth;\n      result = p->out;\n      p->out = NULL;\n      if (req_comp && req_comp != p->s->img_out_n) {\n         if (ri->bits_per_channel == 8)\n            result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);\n         else\n            result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y);\n         p->s->img_out_n = req_comp;\n         if (result == NULL) return result;\n      }\n      *x = p->s->img_x;\n      *y = p->s->img_y;\n      if (n) *n = p->s->img_n;\n   }\n   STBI_FREE(p->out);      p->out      = NULL;\n   STBI_FREE(p->expanded); p->expanded = NULL;\n   STBI_FREE(p->idata);    p->idata    = NULL;\n\n   return result;\n}\n\nstatic void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)\n{\n   stbi__png p;\n   p.s = s;\n   return stbi__do_png(&p, x,y,comp,req_comp, ri);\n}\n\nstatic int stbi__png_test(stbi__context *s)\n{\n   int r;\n   r = stbi__check_png_header(s);\n   stbi__rewind(s);\n   return r;\n}\n\nstatic int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp)\n{\n   if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) {\n      stbi__rewind( p->s );\n      return 0;\n   }\n   if (x) *x = p->s->img_x;\n   if (y) *y = p->s->img_y;\n   if (comp) *comp = p->s->img_n;\n   return 1;\n}\n\nstatic int stbi__png_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   stbi__png p;\n   p.s = s;\n   return stbi__png_info_raw(&p, x, y, comp);\n}\n#endif\n\n// Microsoft/Windows BMP image\n\n#ifndef STBI_NO_BMP\nstatic int stbi__bmp_test_raw(stbi__context *s)\n{\n   int r;\n   int sz;\n   if (stbi__get8(s) != 'B') return 0;\n   if (stbi__get8(s) != 'M') return 0;\n   stbi__get32le(s); // discard filesize\n   stbi__get16le(s); // discard reserved\n   stbi__get16le(s); // discard reserved\n   stbi__get32le(s); // discard data offset\n   sz = stbi__get32le(s);\n   r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124);\n   return r;\n}\n\nstatic int stbi__bmp_test(stbi__context *s)\n{\n   int r = stbi__bmp_test_raw(s);\n   stbi__rewind(s);\n   return r;\n}\n\n\n// returns 0..31 for the highest set bit\nstatic int stbi__high_bit(unsigned int z)\n{\n   int n=0;\n   if (z == 0) return -1;\n   if (z >= 0x10000) n += 16, z >>= 16;\n   if (z >= 0x00100) n +=  8, z >>=  8;\n   if (z >= 0x00010) n +=  4, z >>=  4;\n   if (z >= 0x00004) n +=  2, z >>=  2;\n   if (z >= 0x00002) n +=  1, z >>=  1;\n   return n;\n}\n\nstatic int stbi__bitcount(unsigned int a)\n{\n   a = (a & 0x55555555) + ((a >>  1) & 0x55555555); // max 2\n   a = (a & 0x33333333) + ((a >>  2) & 0x33333333); // max 4\n   a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits\n   a = (a + (a >> 8)); // max 16 per 8 bits\n   a = (a + (a >> 16)); // max 32 per 8 bits\n   return a & 0xff;\n}\n\nstatic int stbi__shiftsigned(int v, int shift, int bits)\n{\n   int result;\n   int z=0;\n\n   if (shift < 0) v <<= -shift;\n   else v >>= shift;\n   result = v;\n\n   z = bits;\n   while (z < 8) {\n      result += v >> z;\n      z += bits;\n   }\n   return result;\n}\n\ntypedef struct\n{\n   int bpp, offset, hsz;\n   unsigned int mr,mg,mb,ma, all_a;\n} stbi__bmp_data;\n\nstatic void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info)\n{\n   int hsz;\n   if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc(\"not BMP\", \"Corrupt BMP\");\n   stbi__get32le(s); // discard filesize\n   stbi__get16le(s); // discard reserved\n   stbi__get16le(s); // discard reserved\n   info->offset = stbi__get32le(s);\n   info->hsz = hsz = stbi__get32le(s);\n   info->mr = info->mg = info->mb = info->ma = 0;\n\n   if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc(\"unknown BMP\", \"BMP type not supported: unknown\");\n   if (hsz == 12) {\n      s->img_x = stbi__get16le(s);\n      s->img_y = stbi__get16le(s);\n   } else {\n      s->img_x = stbi__get32le(s);\n      s->img_y = stbi__get32le(s);\n   }\n   if (stbi__get16le(s) != 1) return stbi__errpuc(\"bad BMP\", \"bad BMP\");\n   info->bpp = stbi__get16le(s);\n   if (info->bpp == 1) return stbi__errpuc(\"monochrome\", \"BMP type not supported: 1-bit\");\n   if (hsz != 12) {\n      int compress = stbi__get32le(s);\n      if (compress == 1 || compress == 2) return stbi__errpuc(\"BMP RLE\", \"BMP type not supported: RLE\");\n      stbi__get32le(s); // discard sizeof\n      stbi__get32le(s); // discard hres\n      stbi__get32le(s); // discard vres\n      stbi__get32le(s); // discard colorsused\n      stbi__get32le(s); // discard max important\n      if (hsz == 40 || hsz == 56) {\n         if (hsz == 56) {\n            stbi__get32le(s);\n            stbi__get32le(s);\n            stbi__get32le(s);\n            stbi__get32le(s);\n         }\n         if (info->bpp == 16 || info->bpp == 32) {\n            if (compress == 0) {\n               if (info->bpp == 32) {\n                  info->mr = 0xffu << 16;\n                  info->mg = 0xffu <<  8;\n                  info->mb = 0xffu <<  0;\n                  info->ma = 0xffu << 24;\n                  info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0\n               } else {\n                  info->mr = 31u << 10;\n                  info->mg = 31u <<  5;\n                  info->mb = 31u <<  0;\n               }\n            } else if (compress == 3) {\n               info->mr = stbi__get32le(s);\n               info->mg = stbi__get32le(s);\n               info->mb = stbi__get32le(s);\n               // not documented, but generated by photoshop and handled by mspaint\n               if (info->mr == info->mg && info->mg == info->mb) {\n                  // ?!?!?\n                  return stbi__errpuc(\"bad BMP\", \"bad BMP\");\n               }\n            } else\n               return stbi__errpuc(\"bad BMP\", \"bad BMP\");\n         }\n      } else {\n         int i;\n         if (hsz != 108 && hsz != 124)\n            return stbi__errpuc(\"bad BMP\", \"bad BMP\");\n         info->mr = stbi__get32le(s);\n         info->mg = stbi__get32le(s);\n         info->mb = stbi__get32le(s);\n         info->ma = stbi__get32le(s);\n         stbi__get32le(s); // discard color space\n         for (i=0; i < 12; ++i)\n            stbi__get32le(s); // discard color space parameters\n         if (hsz == 124) {\n            stbi__get32le(s); // discard rendering intent\n            stbi__get32le(s); // discard offset of profile data\n            stbi__get32le(s); // discard size of profile data\n            stbi__get32le(s); // discard reserved\n         }\n      }\n   }\n   return (void *) 1;\n}\n\n\nstatic void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)\n{\n   stbi_uc *out;\n   unsigned int mr=0,mg=0,mb=0,ma=0, all_a;\n   stbi_uc pal[256][4];\n   int psize=0,i,j,width;\n   int flip_vertically, pad, target;\n   stbi__bmp_data info;\n   STBI_NOTUSED(ri);\n\n   info.all_a = 255;\n   if (stbi__bmp_parse_header(s, &info) == NULL)\n      return NULL; // error code already set\n\n   flip_vertically = ((int) s->img_y) > 0;\n   s->img_y = abs((int) s->img_y);\n\n   mr = info.mr;\n   mg = info.mg;\n   mb = info.mb;\n   ma = info.ma;\n   all_a = info.all_a;\n\n   if (info.hsz == 12) {\n      if (info.bpp < 24)\n         psize = (info.offset - 14 - 24) / 3;\n   } else {\n      if (info.bpp < 16)\n         psize = (info.offset - 14 - info.hsz) >> 2;\n   }\n\n   s->img_n = ma ? 4 : 3;\n   if (req_comp && req_comp >= 3) // we can directly decode 3 or 4\n      target = req_comp;\n   else\n      target = s->img_n; // if they want monochrome, we'll post-convert\n\n   // sanity-check size\n   if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0))\n      return stbi__errpuc(\"too large\", \"Corrupt BMP\");\n\n   out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0);\n   if (!out) return stbi__errpuc(\"outofmem\", \"Out of memory\");\n   if (info.bpp < 16) {\n      int z=0;\n      if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc(\"invalid\", \"Corrupt BMP\"); }\n      for (i=0; i < psize; ++i) {\n         pal[i][2] = stbi__get8(s);\n         pal[i][1] = stbi__get8(s);\n         pal[i][0] = stbi__get8(s);\n         if (info.hsz != 12) stbi__get8(s);\n         pal[i][3] = 255;\n      }\n      stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4));\n      if (info.bpp == 4) width = (s->img_x + 1) >> 1;\n      else if (info.bpp == 8) width = s->img_x;\n      else { STBI_FREE(out); return stbi__errpuc(\"bad bpp\", \"Corrupt BMP\"); }\n      pad = (-width)&3;\n      for (j=0; j < (int) s->img_y; ++j) {\n         for (i=0; i < (int) s->img_x; i += 2) {\n            int v=stbi__get8(s),v2=0;\n            if (info.bpp == 4) {\n               v2 = v & 15;\n               v >>= 4;\n            }\n            out[z++] = pal[v][0];\n            out[z++] = pal[v][1];\n            out[z++] = pal[v][2];\n            if (target == 4) out[z++] = 255;\n            if (i+1 == (int) s->img_x) break;\n            v = (info.bpp == 8) ? stbi__get8(s) : v2;\n            out[z++] = pal[v][0];\n            out[z++] = pal[v][1];\n            out[z++] = pal[v][2];\n            if (target == 4) out[z++] = 255;\n         }\n         stbi__skip(s, pad);\n      }\n   } else {\n      int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0;\n      int z = 0;\n      int easy=0;\n      stbi__skip(s, info.offset - 14 - info.hsz);\n      if (info.bpp == 24) width = 3 * s->img_x;\n      else if (info.bpp == 16) width = 2*s->img_x;\n      else /* bpp = 32 and pad = 0 */ width=0;\n      pad = (-width) & 3;\n      if (info.bpp == 24) {\n         easy = 1;\n      } else if (info.bpp == 32) {\n         if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000)\n            easy = 2;\n      }\n      if (!easy) {\n         if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc(\"bad masks\", \"Corrupt BMP\"); }\n         // right shift amt to put high bit in position #7\n         rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr);\n         gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg);\n         bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb);\n         ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma);\n      }\n      for (j=0; j < (int) s->img_y; ++j) {\n         if (easy) {\n            for (i=0; i < (int) s->img_x; ++i) {\n               unsigned char a;\n               out[z+2] = stbi__get8(s);\n               out[z+1] = stbi__get8(s);\n               out[z+0] = stbi__get8(s);\n               z += 3;\n               a = (easy == 2 ? stbi__get8(s) : 255);\n               all_a |= a;\n               if (target == 4) out[z++] = a;\n            }\n         } else {\n            int bpp = info.bpp;\n            for (i=0; i < (int) s->img_x; ++i) {\n               stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s));\n               int a;\n               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount));\n               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount));\n               out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount));\n               a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255);\n               all_a |= a;\n               if (target == 4) out[z++] = STBI__BYTECAST(a);\n            }\n         }\n         stbi__skip(s, pad);\n      }\n   }\n\n   // if alpha channel is all 0s, replace with all 255s\n   if (target == 4 && all_a == 0)\n      for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4)\n         out[i] = 255;\n\n   if (flip_vertically) {\n      stbi_uc t;\n      for (j=0; j < (int) s->img_y>>1; ++j) {\n         stbi_uc *p1 = out +      j     *s->img_x*target;\n         stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target;\n         for (i=0; i < (int) s->img_x*target; ++i) {\n            t = p1[i], p1[i] = p2[i], p2[i] = t;\n         }\n      }\n   }\n\n   if (req_comp && req_comp != target) {\n      out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y);\n      if (out == NULL) return out; // stbi__convert_format frees input on failure\n   }\n\n   *x = s->img_x;\n   *y = s->img_y;\n   if (comp) *comp = s->img_n;\n   return out;\n}\n#endif\n\n// Targa Truevision - TGA\n// by Jonathan Dummer\n#ifndef STBI_NO_TGA\n// returns STBI_rgb or whatever, 0 on error\nstatic int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16)\n{\n   // only RGB or RGBA (incl. 16bit) or grey allowed\n   if(is_rgb16) *is_rgb16 = 0;\n   switch(bits_per_pixel) {\n      case 8:  return STBI_grey;\n      case 16: if(is_grey) return STBI_grey_alpha;\n            // else: fall-through\n      case 15: if(is_rgb16) *is_rgb16 = 1;\n            return STBI_rgb;\n      case 24: // fall-through\n      case 32: return bits_per_pixel/8;\n      default: return 0;\n   }\n}\n\nstatic int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp)\n{\n    int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp;\n    int sz, tga_colormap_type;\n    stbi__get8(s);                   // discard Offset\n    tga_colormap_type = stbi__get8(s); // colormap type\n    if( tga_colormap_type > 1 ) {\n        stbi__rewind(s);\n        return 0;      // only RGB or indexed allowed\n    }\n    tga_image_type = stbi__get8(s); // image type\n    if ( tga_colormap_type == 1 ) { // colormapped (paletted) image\n        if (tga_image_type != 1 && tga_image_type != 9) {\n            stbi__rewind(s);\n            return 0;\n        }\n        stbi__skip(s,4);       // skip index of first colormap entry and number of entries\n        sz = stbi__get8(s);    //   check bits per palette color entry\n        if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) {\n            stbi__rewind(s);\n            return 0;\n        }\n        stbi__skip(s,4);       // skip image x and y origin\n        tga_colormap_bpp = sz;\n    } else { // \"normal\" image w/o colormap - only RGB or grey allowed, +/- RLE\n        if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) {\n            stbi__rewind(s);\n            return 0; // only RGB or grey allowed, +/- RLE\n        }\n        stbi__skip(s,9); // skip colormap specification and image x/y origin\n        tga_colormap_bpp = 0;\n    }\n    tga_w = stbi__get16le(s);\n    if( tga_w < 1 ) {\n        stbi__rewind(s);\n        return 0;   // test width\n    }\n    tga_h = stbi__get16le(s);\n    if( tga_h < 1 ) {\n        stbi__rewind(s);\n        return 0;   // test height\n    }\n    tga_bits_per_pixel = stbi__get8(s); // bits per pixel\n    stbi__get8(s); // ignore alpha bits\n    if (tga_colormap_bpp != 0) {\n        if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) {\n            // when using a colormap, tga_bits_per_pixel is the size of the indexes\n            // I don't think anything but 8 or 16bit indexes makes sense\n            stbi__rewind(s);\n            return 0;\n        }\n        tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL);\n    } else {\n        tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL);\n    }\n    if(!tga_comp) {\n      stbi__rewind(s);\n      return 0;\n    }\n    if (x) *x = tga_w;\n    if (y) *y = tga_h;\n    if (comp) *comp = tga_comp;\n    return 1;                   // seems to have passed everything\n}\n\nstatic int stbi__tga_test(stbi__context *s)\n{\n   int res = 0;\n   int sz, tga_color_type;\n   stbi__get8(s);      //   discard Offset\n   tga_color_type = stbi__get8(s);   //   color type\n   if ( tga_color_type > 1 ) goto errorEnd;   //   only RGB or indexed allowed\n   sz = stbi__get8(s);   //   image type\n   if ( tga_color_type == 1 ) { // colormapped (paletted) image\n      if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9\n      stbi__skip(s,4);       // skip index of first colormap entry and number of entries\n      sz = stbi__get8(s);    //   check bits per palette color entry\n      if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;\n      stbi__skip(s,4);       // skip image x and y origin\n   } else { // \"normal\" image w/o colormap\n      if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE\n      stbi__skip(s,9); // skip colormap specification and image x/y origin\n   }\n   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test width\n   if ( stbi__get16le(s) < 1 ) goto errorEnd;      //   test height\n   sz = stbi__get8(s);   //   bits per pixel\n   if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index\n   if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;\n\n   res = 1; // if we got this far, everything's good and we can return 1 instead of 0\n\nerrorEnd:\n   stbi__rewind(s);\n   return res;\n}\n\n// read 16bit value and convert to 24bit RGB\nstatic void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out)\n{\n   stbi__uint16 px = (stbi__uint16)stbi__get16le(s);\n   stbi__uint16 fiveBitMask = 31;\n   // we have 3 channels with 5bits each\n   int r = (px >> 10) & fiveBitMask;\n   int g = (px >> 5) & fiveBitMask;\n   int b = px & fiveBitMask;\n   // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later\n   out[0] = (stbi_uc)((r * 255)/31);\n   out[1] = (stbi_uc)((g * 255)/31);\n   out[2] = (stbi_uc)((b * 255)/31);\n\n   // some people claim that the most significant bit might be used for alpha\n   // (possibly if an alpha-bit is set in the \"image descriptor byte\")\n   // but that only made 16bit test images completely translucent..\n   // so let's treat all 15 and 16bit TGAs as RGB with no alpha.\n}\n\nstatic void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)\n{\n   //   read in the TGA header stuff\n   int tga_offset = stbi__get8(s);\n   int tga_indexed = stbi__get8(s);\n   int tga_image_type = stbi__get8(s);\n   int tga_is_RLE = 0;\n   int tga_palette_start = stbi__get16le(s);\n   int tga_palette_len = stbi__get16le(s);\n   int tga_palette_bits = stbi__get8(s);\n   int tga_x_origin = stbi__get16le(s);\n   int tga_y_origin = stbi__get16le(s);\n   int tga_width = stbi__get16le(s);\n   int tga_height = stbi__get16le(s);\n   int tga_bits_per_pixel = stbi__get8(s);\n   int tga_comp, tga_rgb16=0;\n   int tga_inverted = stbi__get8(s);\n   // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?)\n   //   image data\n   unsigned char *tga_data;\n   unsigned char *tga_palette = NULL;\n   int i, j;\n   unsigned char raw_data[4] = {0};\n   int RLE_count = 0;\n   int RLE_repeating = 0;\n   int read_next_pixel = 1;\n   STBI_NOTUSED(ri);\n\n   //   do a tiny bit of precessing\n   if ( tga_image_type >= 8 )\n   {\n      tga_image_type -= 8;\n      tga_is_RLE = 1;\n   }\n   tga_inverted = 1 - ((tga_inverted >> 5) & 1);\n\n   //   If I'm paletted, then I'll use the number of bits from the palette\n   if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16);\n   else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16);\n\n   if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency\n      return stbi__errpuc(\"bad format\", \"Can't find out TGA pixelformat\");\n\n   //   tga info\n   *x = tga_width;\n   *y = tga_height;\n   if (comp) *comp = tga_comp;\n\n   if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0))\n      return stbi__errpuc(\"too large\", \"Corrupt TGA\");\n\n   tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0);\n   if (!tga_data) return stbi__errpuc(\"outofmem\", \"Out of memory\");\n\n   // skip to the data's starting position (offset usually = 0)\n   stbi__skip(s, tga_offset );\n\n   if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) {\n      for (i=0; i < tga_height; ++i) {\n         int row = tga_inverted ? tga_height -i - 1 : i;\n         stbi_uc *tga_row = tga_data + row*tga_width*tga_comp;\n         stbi__getn(s, tga_row, tga_width * tga_comp);\n      }\n   } else  {\n      //   do I need to load a palette?\n      if ( tga_indexed)\n      {\n         //   any data to skip? (offset usually = 0)\n         stbi__skip(s, tga_palette_start );\n         //   load the palette\n         tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0);\n         if (!tga_palette) {\n            STBI_FREE(tga_data);\n            return stbi__errpuc(\"outofmem\", \"Out of memory\");\n         }\n         if (tga_rgb16) {\n            stbi_uc *pal_entry = tga_palette;\n            STBI_ASSERT(tga_comp == STBI_rgb);\n            for (i=0; i < tga_palette_len; ++i) {\n               stbi__tga_read_rgb16(s, pal_entry);\n               pal_entry += tga_comp;\n            }\n         } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) {\n               STBI_FREE(tga_data);\n               STBI_FREE(tga_palette);\n               return stbi__errpuc(\"bad palette\", \"Corrupt TGA\");\n         }\n      }\n      //   load the data\n      for (i=0; i < tga_width * tga_height; ++i)\n      {\n         //   if I'm in RLE mode, do I need to get a RLE stbi__pngchunk?\n         if ( tga_is_RLE )\n         {\n            if ( RLE_count == 0 )\n            {\n               //   yep, get the next byte as a RLE command\n               int RLE_cmd = stbi__get8(s);\n               RLE_count = 1 + (RLE_cmd & 127);\n               RLE_repeating = RLE_cmd >> 7;\n               read_next_pixel = 1;\n            } else if ( !RLE_repeating )\n            {\n               read_next_pixel = 1;\n            }\n         } else\n         {\n            read_next_pixel = 1;\n         }\n         //   OK, if I need to read a pixel, do it now\n         if ( read_next_pixel )\n         {\n            //   load however much data we did have\n            if ( tga_indexed )\n            {\n               // read in index, then perform the lookup\n               int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s);\n               if ( pal_idx >= tga_palette_len ) {\n                  // invalid index\n                  pal_idx = 0;\n               }\n               pal_idx *= tga_comp;\n               for (j = 0; j < tga_comp; ++j) {\n                  raw_data[j] = tga_palette[pal_idx+j];\n               }\n            } else if(tga_rgb16) {\n               STBI_ASSERT(tga_comp == STBI_rgb);\n               stbi__tga_read_rgb16(s, raw_data);\n            } else {\n               //   read in the data raw\n               for (j = 0; j < tga_comp; ++j) {\n                  raw_data[j] = stbi__get8(s);\n               }\n            }\n            //   clear the reading flag for the next pixel\n            read_next_pixel = 0;\n         } // end of reading a pixel\n\n         // copy data\n         for (j = 0; j < tga_comp; ++j)\n           tga_data[i*tga_comp+j] = raw_data[j];\n\n         //   in case we're in RLE mode, keep counting down\n         --RLE_count;\n      }\n      //   do I need to invert the image?\n      if ( tga_inverted )\n      {\n         for (j = 0; j*2 < tga_height; ++j)\n         {\n            int index1 = j * tga_width * tga_comp;\n            int index2 = (tga_height - 1 - j) * tga_width * tga_comp;\n            for (i = tga_width * tga_comp; i > 0; --i)\n            {\n               unsigned char temp = tga_data[index1];\n               tga_data[index1] = tga_data[index2];\n               tga_data[index2] = temp;\n               ++index1;\n               ++index2;\n            }\n         }\n      }\n      //   clear my palette, if I had one\n      if ( tga_palette != NULL )\n      {\n         STBI_FREE( tga_palette );\n      }\n   }\n\n   // swap RGB - if the source data was RGB16, it already is in the right order\n   if (tga_comp >= 3 && !tga_rgb16)\n   {\n      unsigned char* tga_pixel = tga_data;\n      for (i=0; i < tga_width * tga_height; ++i)\n      {\n         unsigned char temp = tga_pixel[0];\n         tga_pixel[0] = tga_pixel[2];\n         tga_pixel[2] = temp;\n         tga_pixel += tga_comp;\n      }\n   }\n\n   // convert to target component count\n   if (req_comp && req_comp != tga_comp)\n      tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height);\n\n   //   the things I do to get rid of an error message, and yet keep\n   //   Microsoft's C compilers happy... [8^(\n   tga_palette_start = tga_palette_len = tga_palette_bits =\n         tga_x_origin = tga_y_origin = 0;\n   //   OK, done\n   return tga_data;\n}\n#endif\n\n// *************************************************************************************************\n// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB\n\n#ifndef STBI_NO_PSD\nstatic int stbi__psd_test(stbi__context *s)\n{\n   int r = (stbi__get32be(s) == 0x38425053);\n   stbi__rewind(s);\n   return r;\n}\n\nstatic int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount)\n{\n   int count, nleft, len;\n\n   count = 0;\n   while ((nleft = pixelCount - count) > 0) {\n      len = stbi__get8(s);\n      if (len == 128) {\n         // No-op.\n      } else if (len < 128) {\n         // Copy next len+1 bytes literally.\n         len++;\n         if (len > nleft) return 0; // corrupt data\n         count += len;\n         while (len) {\n            *p = stbi__get8(s);\n            p += 4;\n            len--;\n         }\n      } else if (len > 128) {\n         stbi_uc   val;\n         // Next -len+1 bytes in the dest are replicated from next source byte.\n         // (Interpret len as a negative 8-bit int.)\n         len = 257 - len;\n         if (len > nleft) return 0; // corrupt data\n         val = stbi__get8(s);\n         count += len;\n         while (len) {\n            *p = val;\n            p += 4;\n            len--;\n         }\n      }\n   }\n\n   return 1;\n}\n\nstatic void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)\n{\n   int pixelCount;\n   int channelCount, compression;\n   int channel, i;\n   int bitdepth;\n   int w,h;\n   stbi_uc *out;\n   STBI_NOTUSED(ri);\n\n   // Check identifier\n   if (stbi__get32be(s) != 0x38425053)   // \"8BPS\"\n      return stbi__errpuc(\"not PSD\", \"Corrupt PSD image\");\n\n   // Check file type version.\n   if (stbi__get16be(s) != 1)\n      return stbi__errpuc(\"wrong version\", \"Unsupported version of PSD image\");\n\n   // Skip 6 reserved bytes.\n   stbi__skip(s, 6 );\n\n   // Read the number of channels (R, G, B, A, etc).\n   channelCount = stbi__get16be(s);\n   if (channelCount < 0 || channelCount > 16)\n      return stbi__errpuc(\"wrong channel count\", \"Unsupported number of channels in PSD image\");\n\n   // Read the rows and columns of the image.\n   h = stbi__get32be(s);\n   w = stbi__get32be(s);\n\n   // Make sure the depth is 8 bits.\n   bitdepth = stbi__get16be(s);\n   if (bitdepth != 8 && bitdepth != 16)\n      return stbi__errpuc(\"unsupported bit depth\", \"PSD bit depth is not 8 or 16 bit\");\n\n   // Make sure the color mode is RGB.\n   // Valid options are:\n   //   0: Bitmap\n   //   1: Grayscale\n   //   2: Indexed color\n   //   3: RGB color\n   //   4: CMYK color\n   //   7: Multichannel\n   //   8: Duotone\n   //   9: Lab color\n   if (stbi__get16be(s) != 3)\n      return stbi__errpuc(\"wrong color format\", \"PSD is not in RGB color format\");\n\n   // Skip the Mode Data.  (It's the palette for indexed color; other info for other modes.)\n   stbi__skip(s,stbi__get32be(s) );\n\n   // Skip the image resources.  (resolution, pen tool paths, etc)\n   stbi__skip(s, stbi__get32be(s) );\n\n   // Skip the reserved data.\n   stbi__skip(s, stbi__get32be(s) );\n\n   // Find out if the data is compressed.\n   // Known values:\n   //   0: no compression\n   //   1: RLE compressed\n   compression = stbi__get16be(s);\n   if (compression > 1)\n      return stbi__errpuc(\"bad compression\", \"PSD has an unknown compression format\");\n\n   // Check size\n   if (!stbi__mad3sizes_valid(4, w, h, 0))\n      return stbi__errpuc(\"too large\", \"Corrupt PSD\");\n\n   // Create the destination image.\n\n   if (!compression && bitdepth == 16 && bpc == 16) {\n      out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0);\n      ri->bits_per_channel = 16;\n   } else\n      out = (stbi_uc *) stbi__malloc(4 * w*h);\n\n   if (!out) return stbi__errpuc(\"outofmem\", \"Out of memory\");\n   pixelCount = w*h;\n\n   // Initialize the data to zero.\n   //memset( out, 0, pixelCount * 4 );\n\n   // Finally, the image data.\n   if (compression) {\n      // RLE as used by .PSD and .TIFF\n      // Loop until you get the number of unpacked bytes you are expecting:\n      //     Read the next source byte into n.\n      //     If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.\n      //     Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.\n      //     Else if n is 128, noop.\n      // Endloop\n\n      // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data,\n      // which we're going to just skip.\n      stbi__skip(s, h * channelCount * 2 );\n\n      // Read the RLE data by channel.\n      for (channel = 0; channel < 4; channel++) {\n         stbi_uc *p;\n\n         p = out+channel;\n         if (channel >= channelCount) {\n            // Fill this channel with default data.\n            for (i = 0; i < pixelCount; i++, p += 4)\n               *p = (channel == 3 ? 255 : 0);\n         } else {\n            // Read the RLE data.\n            if (!stbi__psd_decode_rle(s, p, pixelCount)) {\n               STBI_FREE(out);\n               return stbi__errpuc(\"corrupt\", \"bad RLE data\");\n            }\n         }\n      }\n\n   } else {\n      // We're at the raw image data.  It's each channel in order (Red, Green, Blue, Alpha, ...)\n      // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image.\n\n      // Read the data by channel.\n      for (channel = 0; channel < 4; channel++) {\n         if (channel >= channelCount) {\n            // Fill this channel with default data.\n            if (bitdepth == 16 && bpc == 16) {\n               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;\n               stbi__uint16 val = channel == 3 ? 65535 : 0;\n               for (i = 0; i < pixelCount; i++, q += 4)\n                  *q = val;\n            } else {\n               stbi_uc *p = out+channel;\n               stbi_uc val = channel == 3 ? 255 : 0;\n               for (i = 0; i < pixelCount; i++, p += 4)\n                  *p = val;\n            }\n         } else {\n            if (ri->bits_per_channel == 16) {    // output bpc\n               stbi__uint16 *q = ((stbi__uint16 *) out) + channel;\n               for (i = 0; i < pixelCount; i++, q += 4)\n                  *q = (stbi__uint16) stbi__get16be(s);\n            } else {\n               stbi_uc *p = out+channel;\n               if (bitdepth == 16) {  // input bpc\n                  for (i = 0; i < pixelCount; i++, p += 4)\n                     *p = (stbi_uc) (stbi__get16be(s) >> 8);\n               } else {\n                  for (i = 0; i < pixelCount; i++, p += 4)\n                     *p = stbi__get8(s);\n               }\n            }\n         }\n      }\n   }\n\n   // remove weird white matte from PSD\n   if (channelCount >= 4) {\n      if (ri->bits_per_channel == 16) {\n         for (i=0; i < w*h; ++i) {\n            stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i;\n            if (pixel[3] != 0 && pixel[3] != 65535) {\n               float a = pixel[3] / 65535.0f;\n               float ra = 1.0f / a;\n               float inv_a = 65535.0f * (1 - ra);\n               pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a);\n               pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a);\n               pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a);\n            }\n         }\n      } else {\n         for (i=0; i < w*h; ++i) {\n            unsigned char *pixel = out + 4*i;\n            if (pixel[3] != 0 && pixel[3] != 255) {\n               float a = pixel[3] / 255.0f;\n               float ra = 1.0f / a;\n               float inv_a = 255.0f * (1 - ra);\n               pixel[0] = (unsigned char) (pixel[0]*ra + inv_a);\n               pixel[1] = (unsigned char) (pixel[1]*ra + inv_a);\n               pixel[2] = (unsigned char) (pixel[2]*ra + inv_a);\n            }\n         }\n      }\n   }\n\n   // convert to desired output format\n   if (req_comp && req_comp != 4) {\n      if (ri->bits_per_channel == 16)\n         out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h);\n      else\n         out = stbi__convert_format(out, 4, req_comp, w, h);\n      if (out == NULL) return out; // stbi__convert_format frees input on failure\n   }\n\n   if (comp) *comp = 4;\n   *y = h;\n   *x = w;\n\n   return out;\n}\n#endif\n\n// *************************************************************************************************\n// Softimage PIC loader\n// by Tom Seddon\n//\n// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format\n// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/\n\n#ifndef STBI_NO_PIC\nstatic int stbi__pic_is4(stbi__context *s,const char *str)\n{\n   int i;\n   for (i=0; i<4; ++i)\n      if (stbi__get8(s) != (stbi_uc)str[i])\n         return 0;\n\n   return 1;\n}\n\nstatic int stbi__pic_test_core(stbi__context *s)\n{\n   int i;\n\n   if (!stbi__pic_is4(s,\"\\x53\\x80\\xF6\\x34\"))\n      return 0;\n\n   for(i=0;i<84;++i)\n      stbi__get8(s);\n\n   if (!stbi__pic_is4(s,\"PICT\"))\n      return 0;\n\n   return 1;\n}\n\ntypedef struct\n{\n   stbi_uc size,type,channel;\n} stbi__pic_packet;\n\nstatic stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest)\n{\n   int mask=0x80, i;\n\n   for (i=0; i<4; ++i, mask>>=1) {\n      if (channel & mask) {\n         if (stbi__at_eof(s)) return stbi__errpuc(\"bad file\",\"PIC file too short\");\n         dest[i]=stbi__get8(s);\n      }\n   }\n\n   return dest;\n}\n\nstatic void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src)\n{\n   int mask=0x80,i;\n\n   for (i=0;i<4; ++i, mask>>=1)\n      if (channel&mask)\n         dest[i]=src[i];\n}\n\nstatic stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result)\n{\n   int act_comp=0,num_packets=0,y,chained;\n   stbi__pic_packet packets[10];\n\n   // this will (should...) cater for even some bizarre stuff like having data\n    // for the same channel in multiple packets.\n   do {\n      stbi__pic_packet *packet;\n\n      if (num_packets==sizeof(packets)/sizeof(packets[0]))\n         return stbi__errpuc(\"bad format\",\"too many packets\");\n\n      packet = &packets[num_packets++];\n\n      chained = stbi__get8(s);\n      packet->size    = stbi__get8(s);\n      packet->type    = stbi__get8(s);\n      packet->channel = stbi__get8(s);\n\n      act_comp |= packet->channel;\n\n      if (stbi__at_eof(s))          return stbi__errpuc(\"bad file\",\"file too short (reading packets)\");\n      if (packet->size != 8)  return stbi__errpuc(\"bad format\",\"packet isn't 8bpp\");\n   } while (chained);\n\n   *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel?\n\n   for(y=0; y<height; ++y) {\n      int packet_idx;\n\n      for(packet_idx=0; packet_idx < num_packets; ++packet_idx) {\n         stbi__pic_packet *packet = &packets[packet_idx];\n         stbi_uc *dest = result+y*width*4;\n\n         switch (packet->type) {\n            default:\n               return stbi__errpuc(\"bad format\",\"packet has bad compression type\");\n\n            case 0: {//uncompressed\n               int x;\n\n               for(x=0;x<width;++x, dest+=4)\n                  if (!stbi__readval(s,packet->channel,dest))\n                     return 0;\n               break;\n            }\n\n            case 1://Pure RLE\n               {\n                  int left=width, i;\n\n                  while (left>0) {\n                     stbi_uc count,value[4];\n\n                     count=stbi__get8(s);\n                     if (stbi__at_eof(s))   return stbi__errpuc(\"bad file\",\"file too short (pure read count)\");\n\n                     if (count > left)\n                        count = (stbi_uc) left;\n\n                     if (!stbi__readval(s,packet->channel,value))  return 0;\n\n                     for(i=0; i<count; ++i,dest+=4)\n                        stbi__copyval(packet->channel,dest,value);\n                     left -= count;\n                  }\n               }\n               break;\n\n            case 2: {//Mixed RLE\n               int left=width;\n               while (left>0) {\n                  int count = stbi__get8(s), i;\n                  if (stbi__at_eof(s))  return stbi__errpuc(\"bad file\",\"file too short (mixed read count)\");\n\n                  if (count >= 128) { // Repeated\n                     stbi_uc value[4];\n\n                     if (count==128)\n                        count = stbi__get16be(s);\n                     else\n                        count -= 127;\n                     if (count > left)\n                        return stbi__errpuc(\"bad file\",\"scanline overrun\");\n\n                     if (!stbi__readval(s,packet->channel,value))\n                        return 0;\n\n                     for(i=0;i<count;++i, dest += 4)\n                        stbi__copyval(packet->channel,dest,value);\n                  } else { // Raw\n                     ++count;\n                     if (count>left) return stbi__errpuc(\"bad file\",\"scanline overrun\");\n\n                     for(i=0;i<count;++i, dest+=4)\n                        if (!stbi__readval(s,packet->channel,dest))\n                           return 0;\n                  }\n                  left-=count;\n               }\n               break;\n            }\n         }\n      }\n   }\n\n   return result;\n}\n\nstatic void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri)\n{\n   stbi_uc *result;\n   int i, x,y, internal_comp;\n   STBI_NOTUSED(ri);\n\n   if (!comp) comp = &internal_comp;\n\n   for (i=0; i<92; ++i)\n      stbi__get8(s);\n\n   x = stbi__get16be(s);\n   y = stbi__get16be(s);\n   if (stbi__at_eof(s))  return stbi__errpuc(\"bad file\",\"file too short (pic header)\");\n   if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc(\"too large\", \"PIC image too large to decode\");\n\n   stbi__get32be(s); //skip `ratio'\n   stbi__get16be(s); //skip `fields'\n   stbi__get16be(s); //skip `pad'\n\n   // intermediate buffer is RGBA\n   result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0);\n   memset(result, 0xff, x*y*4);\n\n   if (!stbi__pic_load_core(s,x,y,comp, result)) {\n      STBI_FREE(result);\n      result=0;\n   }\n   *px = x;\n   *py = y;\n   if (req_comp == 0) req_comp = *comp;\n   result=stbi__convert_format(result,4,req_comp,x,y);\n\n   return result;\n}\n\nstatic int stbi__pic_test(stbi__context *s)\n{\n   int r = stbi__pic_test_core(s);\n   stbi__rewind(s);\n   return r;\n}\n#endif\n\n// *************************************************************************************************\n// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb\n\n#ifndef STBI_NO_GIF\ntypedef struct\n{\n   stbi__int16 prefix;\n   stbi_uc first;\n   stbi_uc suffix;\n} stbi__gif_lzw;\n\ntypedef struct\n{\n   int w,h;\n   stbi_uc *out, *old_out;             // output buffer (always 4 components)\n   int flags, bgindex, ratio, transparent, eflags, delay;\n   stbi_uc  pal[256][4];\n   stbi_uc lpal[256][4];\n   stbi__gif_lzw codes[4096];\n   stbi_uc *color_table;\n   int parse, step;\n   int lflags;\n   int start_x, start_y;\n   int max_x, max_y;\n   int cur_x, cur_y;\n   int line_size;\n} stbi__gif;\n\nstatic int stbi__gif_test_raw(stbi__context *s)\n{\n   int sz;\n   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0;\n   sz = stbi__get8(s);\n   if (sz != '9' && sz != '7') return 0;\n   if (stbi__get8(s) != 'a') return 0;\n   return 1;\n}\n\nstatic int stbi__gif_test(stbi__context *s)\n{\n   int r = stbi__gif_test_raw(s);\n   stbi__rewind(s);\n   return r;\n}\n\nstatic void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp)\n{\n   int i;\n   for (i=0; i < num_entries; ++i) {\n      pal[i][2] = stbi__get8(s);\n      pal[i][1] = stbi__get8(s);\n      pal[i][0] = stbi__get8(s);\n      pal[i][3] = transp == i ? 0 : 255;\n   }\n}\n\nstatic int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info)\n{\n   stbi_uc version;\n   if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8')\n      return stbi__err(\"not GIF\", \"Corrupt GIF\");\n\n   version = stbi__get8(s);\n   if (version != '7' && version != '9')    return stbi__err(\"not GIF\", \"Corrupt GIF\");\n   if (stbi__get8(s) != 'a')                return stbi__err(\"not GIF\", \"Corrupt GIF\");\n\n   stbi__g_failure_reason = \"\";\n   g->w = stbi__get16le(s);\n   g->h = stbi__get16le(s);\n   g->flags = stbi__get8(s);\n   g->bgindex = stbi__get8(s);\n   g->ratio = stbi__get8(s);\n   g->transparent = -1;\n\n   if (comp != 0) *comp = 4;  // can't actually tell whether it's 3 or 4 until we parse the comments\n\n   if (is_info) return 1;\n\n   if (g->flags & 0x80)\n      stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1);\n\n   return 1;\n}\n\nstatic int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp)\n{\n   stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));\n   if (!stbi__gif_header(s, g, comp, 1)) {\n      STBI_FREE(g);\n      stbi__rewind( s );\n      return 0;\n   }\n   if (x) *x = g->w;\n   if (y) *y = g->h;\n   STBI_FREE(g);\n   return 1;\n}\n\nstatic void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)\n{\n   stbi_uc *p, *c;\n\n   // recurse to decode the prefixes, since the linked-list is backwards,\n   // and working backwards through an interleaved image would be nasty\n   if (g->codes[code].prefix >= 0)\n      stbi__out_gif_code(g, g->codes[code].prefix);\n\n   if (g->cur_y >= g->max_y) return;\n\n   p = &g->out[g->cur_x + g->cur_y];\n   c = &g->color_table[g->codes[code].suffix * 4];\n\n   if (c[3] >= 128) {\n      p[0] = c[2];\n      p[1] = c[1];\n      p[2] = c[0];\n      p[3] = c[3];\n   }\n   g->cur_x += 4;\n\n   if (g->cur_x >= g->max_x) {\n      g->cur_x = g->start_x;\n      g->cur_y += g->step;\n\n      while (g->cur_y >= g->max_y && g->parse > 0) {\n         g->step = (1 << g->parse) * g->line_size;\n         g->cur_y = g->start_y + (g->step >> 1);\n         --g->parse;\n      }\n   }\n}\n\nstatic stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)\n{\n   stbi_uc lzw_cs;\n   stbi__int32 len, init_code;\n   stbi__uint32 first;\n   stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear;\n   stbi__gif_lzw *p;\n\n   lzw_cs = stbi__get8(s);\n   if (lzw_cs > 12) return NULL;\n   clear = 1 << lzw_cs;\n   first = 1;\n   codesize = lzw_cs + 1;\n   codemask = (1 << codesize) - 1;\n   bits = 0;\n   valid_bits = 0;\n   for (init_code = 0; init_code < clear; init_code++) {\n      g->codes[init_code].prefix = -1;\n      g->codes[init_code].first = (stbi_uc) init_code;\n      g->codes[init_code].suffix = (stbi_uc) init_code;\n   }\n\n   // support no starting clear code\n   avail = clear+2;\n   oldcode = -1;\n\n   len = 0;\n   for(;;) {\n      if (valid_bits < codesize) {\n         if (len == 0) {\n            len = stbi__get8(s); // start new block\n            if (len == 0)\n               return g->out;\n         }\n         --len;\n         bits |= (stbi__int32) stbi__get8(s) << valid_bits;\n         valid_bits += 8;\n      } else {\n         stbi__int32 code = bits & codemask;\n         bits >>= codesize;\n         valid_bits -= codesize;\n         // @OPTIMIZE: is there some way we can accelerate the non-clear path?\n         if (code == clear) {  // clear code\n            codesize = lzw_cs + 1;\n            codemask = (1 << codesize) - 1;\n            avail = clear + 2;\n            oldcode = -1;\n            first = 0;\n         } else if (code == clear + 1) { // end of stream code\n            stbi__skip(s, len);\n            while ((len = stbi__get8(s)) > 0)\n               stbi__skip(s,len);\n            return g->out;\n         } else if (code <= avail) {\n            if (first) return stbi__errpuc(\"no clear code\", \"Corrupt GIF\");\n\n            if (oldcode >= 0) {\n               p = &g->codes[avail++];\n               if (avail > 4096)        return stbi__errpuc(\"too many codes\", \"Corrupt GIF\");\n               p->prefix = (stbi__int16) oldcode;\n               p->first = g->codes[oldcode].first;\n               p->suffix = (code == avail) ? p->first : g->codes[code].first;\n            } else if (code == avail)\n               return stbi__errpuc(\"illegal code in raster\", \"Corrupt GIF\");\n\n            stbi__out_gif_code(g, (stbi__uint16) code);\n\n            if ((avail & codemask) == 0 && avail <= 0x0FFF) {\n               codesize++;\n               codemask = (1 << codesize) - 1;\n            }\n\n            oldcode = code;\n         } else {\n            return stbi__errpuc(\"illegal code in raster\", \"Corrupt GIF\");\n         }\n      }\n   }\n}\n\nstatic void stbi__fill_gif_background(stbi__gif *g, int x0, int y0, int x1, int y1)\n{\n   int x, y;\n   stbi_uc *c = g->pal[g->bgindex];\n   for (y = y0; y < y1; y += 4 * g->w) {\n      for (x = x0; x < x1; x += 4) {\n         stbi_uc *p  = &g->out[y + x];\n         p[0] = c[2];\n         p[1] = c[1];\n         p[2] = c[0];\n         p[3] = 0;\n      }\n   }\n}\n\n// this function is designed to support animated gifs, although stb_image doesn't support it\nstatic stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp)\n{\n   int i;\n   stbi_uc *prev_out = 0;\n\n   if (g->out == 0 && !stbi__gif_header(s, g, comp,0))\n      return 0; // stbi__g_failure_reason set by stbi__gif_header\n\n   if (!stbi__mad3sizes_valid(g->w, g->h, 4, 0))\n      return stbi__errpuc(\"too large\", \"GIF too large\");\n\n   prev_out = g->out;\n   g->out = (stbi_uc *) stbi__malloc_mad3(4, g->w, g->h, 0);\n   if (g->out == 0) return stbi__errpuc(\"outofmem\", \"Out of memory\");\n\n   switch ((g->eflags & 0x1C) >> 2) {\n      case 0: // unspecified (also always used on 1st frame)\n         stbi__fill_gif_background(g, 0, 0, 4 * g->w, 4 * g->w * g->h);\n         break;\n      case 1: // do not dispose\n         if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h);\n         g->old_out = prev_out;\n         break;\n      case 2: // dispose to background\n         if (prev_out) memcpy(g->out, prev_out, 4 * g->w * g->h);\n         stbi__fill_gif_background(g, g->start_x, g->start_y, g->max_x, g->max_y);\n         break;\n      case 3: // dispose to previous\n         if (g->old_out) {\n            for (i = g->start_y; i < g->max_y; i += 4 * g->w)\n               memcpy(&g->out[i + g->start_x], &g->old_out[i + g->start_x], g->max_x - g->start_x);\n         }\n         break;\n   }\n\n   for (;;) {\n      switch (stbi__get8(s)) {\n         case 0x2C: /* Image Descriptor */\n         {\n            int prev_trans = -1;\n            stbi__int32 x, y, w, h;\n            stbi_uc *o;\n\n            x = stbi__get16le(s);\n            y = stbi__get16le(s);\n            w = stbi__get16le(s);\n            h = stbi__get16le(s);\n            if (((x + w) > (g->w)) || ((y + h) > (g->h)))\n               return stbi__errpuc(\"bad Image Descriptor\", \"Corrupt GIF\");\n\n            g->line_size = g->w * 4;\n            g->start_x = x * 4;\n            g->start_y = y * g->line_size;\n            g->max_x   = g->start_x + w * 4;\n            g->max_y   = g->start_y + h * g->line_size;\n            g->cur_x   = g->start_x;\n            g->cur_y   = g->start_y;\n\n            g->lflags = stbi__get8(s);\n\n            if (g->lflags & 0x40) {\n               g->step = 8 * g->line_size; // first interlaced spacing\n               g->parse = 3;\n            } else {\n               g->step = g->line_size;\n               g->parse = 0;\n            }\n\n            if (g->lflags & 0x80) {\n               stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1);\n               g->color_table = (stbi_uc *) g->lpal;\n            } else if (g->flags & 0x80) {\n               if (g->transparent >= 0 && (g->eflags & 0x01)) {\n                  prev_trans = g->pal[g->transparent][3];\n                  g->pal[g->transparent][3] = 0;\n               }\n               g->color_table = (stbi_uc *) g->pal;\n            } else\n               return stbi__errpuc(\"missing color table\", \"Corrupt GIF\");\n\n            o = stbi__process_gif_raster(s, g);\n            if (o == NULL) return NULL;\n\n            if (prev_trans != -1)\n               g->pal[g->transparent][3] = (stbi_uc) prev_trans;\n\n            return o;\n         }\n\n         case 0x21: // Comment Extension.\n         {\n            int len;\n            if (stbi__get8(s) == 0xF9) { // Graphic Control Extension.\n               len = stbi__get8(s);\n               if (len == 4) {\n                  g->eflags = stbi__get8(s);\n                  g->delay = stbi__get16le(s);\n                  g->transparent = stbi__get8(s);\n               } else {\n                  stbi__skip(s, len);\n                  break;\n               }\n            }\n            while ((len = stbi__get8(s)) != 0)\n               stbi__skip(s, len);\n            break;\n         }\n\n         case 0x3B: // gif stream termination code\n            return (stbi_uc *) s; // using '1' causes warning on some compilers\n\n         default:\n            return stbi__errpuc(\"unknown code\", \"Corrupt GIF\");\n      }\n   }\n\n   STBI_NOTUSED(req_comp);\n}\n\nstatic void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)\n{\n   stbi_uc *u = 0;\n   stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif));\n   memset(g, 0, sizeof(*g));\n   STBI_NOTUSED(ri);\n\n   u = stbi__gif_load_next(s, g, comp, req_comp);\n   if (u == (stbi_uc *) s) u = 0;  // end of animated gif marker\n   if (u) {\n      *x = g->w;\n      *y = g->h;\n      if (req_comp && req_comp != 4)\n         u = stbi__convert_format(u, 4, req_comp, g->w, g->h);\n   }\n   else if (g->out)\n      STBI_FREE(g->out);\n   STBI_FREE(g);\n   return u;\n}\n\nstatic int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   return stbi__gif_info_raw(s,x,y,comp);\n}\n#endif\n\n// *************************************************************************************************\n// Radiance RGBE HDR loader\n// originally by Nicolas Schulz\n#ifndef STBI_NO_HDR\nstatic int stbi__hdr_test_core(stbi__context *s, const char *signature)\n{\n   int i;\n   for (i=0; signature[i]; ++i)\n      if (stbi__get8(s) != signature[i])\n          return 0;\n   stbi__rewind(s);\n   return 1;\n}\n\nstatic int stbi__hdr_test(stbi__context* s)\n{\n   int r = stbi__hdr_test_core(s, \"#?RADIANCE\\n\");\n   stbi__rewind(s);\n   if(!r) {\n       r = stbi__hdr_test_core(s, \"#?RGBE\\n\");\n       stbi__rewind(s);\n   }\n   return r;\n}\n\n#define STBI__HDR_BUFLEN  1024\nstatic char *stbi__hdr_gettoken(stbi__context *z, char *buffer)\n{\n   int len=0;\n   char c = '\\0';\n\n   c = (char) stbi__get8(z);\n\n   while (!stbi__at_eof(z) && c != '\\n') {\n      buffer[len++] = c;\n      if (len == STBI__HDR_BUFLEN-1) {\n         // flush to end of line\n         while (!stbi__at_eof(z) && stbi__get8(z) != '\\n')\n            ;\n         break;\n      }\n      c = (char) stbi__get8(z);\n   }\n\n   buffer[len] = 0;\n   return buffer;\n}\n\nstatic void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp)\n{\n   if ( input[3] != 0 ) {\n      float f1;\n      // Exponent\n      f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8));\n      if (req_comp <= 2)\n         output[0] = (input[0] + input[1] + input[2]) * f1 / 3;\n      else {\n         output[0] = input[0] * f1;\n         output[1] = input[1] * f1;\n         output[2] = input[2] * f1;\n      }\n      if (req_comp == 2) output[1] = 1;\n      if (req_comp == 4) output[3] = 1;\n   } else {\n      switch (req_comp) {\n         case 4: output[3] = 1; /* fallthrough */\n         case 3: output[0] = output[1] = output[2] = 0;\n                 break;\n         case 2: output[1] = 1; /* fallthrough */\n         case 1: output[0] = 0;\n                 break;\n      }\n   }\n}\n\nstatic float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)\n{\n   char buffer[STBI__HDR_BUFLEN];\n   char *token;\n   int valid = 0;\n   int width, height;\n   stbi_uc *scanline;\n   float *hdr_data;\n   int len;\n   unsigned char count, value;\n   int i, j, k, c1,c2, z;\n   const char *headerToken;\n   STBI_NOTUSED(ri);\n\n   // Check identifier\n   headerToken = stbi__hdr_gettoken(s,buffer);\n   if (strcmp(headerToken, \"#?RADIANCE\") != 0 && strcmp(headerToken, \"#?RGBE\") != 0)\n      return stbi__errpf(\"not HDR\", \"Corrupt HDR image\");\n\n   // Parse header\n   for(;;) {\n      token = stbi__hdr_gettoken(s,buffer);\n      if (token[0] == 0) break;\n      if (strcmp(token, \"FORMAT=32-bit_rle_rgbe\") == 0) valid = 1;\n   }\n\n   if (!valid)    return stbi__errpf(\"unsupported format\", \"Unsupported HDR format\");\n\n   // Parse width and height\n   // can't use sscanf() if we're not using stdio!\n   token = stbi__hdr_gettoken(s,buffer);\n   if (strncmp(token, \"-Y \", 3))  return stbi__errpf(\"unsupported data layout\", \"Unsupported HDR format\");\n   token += 3;\n   height = (int) strtol(token, &token, 10);\n   while (*token == ' ') ++token;\n   if (strncmp(token, \"+X \", 3))  return stbi__errpf(\"unsupported data layout\", \"Unsupported HDR format\");\n   token += 3;\n   width = (int) strtol(token, NULL, 10);\n\n   *x = width;\n   *y = height;\n\n   if (comp) *comp = 3;\n   if (req_comp == 0) req_comp = 3;\n\n   if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0))\n      return stbi__errpf(\"too large\", \"HDR image is too large\");\n\n   // Read data\n   hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0);\n   if (!hdr_data)\n      return stbi__errpf(\"outofmem\", \"Out of memory\");\n\n   // Load image data\n   // image data is stored as some number of sca\n   if ( width < 8 || width >= 32768) {\n      // Read flat data\n      for (j=0; j < height; ++j) {\n         for (i=0; i < width; ++i) {\n            stbi_uc rgbe[4];\n           main_decode_loop:\n            stbi__getn(s, rgbe, 4);\n            stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp);\n         }\n      }\n   } else {\n      // Read RLE-encoded data\n      scanline = NULL;\n\n      for (j = 0; j < height; ++j) {\n         c1 = stbi__get8(s);\n         c2 = stbi__get8(s);\n         len = stbi__get8(s);\n         if (c1 != 2 || c2 != 2 || (len & 0x80)) {\n            // not run-length encoded, so we have to actually use THIS data as a decoded\n            // pixel (note this can't be a valid pixel--one of RGB must be >= 128)\n            stbi_uc rgbe[4];\n            rgbe[0] = (stbi_uc) c1;\n            rgbe[1] = (stbi_uc) c2;\n            rgbe[2] = (stbi_uc) len;\n            rgbe[3] = (stbi_uc) stbi__get8(s);\n            stbi__hdr_convert(hdr_data, rgbe, req_comp);\n            i = 1;\n            j = 0;\n            STBI_FREE(scanline);\n            goto main_decode_loop; // yes, this makes no sense\n         }\n         len <<= 8;\n         len |= stbi__get8(s);\n         if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf(\"invalid decoded scanline length\", \"corrupt HDR\"); }\n         if (scanline == NULL) {\n            scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0);\n            if (!scanline) {\n               STBI_FREE(hdr_data);\n               return stbi__errpf(\"outofmem\", \"Out of memory\");\n            }\n         }\n\n         for (k = 0; k < 4; ++k) {\n            int nleft;\n            i = 0;\n            while ((nleft = width - i) > 0) {\n               count = stbi__get8(s);\n               if (count > 128) {\n                  // Run\n                  value = stbi__get8(s);\n                  count -= 128;\n                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf(\"corrupt\", \"bad RLE data in HDR\"); }\n                  for (z = 0; z < count; ++z)\n                     scanline[i++ * 4 + k] = value;\n               } else {\n                  // Dump\n                  if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf(\"corrupt\", \"bad RLE data in HDR\"); }\n                  for (z = 0; z < count; ++z)\n                     scanline[i++ * 4 + k] = stbi__get8(s);\n               }\n            }\n         }\n         for (i=0; i < width; ++i)\n            stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp);\n      }\n      if (scanline)\n         STBI_FREE(scanline);\n   }\n\n   return hdr_data;\n}\n\nstatic int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   char buffer[STBI__HDR_BUFLEN];\n   char *token;\n   int valid = 0;\n   int dummy;\n\n   if (!x) x = &dummy;\n   if (!y) y = &dummy;\n   if (!comp) comp = &dummy;\n\n   if (stbi__hdr_test(s) == 0) {\n       stbi__rewind( s );\n       return 0;\n   }\n\n   for(;;) {\n      token = stbi__hdr_gettoken(s,buffer);\n      if (token[0] == 0) break;\n      if (strcmp(token, \"FORMAT=32-bit_rle_rgbe\") == 0) valid = 1;\n   }\n\n   if (!valid) {\n       stbi__rewind( s );\n       return 0;\n   }\n   token = stbi__hdr_gettoken(s,buffer);\n   if (strncmp(token, \"-Y \", 3)) {\n       stbi__rewind( s );\n       return 0;\n   }\n   token += 3;\n   *y = (int) strtol(token, &token, 10);\n   while (*token == ' ') ++token;\n   if (strncmp(token, \"+X \", 3)) {\n       stbi__rewind( s );\n       return 0;\n   }\n   token += 3;\n   *x = (int) strtol(token, NULL, 10);\n   *comp = 3;\n   return 1;\n}\n#endif // STBI_NO_HDR\n\n#ifndef STBI_NO_BMP\nstatic int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   void *p;\n   stbi__bmp_data info;\n\n   info.all_a = 255;\n   p = stbi__bmp_parse_header(s, &info);\n   stbi__rewind( s );\n   if (p == NULL)\n      return 0;\n   if (x) *x = s->img_x;\n   if (y) *y = s->img_y;\n   if (comp) *comp = info.ma ? 4 : 3;\n   return 1;\n}\n#endif\n\n#ifndef STBI_NO_PSD\nstatic int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   int channelCount, dummy;\n   if (!x) x = &dummy;\n   if (!y) y = &dummy;\n   if (!comp) comp = &dummy;\n   if (stbi__get32be(s) != 0x38425053) {\n       stbi__rewind( s );\n       return 0;\n   }\n   if (stbi__get16be(s) != 1) {\n       stbi__rewind( s );\n       return 0;\n   }\n   stbi__skip(s, 6);\n   channelCount = stbi__get16be(s);\n   if (channelCount < 0 || channelCount > 16) {\n       stbi__rewind( s );\n       return 0;\n   }\n   *y = stbi__get32be(s);\n   *x = stbi__get32be(s);\n   if (stbi__get16be(s) != 8) {\n       stbi__rewind( s );\n       return 0;\n   }\n   if (stbi__get16be(s) != 3) {\n       stbi__rewind( s );\n       return 0;\n   }\n   *comp = 4;\n   return 1;\n}\n#endif\n\n#ifndef STBI_NO_PIC\nstatic int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   int act_comp=0,num_packets=0,chained,dummy;\n   stbi__pic_packet packets[10];\n\n   if (!x) x = &dummy;\n   if (!y) y = &dummy;\n   if (!comp) comp = &dummy;\n\n   if (!stbi__pic_is4(s,\"\\x53\\x80\\xF6\\x34\")) {\n      stbi__rewind(s);\n      return 0;\n   }\n\n   stbi__skip(s, 88);\n\n   *x = stbi__get16be(s);\n   *y = stbi__get16be(s);\n   if (stbi__at_eof(s)) {\n      stbi__rewind( s);\n      return 0;\n   }\n   if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) {\n      stbi__rewind( s );\n      return 0;\n   }\n\n   stbi__skip(s, 8);\n\n   do {\n      stbi__pic_packet *packet;\n\n      if (num_packets==sizeof(packets)/sizeof(packets[0]))\n         return 0;\n\n      packet = &packets[num_packets++];\n      chained = stbi__get8(s);\n      packet->size    = stbi__get8(s);\n      packet->type    = stbi__get8(s);\n      packet->channel = stbi__get8(s);\n      act_comp |= packet->channel;\n\n      if (stbi__at_eof(s)) {\n          stbi__rewind( s );\n          return 0;\n      }\n      if (packet->size != 8) {\n          stbi__rewind( s );\n          return 0;\n      }\n   } while (chained);\n\n   *comp = (act_comp & 0x10 ? 4 : 3);\n\n   return 1;\n}\n#endif\n\n// *************************************************************************************************\n// Portable Gray Map and Portable Pixel Map loader\n// by Ken Miller\n//\n// PGM: http://netpbm.sourceforge.net/doc/pgm.html\n// PPM: http://netpbm.sourceforge.net/doc/ppm.html\n//\n// Known limitations:\n//    Does not support comments in the header section\n//    Does not support ASCII image data (formats P2 and P3)\n//    Does not support 16-bit-per-channel\n\n#ifndef STBI_NO_PNM\n\nstatic int      stbi__pnm_test(stbi__context *s)\n{\n   char p, t;\n   p = (char) stbi__get8(s);\n   t = (char) stbi__get8(s);\n   if (p != 'P' || (t != '5' && t != '6')) {\n       stbi__rewind( s );\n       return 0;\n   }\n   return 1;\n}\n\nstatic void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)\n{\n   stbi_uc *out;\n   STBI_NOTUSED(ri);\n\n   if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n))\n      return 0;\n\n   *x = s->img_x;\n   *y = s->img_y;\n   if (comp) *comp = s->img_n;\n\n   if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0))\n      return stbi__errpuc(\"too large\", \"PNM too large\");\n\n   out = (stbi_uc *) stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0);\n   if (!out) return stbi__errpuc(\"outofmem\", \"Out of memory\");\n   stbi__getn(s, out, s->img_n * s->img_x * s->img_y);\n\n   if (req_comp && req_comp != s->img_n) {\n      out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);\n      if (out == NULL) return out; // stbi__convert_format frees input on failure\n   }\n   return out;\n}\n\nstatic int      stbi__pnm_isspace(char c)\n{\n   return c == ' ' || c == '\\t' || c == '\\n' || c == '\\v' || c == '\\f' || c == '\\r';\n}\n\nstatic void     stbi__pnm_skip_whitespace(stbi__context *s, char *c)\n{\n   for (;;) {\n      while (!stbi__at_eof(s) && stbi__pnm_isspace(*c))\n         *c = (char) stbi__get8(s);\n\n      if (stbi__at_eof(s) || *c != '#')\n         break;\n\n      while (!stbi__at_eof(s) && *c != '\\n' && *c != '\\r' )\n         *c = (char) stbi__get8(s);\n   }\n}\n\nstatic int      stbi__pnm_isdigit(char c)\n{\n   return c >= '0' && c <= '9';\n}\n\nstatic int      stbi__pnm_getinteger(stbi__context *s, char *c)\n{\n   int value = 0;\n\n   while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) {\n      value = value*10 + (*c - '0');\n      *c = (char) stbi__get8(s);\n   }\n\n   return value;\n}\n\nstatic int      stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp)\n{\n   int maxv, dummy;\n   char c, p, t;\n\n   if (!x) x = &dummy;\n   if (!y) y = &dummy;\n   if (!comp) comp = &dummy;\n\n   stbi__rewind(s);\n\n   // Get identifier\n   p = (char) stbi__get8(s);\n   t = (char) stbi__get8(s);\n   if (p != 'P' || (t != '5' && t != '6')) {\n       stbi__rewind(s);\n       return 0;\n   }\n\n   *comp = (t == '6') ? 3 : 1;  // '5' is 1-component .pgm; '6' is 3-component .ppm\n\n   c = (char) stbi__get8(s);\n   stbi__pnm_skip_whitespace(s, &c);\n\n   *x = stbi__pnm_getinteger(s, &c); // read width\n   stbi__pnm_skip_whitespace(s, &c);\n\n   *y = stbi__pnm_getinteger(s, &c); // read height\n   stbi__pnm_skip_whitespace(s, &c);\n\n   maxv = stbi__pnm_getinteger(s, &c);  // read max value\n\n   if (maxv > 255)\n      return stbi__err(\"max value > 255\", \"PPM image not 8-bit\");\n   else\n      return 1;\n}\n#endif\n\nstatic int stbi__info_main(stbi__context *s, int *x, int *y, int *comp)\n{\n   #ifndef STBI_NO_JPEG\n   if (stbi__jpeg_info(s, x, y, comp)) return 1;\n   #endif\n\n   #ifndef STBI_NO_PNG\n   if (stbi__png_info(s, x, y, comp))  return 1;\n   #endif\n\n   #ifndef STBI_NO_GIF\n   if (stbi__gif_info(s, x, y, comp))  return 1;\n   #endif\n\n   #ifndef STBI_NO_BMP\n   if (stbi__bmp_info(s, x, y, comp))  return 1;\n   #endif\n\n   #ifndef STBI_NO_PSD\n   if (stbi__psd_info(s, x, y, comp))  return 1;\n   #endif\n\n   #ifndef STBI_NO_PIC\n   if (stbi__pic_info(s, x, y, comp))  return 1;\n   #endif\n\n   #ifndef STBI_NO_PNM\n   if (stbi__pnm_info(s, x, y, comp))  return 1;\n   #endif\n\n   #ifndef STBI_NO_HDR\n   if (stbi__hdr_info(s, x, y, comp))  return 1;\n   #endif\n\n   // test tga last because it's a crappy test!\n   #ifndef STBI_NO_TGA\n   if (stbi__tga_info(s, x, y, comp))\n       return 1;\n   #endif\n   return stbi__err(\"unknown image type\", \"Image not of any known type, or corrupt\");\n}\n\n#ifndef STBI_NO_STDIO\nSTBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp)\n{\n    FILE *f = stbi__fopen(filename, \"rb\");\n    int result;\n    if (!f) return stbi__err(\"can't fopen\", \"Unable to open file\");\n    result = stbi_info_from_file(f, x, y, comp);\n    fclose(f);\n    return result;\n}\n\nSTBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp)\n{\n   int r;\n   stbi__context s;\n   long pos = ftell(f);\n   stbi__start_file(&s, f);\n   r = stbi__info_main(&s,x,y,comp);\n   fseek(f,pos,SEEK_SET);\n   return r;\n}\n#endif // !STBI_NO_STDIO\n\nSTBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp)\n{\n   stbi__context s;\n   stbi__start_mem(&s,buffer,len);\n   return stbi__info_main(&s,x,y,comp);\n}\n\nSTBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp)\n{\n   stbi__context s;\n   stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user);\n   return stbi__info_main(&s,x,y,comp);\n}\n\n#endif // STB_IMAGE_IMPLEMENTATION\n\n/*\n   revision history:\n      2.15  (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode;\n                         warning fixes; disable run-time SSE detection on gcc;\n                         uniform handling of optional \"return\" values;\n                         thread-safe initialization of zlib tables\n      2.14  (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs\n      2.13  (2016-11-29) add 16-bit API, only supported for PNG right now\n      2.12  (2016-04-02) fix typo in 2.11 PSD fix that caused crashes\n      2.11  (2016-04-02) allocate large structures on the stack\n                         remove white matting for transparent PSD\n                         fix reported channel count for PNG & BMP\n                         re-enable SSE2 in non-gcc 64-bit\n                         support RGB-formatted JPEG\n                         read 16-bit PNGs (only as 8-bit)\n      2.10  (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED\n      2.09  (2016-01-16) allow comments in PNM files\n                         16-bit-per-pixel TGA (not bit-per-component)\n                         info() for TGA could break due to .hdr handling\n                         info() for BMP to shares code instead of sloppy parse\n                         can use STBI_REALLOC_SIZED if allocator doesn't support realloc\n                         code cleanup\n      2.08  (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA\n      2.07  (2015-09-13) fix compiler warnings\n                         partial animated GIF support\n                         limited 16-bpc PSD support\n                         #ifdef unused functions\n                         bug with < 92 byte PIC,PNM,HDR,TGA\n      2.06  (2015-04-19) fix bug where PSD returns wrong '*comp' value\n      2.05  (2015-04-19) fix bug in progressive JPEG handling, fix warning\n      2.04  (2015-04-15) try to re-enable SIMD on MinGW 64-bit\n      2.03  (2015-04-12) extra corruption checking (mmozeiko)\n                         stbi_set_flip_vertically_on_load (nguillemot)\n                         fix NEON support; fix mingw support\n      2.02  (2015-01-19) fix incorrect assert, fix warning\n      2.01  (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2\n      2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG\n      2.00  (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg)\n                         progressive JPEG (stb)\n                         PGM/PPM support (Ken Miller)\n                         STBI_MALLOC,STBI_REALLOC,STBI_FREE\n                         GIF bugfix -- seemingly never worked\n                         STBI_NO_*, STBI_ONLY_*\n      1.48  (2014-12-14) fix incorrectly-named assert()\n      1.47  (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb)\n                         optimize PNG (ryg)\n                         fix bug in interlaced PNG with user-specified channel count (stb)\n      1.46  (2014-08-26)\n              fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG\n      1.45  (2014-08-16)\n              fix MSVC-ARM internal compiler error by wrapping malloc\n      1.44  (2014-08-07)\n              various warning fixes from Ronny Chevalier\n      1.43  (2014-07-15)\n              fix MSVC-only compiler problem in code changed in 1.42\n      1.42  (2014-07-09)\n              don't define _CRT_SECURE_NO_WARNINGS (affects user code)\n              fixes to stbi__cleanup_jpeg path\n              added STBI_ASSERT to avoid requiring assert.h\n      1.41  (2014-06-25)\n              fix search&replace from 1.36 that messed up comments/error messages\n      1.40  (2014-06-22)\n              fix gcc struct-initialization warning\n      1.39  (2014-06-15)\n              fix to TGA optimization when req_comp != number of components in TGA;\n              fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite)\n              add support for BMP version 5 (more ignored fields)\n      1.38  (2014-06-06)\n              suppress MSVC warnings on integer casts truncating values\n              fix accidental rename of 'skip' field of I/O\n      1.37  (2014-06-04)\n              remove duplicate typedef\n      1.36  (2014-06-03)\n              convert to header file single-file library\n              if de-iphone isn't set, load iphone images color-swapped instead of returning NULL\n      1.35  (2014-05-27)\n              various warnings\n              fix broken STBI_SIMD path\n              fix bug where stbi_load_from_file no longer left file pointer in correct place\n              fix broken non-easy path for 32-bit BMP (possibly never used)\n              TGA optimization by Arseny Kapoulkine\n      1.34  (unknown)\n              use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case\n      1.33  (2011-07-14)\n              make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements\n      1.32  (2011-07-13)\n              support for \"info\" function for all supported filetypes (SpartanJ)\n      1.31  (2011-06-20)\n              a few more leak fixes, bug in PNG handling (SpartanJ)\n      1.30  (2011-06-11)\n              added ability to load files via callbacks to accomidate custom input streams (Ben Wenger)\n              removed deprecated format-specific test/load functions\n              removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway\n              error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha)\n              fix inefficiency in decoding 32-bit BMP (David Woo)\n      1.29  (2010-08-16)\n              various warning fixes from Aurelien Pocheville\n      1.28  (2010-08-01)\n              fix bug in GIF palette transparency (SpartanJ)\n      1.27  (2010-08-01)\n              cast-to-stbi_uc to fix warnings\n      1.26  (2010-07-24)\n              fix bug in file buffering for PNG reported by SpartanJ\n      1.25  (2010-07-17)\n              refix trans_data warning (Won Chun)\n      1.24  (2010-07-12)\n              perf improvements reading from files on platforms with lock-heavy fgetc()\n              minor perf improvements for jpeg\n              deprecated type-specific functions so we'll get feedback if they're needed\n              attempt to fix trans_data warning (Won Chun)\n      1.23    fixed bug in iPhone support\n      1.22  (2010-07-10)\n              removed image *writing* support\n              stbi_info support from Jetro Lauha\n              GIF support from Jean-Marc Lienher\n              iPhone PNG-extensions from James Brown\n              warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva)\n      1.21    fix use of 'stbi_uc' in header (reported by jon blow)\n      1.20    added support for Softimage PIC, by Tom Seddon\n      1.19    bug in interlaced PNG corruption check (found by ryg)\n      1.18  (2008-08-02)\n              fix a threading bug (local mutable static)\n      1.17    support interlaced PNG\n      1.16    major bugfix - stbi__convert_format converted one too many pixels\n      1.15    initialize some fields for thread safety\n      1.14    fix threadsafe conversion bug\n              header-file-only version (#define STBI_HEADER_FILE_ONLY before including)\n      1.13    threadsafe\n      1.12    const qualifiers in the API\n      1.11    Support installable IDCT, colorspace conversion routines\n      1.10    Fixes for 64-bit (don't use \"unsigned long\")\n              optimized upsampling by Fabian \"ryg\" Giesen\n      1.09    Fix format-conversion for PSD code (bad global variables!)\n      1.08    Thatcher Ulrich's PSD code integrated by Nicolas Schulz\n      1.07    attempt to fix C++ warning/errors again\n      1.06    attempt to fix C++ warning/errors again\n      1.05    fix TGA loading to return correct *comp and use good luminance calc\n      1.04    default float alpha is 1, not 255; use 'void *' for stbi_image_free\n      1.03    bugfixes to STBI_NO_STDIO, STBI_NO_HDR\n      1.02    support for (subset of) HDR files, float interface for preferred access to them\n      1.01    fix bug: possible bug in handling right-side up bmps... not sure\n              fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all\n      1.00    interface to zlib that skips zlib header\n      0.99    correct handling of alpha in palette\n      0.98    TGA loader by lonesock; dynamically add loaders (untested)\n      0.97    jpeg errors on too large a file; also catch another malloc failure\n      0.96    fix detection of invalid v value - particleman@mollyrocket forum\n      0.95    during header scan, seek to markers in case of padding\n      0.94    STBI_NO_STDIO to disable stdio usage; rename all #defines the same\n      0.93    handle jpegtran output; verbose errors\n      0.92    read 4,8,16,24,32-bit BMP files of several formats\n      0.91    output 24-bit Windows 3.0 BMP files\n      0.90    fix a few more warnings; bump version number to approach 1.0\n      0.61    bugfixes due to Marc LeBlanc, Christopher Lloyd\n      0.60    fix compiling as c++\n      0.59    fix warnings: merge Dave Moore's -Wall fixes\n      0.58    fix bug: zlib uncompressed mode len/nlen was wrong endian\n      0.57    fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available\n      0.56    fix bug: zlib uncompressed mode len vs. nlen\n      0.55    fix bug: restart_interval not initialized to 0\n      0.54    allow NULL for 'int *comp'\n      0.53    fix bug in png 3->4; speedup png decoding\n      0.52    png handles req_comp=3,4 directly; minor cleanup; jpeg comments\n      0.51    obey req_comp requests, 1-component jpegs return as 1-component,\n              on 'test' only check type, not whether we support this variant\n      0.50  (2006-11-19)\n              first released version\n*/\n\n\n/*\n------------------------------------------------------------------------------\nThis software is available under 2 licenses -- choose whichever you prefer.\n------------------------------------------------------------------------------\nALTERNATIVE A - MIT License\nCopyright (c) 2017 Sean Barrett\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n------------------------------------------------------------------------------\nALTERNATIVE B - Public Domain (www.unlicense.org)\nThis is free and unencumbered software released into the public domain.\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute this\nsoftware, either in source code form or as a compiled binary, for any purpose,\ncommercial or non-commercial, and by any means.\nIn jurisdictions that recognize copyright laws, the author or authors of this\nsoftware dedicate any and all copyright interest in the software to the public\ndomain. We make this dedication for the benefit of the public at large and to\nthe detriment of our heirs and successors. We intend this dedication to be an\novert act of relinquishment in perpetuity of all present and future rights to\nthis software under copyright law.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\nACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n------------------------------------------------------------------------------\n*/\n"
  },
  {
    "path": "C/stb_writer.h",
    "content": "/* stb_image_write - v1.15 - public domain - http://nothings.org/stb\n   writes out PNG/BMP/TGA/JPEG/HDR images to C stdio - Sean Barrett 2010-2015\n                                     no warranty implied; use at your own risk\n\n   Before #including,\n\n       #define STB_IMAGE_WRITE_IMPLEMENTATION\n\n   in the file that you want to have the implementation.\n\n   Will probably not work correctly with strict-aliasing optimizations.\n\nABOUT:\n\n   This header file is a library for writing images to C stdio or a callback.\n\n   The PNG output is not optimal; it is 20-50% larger than the file\n   written by a decent optimizing implementation; though providing a custom\n   zlib compress function (see STBIW_ZLIB_COMPRESS) can mitigate that.\n   This library is designed for source code compactness and simplicity,\n   not optimal image file size or run-time performance.\n\nBUILDING:\n\n   You can #define STBIW_ASSERT(x) before the #include to avoid using assert.h.\n   You can #define STBIW_MALLOC(), STBIW_REALLOC(), and STBIW_FREE() to replace\n   malloc,realloc,free.\n   You can #define STBIW_MEMMOVE() to replace memmove()\n   You can #define STBIW_ZLIB_COMPRESS to use a custom zlib-style compress function\n   for PNG compression (instead of the builtin one), it must have the following signature:\n   unsigned char * my_compress(unsigned char *data, int data_len, int *out_len, int quality);\n   The returned data will be freed with STBIW_FREE() (free() by default),\n   so it must be heap allocated with STBIW_MALLOC() (malloc() by default),\n\nUNICODE:\n\n   If compiling for Windows and you wish to use Unicode filenames, compile\n   with\n       #define STBIW_WINDOWS_UTF8\n   and pass utf8-encoded filenames. Call stbiw_convert_wchar_to_utf8 to convert\n   Windows wchar_t filenames to utf8.\n\nUSAGE:\n\n   There are five functions, one for each image file format:\n\n     int stbi_write_png(char const *filename, int w, int h, int comp, const void *data, int stride_in_bytes);\n     int stbi_write_bmp(char const *filename, int w, int h, int comp, const void *data);\n     int stbi_write_tga(char const *filename, int w, int h, int comp, const void *data);\n     int stbi_write_jpg(char const *filename, int w, int h, int comp, const void *data, int quality);\n     int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);\n\n     void stbi_flip_vertically_on_write(int flag); // flag is non-zero to flip data vertically\n\n   There are also five equivalent functions that use an arbitrary write function. You are\n   expected to open/close your file-equivalent before and after calling these:\n\n     int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data, int stride_in_bytes);\n     int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);\n     int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);\n     int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);\n     int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality);\n\n   where the callback is:\n      void stbi_write_func(void *context, void *data, int size);\n\n   You can configure it with these global variables:\n      int stbi_write_tga_with_rle;             // defaults to true; set to 0 to disable RLE\n      int stbi_write_png_compression_level;    // defaults to 8; set to higher for more compression\n      int stbi_write_force_png_filter;         // defaults to -1; set to 0..5 to force a filter mode\n\n\n   You can define STBI_WRITE_NO_STDIO to disable the file variant of these\n   functions, so the library will not use stdio.h at all. However, this will\n   also disable HDR writing, because it requires stdio for formatted output.\n\n   Each function returns 0 on failure and non-0 on success.\n\n   The functions create an image file defined by the parameters. The image\n   is a rectangle of pixels stored from left-to-right, top-to-bottom.\n   Each pixel contains 'comp' channels of data stored interleaved with 8-bits\n   per channel, in the following order: 1=Y, 2=YA, 3=RGB, 4=RGBA. (Y is\n   monochrome color.) The rectangle is 'w' pixels wide and 'h' pixels tall.\n   The *data pointer points to the first byte of the top-left-most pixel.\n   For PNG, \"stride_in_bytes\" is the distance in bytes from the first byte of\n   a row of pixels to the first byte of the next row of pixels.\n\n   PNG creates output files with the same number of components as the input.\n   The BMP format expands Y to RGB in the file format and does not\n   output alpha.\n\n   PNG supports writing rectangles of data even when the bytes storing rows of\n   data are not consecutive in memory (e.g. sub-rectangles of a larger image),\n   by supplying the stride between the beginning of adjacent rows. The other\n   formats do not. (Thus you cannot write a native-format BMP through the BMP\n   writer, both because it is in BGR order and because it may have padding\n   at the end of the line.)\n\n   PNG allows you to set the deflate compression level by setting the global\n   variable 'stbi_write_png_compression_level' (it defaults to 8).\n\n   HDR expects linear float data. Since the format is always 32-bit rgb(e)\n   data, alpha (if provided) is discarded, and for monochrome data it is\n   replicated across all three channels.\n\n   TGA supports RLE or non-RLE compressed data. To use non-RLE-compressed\n   data, set the global variable 'stbi_write_tga_with_rle' to 0.\n\n   JPEG does ignore alpha channels in input data; quality is between 1 and 100.\n   Higher quality looks better but results in a bigger image.\n   JPEG baseline (no JPEG progressive).\n\nCREDITS:\n\n\n   Sean Barrett           -    PNG/BMP/TGA\n   Baldur Karlsson        -    HDR\n   Jean-Sebastien Guay    -    TGA monochrome\n   Tim Kelsey             -    misc enhancements\n   Alan Hickman           -    TGA RLE\n   Emmanuel Julien        -    initial file IO callback implementation\n   Jon Olick              -    original jo_jpeg.cpp code\n   Daniel Gibson          -    integrate JPEG, allow external zlib\n   Aarni Koskela          -    allow choosing PNG filter\n\n   bugfixes:\n      github:Chribba\n      Guillaume Chereau\n      github:jry2\n      github:romigrou\n      Sergio Gonzalez\n      Jonas Karlsson\n      Filip Wasil\n      Thatcher Ulrich\n      github:poppolopoppo\n      Patrick Boettcher\n      github:xeekworx\n      Cap Petschulat\n      Simon Rodriguez\n      Ivan Tikhonov\n      github:ignotion\n      Adam Schackart\n\nLICENSE\n\n  See end of file for license information.\n\n*/\n\n#ifndef INCLUDE_STB_IMAGE_WRITE_H\n#define INCLUDE_STB_IMAGE_WRITE_H\n\n#include <stdlib.h>\n\n// if STB_IMAGE_WRITE_STATIC causes problems, try defining STBIWDEF to 'inline' or 'static inline'\n#ifndef STBIWDEF\n#ifdef STB_IMAGE_WRITE_STATIC\n#define STBIWDEF  static\n#else\n#ifdef __cplusplus\n#define STBIWDEF  extern \"C\"\n#else\n#define STBIWDEF  extern\n#endif\n#endif\n#endif\n\n#ifndef STB_IMAGE_WRITE_STATIC  // C++ forbids static forward declarations\nextern int stbi_write_tga_with_rle;\nextern int stbi_write_png_compression_level;\nextern int stbi_write_force_png_filter;\n#endif\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_png(char const *filename, int w, int h, int comp, const void  *data, int stride_in_bytes);\nSTBIWDEF int stbi_write_bmp(char const *filename, int w, int h, int comp, const void  *data);\nSTBIWDEF int stbi_write_tga(char const *filename, int w, int h, int comp, const void  *data);\nSTBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data);\nSTBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void  *data, int quality);\n\n#ifdef STBI_WINDOWS_UTF8\nSTBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input);\n#endif\n#endif\n\ntypedef void stbi_write_func(void *context, void *data, int size);\n\nSTBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data, int stride_in_bytes);\nSTBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);\nSTBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const void  *data);\nSTBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int w, int h, int comp, const float *data);\nSTBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void  *data, int quality);\n\nSTBIWDEF void stbi_flip_vertically_on_write(int flip_boolean);\n\n#endif//INCLUDE_STB_IMAGE_WRITE_H\n\n#ifdef STB_IMAGE_WRITE_IMPLEMENTATION\n\n#ifdef _WIN32\n   #ifndef _CRT_SECURE_NO_WARNINGS\n   #define _CRT_SECURE_NO_WARNINGS\n   #endif\n   #ifndef _CRT_NONSTDC_NO_DEPRECATE\n   #define _CRT_NONSTDC_NO_DEPRECATE\n   #endif\n#endif\n\n#ifndef STBI_WRITE_NO_STDIO\n#include <stdio.h>\n#endif // STBI_WRITE_NO_STDIO\n\n#include <stdarg.h>\n#include <stdlib.h>\n#include <string.h>\n#include <math.h>\n\n#if defined(STBIW_MALLOC) && defined(STBIW_FREE) && (defined(STBIW_REALLOC) || defined(STBIW_REALLOC_SIZED))\n// ok\n#elif !defined(STBIW_MALLOC) && !defined(STBIW_FREE) && !defined(STBIW_REALLOC) && !defined(STBIW_REALLOC_SIZED)\n// ok\n#else\n#error \"Must define all or none of STBIW_MALLOC, STBIW_FREE, and STBIW_REALLOC (or STBIW_REALLOC_SIZED).\"\n#endif\n\n#ifndef STBIW_MALLOC\n#define STBIW_MALLOC(sz)        malloc(sz)\n#define STBIW_REALLOC(p,newsz)  realloc(p,newsz)\n#define STBIW_FREE(p)           free(p)\n#endif\n\n#ifndef STBIW_REALLOC_SIZED\n#define STBIW_REALLOC_SIZED(p,oldsz,newsz) STBIW_REALLOC(p,newsz)\n#endif\n\n\n#ifndef STBIW_MEMMOVE\n#define STBIW_MEMMOVE(a,b,sz) memmove(a,b,sz)\n#endif\n\n\n#ifndef STBIW_ASSERT\n#include <assert.h>\n#define STBIW_ASSERT(x) assert(x)\n#endif\n\n#define STBIW_UCHAR(x) (unsigned char) ((x) & 0xff)\n\n#ifdef STB_IMAGE_WRITE_STATIC\nstatic int stbi_write_png_compression_level = 8;\nstatic int stbi_write_tga_with_rle = 1;\nstatic int stbi_write_force_png_filter = -1;\n#else\nint stbi_write_png_compression_level = 8;\nint stbi_write_tga_with_rle = 1;\nint stbi_write_force_png_filter = -1;\n#endif\n\nstatic int stbi__flip_vertically_on_write = 0;\n\nSTBIWDEF void stbi_flip_vertically_on_write(int flag)\n{\n   stbi__flip_vertically_on_write = flag;\n}\n\ntypedef struct\n{\n   stbi_write_func *func;\n   void *context;\n   unsigned char buffer[64];\n   int buf_used;\n} stbi__write_context;\n\n// initialize a callback-based context\nstatic void stbi__start_write_callbacks(stbi__write_context *s, stbi_write_func *c, void *context)\n{\n   s->func    = c;\n   s->context = context;\n}\n\n#ifndef STBI_WRITE_NO_STDIO\n\nstatic void stbi__stdio_write(void *context, void *data, int size)\n{\n   fwrite(data,1,size,(FILE*) context);\n}\n\n#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)\n#ifdef __cplusplus\n#define STBIW_EXTERN extern \"C\"\n#else\n#define STBIW_EXTERN extern\n#endif\nSTBIW_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide);\nSTBIW_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default);\n\nSTBIWDEF int stbiw_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input)\n{\n\treturn WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL);\n}\n#endif\n\nstatic FILE *stbiw__fopen(char const *filename, char const *mode)\n{\n   FILE *f;\n#if defined(_MSC_VER) && defined(STBI_WINDOWS_UTF8)\n   wchar_t wMode[64];\n   wchar_t wFilename[1024];\n\tif (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))\n      return 0;\n\n\tif (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))\n      return 0;\n\n#if _MSC_VER >= 1400\n\tif (0 != _wfopen_s(&f, wFilename, wMode))\n\t\tf = 0;\n#else\n   f = _wfopen(wFilename, wMode);\n#endif\n\n#elif defined(_MSC_VER) && _MSC_VER >= 1400\n   if (0 != fopen_s(&f, filename, mode))\n      f=0;\n#else\n   f = fopen(filename, mode);\n#endif\n   return f;\n}\n\nstatic int stbi__start_write_file(stbi__write_context *s, const char *filename)\n{\n   FILE *f = stbiw__fopen(filename, \"wb\");\n   stbi__start_write_callbacks(s, stbi__stdio_write, (void *) f);\n   return f != NULL;\n}\n\nstatic void stbi__end_write_file(stbi__write_context *s)\n{\n   fclose((FILE *)s->context);\n}\n\n#endif // !STBI_WRITE_NO_STDIO\n\ntypedef unsigned int stbiw_uint32;\ntypedef int stb_image_write_test[sizeof(stbiw_uint32)==4 ? 1 : -1];\n\nstatic void stbiw__writefv(stbi__write_context *s, const char *fmt, va_list v)\n{\n   while (*fmt) {\n      switch (*fmt++) {\n         case ' ': break;\n         case '1': { unsigned char x = STBIW_UCHAR(va_arg(v, int));\n                     s->func(s->context,&x,1);\n                     break; }\n         case '2': { int x = va_arg(v,int);\n                     unsigned char b[2];\n                     b[0] = STBIW_UCHAR(x);\n                     b[1] = STBIW_UCHAR(x>>8);\n                     s->func(s->context,b,2);\n                     break; }\n         case '4': { stbiw_uint32 x = va_arg(v,int);\n                     unsigned char b[4];\n                     b[0]=STBIW_UCHAR(x);\n                     b[1]=STBIW_UCHAR(x>>8);\n                     b[2]=STBIW_UCHAR(x>>16);\n                     b[3]=STBIW_UCHAR(x>>24);\n                     s->func(s->context,b,4);\n                     break; }\n         default:\n            STBIW_ASSERT(0);\n            return;\n      }\n   }\n}\n\nstatic void stbiw__writef(stbi__write_context *s, const char *fmt, ...)\n{\n   va_list v;\n   va_start(v, fmt);\n   stbiw__writefv(s, fmt, v);\n   va_end(v);\n}\n\nstatic void stbiw__write_flush(stbi__write_context *s)\n{\n   if (s->buf_used) {\n      s->func(s->context, &s->buffer, s->buf_used);\n      s->buf_used = 0;\n   }\n}\n\nstatic void stbiw__putc(stbi__write_context *s, unsigned char c)\n{\n   s->func(s->context, &c, 1);\n}\n\nstatic void stbiw__write1(stbi__write_context *s, unsigned char a)\n{\n   if (s->buf_used + 1 > sizeof(s->buffer))\n      stbiw__write_flush(s);\n   s->buffer[s->buf_used++] = a;\n}\n\nstatic void stbiw__write3(stbi__write_context *s, unsigned char a, unsigned char b, unsigned char c)\n{\n   int n;\n   if (s->buf_used + 3 > sizeof(s->buffer))\n      stbiw__write_flush(s);\n   n = s->buf_used;\n   s->buf_used = n+3;\n   s->buffer[n+0] = a;\n   s->buffer[n+1] = b;\n   s->buffer[n+2] = c;\n}\n\nstatic void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, int write_alpha, int expand_mono, unsigned char *d)\n{\n   unsigned char bg[3] = { 255, 0, 255}, px[3];\n   int k;\n\n   if (write_alpha < 0)\n      stbiw__write1(s, d[comp - 1]);\n\n   switch (comp) {\n      case 2: // 2 pixels = mono + alpha, alpha is written separately, so same as 1-channel case\n      case 1:\n         if (expand_mono)\n            stbiw__write3(s, d[0], d[0], d[0]); // monochrome bmp\n         else\n            stbiw__write1(s, d[0]);  // monochrome TGA\n         break;\n      case 4:\n         if (!write_alpha) {\n            // composite against pink background\n            for (k = 0; k < 3; ++k)\n               px[k] = bg[k] + ((d[k] - bg[k]) * d[3]) / 255;\n            stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);\n            break;\n         }\n         /* FALLTHROUGH */\n      case 3:\n         stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);\n         break;\n   }\n   if (write_alpha > 0)\n      stbiw__write1(s, d[comp - 1]);\n}\n\nstatic void stbiw__write_pixels(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, void *data, int write_alpha, int scanline_pad, int expand_mono)\n{\n   stbiw_uint32 zero = 0;\n   int i,j, j_end;\n\n   if (y <= 0)\n      return;\n\n   if (stbi__flip_vertically_on_write)\n      vdir *= -1;\n\n   if (vdir < 0) {\n      j_end = -1; j = y-1;\n   } else {\n      j_end =  y; j = 0;\n   }\n\n   for (; j != j_end; j += vdir) {\n      for (i=0; i < x; ++i) {\n         unsigned char *d = (unsigned char *) data + (j*x+i)*comp;\n         stbiw__write_pixel(s, rgb_dir, comp, write_alpha, expand_mono, d);\n      }\n      stbiw__write_flush(s);\n      s->func(s->context, &zero, scanline_pad);\n   }\n}\n\nstatic int stbiw__outfile(stbi__write_context *s, int rgb_dir, int vdir, int x, int y, int comp, int expand_mono, void *data, int alpha, int pad, const char *fmt, ...)\n{\n   if (y < 0 || x < 0) {\n      return 0;\n   } else {\n      va_list v;\n      va_start(v, fmt);\n      stbiw__writefv(s, fmt, v);\n      va_end(v);\n      stbiw__write_pixels(s,rgb_dir,vdir,x,y,comp,data,alpha,pad, expand_mono);\n      return 1;\n   }\n}\n\nstatic int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, const void *data)\n{\n   int pad = (-x*3) & 3;\n   return stbiw__outfile(s,-1,-1,x,y,comp,1,(void *) data,0,pad,\n           \"11 4 22 4\" \"4 44 22 444444\",\n           'B', 'M', 14+40+(x*3+pad)*y, 0,0, 14+40,  // file header\n            40, x,y, 1,24, 0,0,0,0,0,0);             // bitmap header\n}\n\nSTBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)\n{\n   stbi__write_context s = { 0 };\n   stbi__start_write_callbacks(&s, func, context);\n   return stbi_write_bmp_core(&s, x, y, comp, data);\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data)\n{\n   stbi__write_context s = { 0 };\n   if (stbi__start_write_file(&s,filename)) {\n      int r = stbi_write_bmp_core(&s, x, y, comp, data);\n      stbi__end_write_file(&s);\n      return r;\n   } else\n      return 0;\n}\n#endif //!STBI_WRITE_NO_STDIO\n\nstatic int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, void *data)\n{\n   int has_alpha = (comp == 2 || comp == 4);\n   int colorbytes = has_alpha ? comp-1 : comp;\n   int format = colorbytes < 2 ? 3 : 2; // 3 color channels (RGB/RGBA) = 2, 1 color channel (Y/YA) = 3\n\n   if (y < 0 || x < 0)\n      return 0;\n\n   if (!stbi_write_tga_with_rle) {\n      return stbiw__outfile(s, -1, -1, x, y, comp, 0, (void *) data, has_alpha, 0,\n         \"111 221 2222 11\", 0, 0, format, 0, 0, 0, 0, 0, x, y, (colorbytes + has_alpha) * 8, has_alpha * 8);\n   } else {\n      int i,j,k;\n      int jend, jdir;\n\n      stbiw__writef(s, \"111 221 2222 11\", 0,0,format+8, 0,0,0, 0,0,x,y, (colorbytes + has_alpha) * 8, has_alpha * 8);\n\n      if (stbi__flip_vertically_on_write) {\n         j = 0;\n         jend = y;\n         jdir = 1;\n      } else {\n         j = y-1;\n         jend = -1;\n         jdir = -1;\n      }\n      for (; j != jend; j += jdir) {\n         unsigned char *row = (unsigned char *) data + j * x * comp;\n         int len;\n\n         for (i = 0; i < x; i += len) {\n            unsigned char *begin = row + i * comp;\n            int diff = 1;\n            len = 1;\n\n            if (i < x - 1) {\n               ++len;\n               diff = memcmp(begin, row + (i + 1) * comp, comp);\n               if (diff) {\n                  const unsigned char *prev = begin;\n                  for (k = i + 2; k < x && len < 128; ++k) {\n                     if (memcmp(prev, row + k * comp, comp)) {\n                        prev += comp;\n                        ++len;\n                     } else {\n                        --len;\n                        break;\n                     }\n                  }\n               } else {\n                  for (k = i + 2; k < x && len < 128; ++k) {\n                     if (!memcmp(begin, row + k * comp, comp)) {\n                        ++len;\n                     } else {\n                        break;\n                     }\n                  }\n               }\n            }\n\n            if (diff) {\n               unsigned char header = STBIW_UCHAR(len - 1);\n               stbiw__write1(s, header);\n               for (k = 0; k < len; ++k) {\n                  stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin + k * comp);\n               }\n            } else {\n               unsigned char header = STBIW_UCHAR(len - 129);\n               stbiw__write1(s, header);\n               stbiw__write_pixel(s, -1, comp, has_alpha, 0, begin);\n            }\n         }\n      }\n      stbiw__write_flush(s);\n   }\n   return 1;\n}\n\nSTBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data)\n{\n   stbi__write_context s = { 0 };\n   stbi__start_write_callbacks(&s, func, context);\n   return stbi_write_tga_core(&s, x, y, comp, (void *) data);\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data)\n{\n   stbi__write_context s = { 0 };\n   if (stbi__start_write_file(&s,filename)) {\n      int r = stbi_write_tga_core(&s, x, y, comp, (void *) data);\n      stbi__end_write_file(&s);\n      return r;\n   } else\n      return 0;\n}\n#endif\n\n// *************************************************************************************************\n// Radiance RGBE HDR writer\n// by Baldur Karlsson\n\n#define stbiw__max(a, b)  ((a) > (b) ? (a) : (b))\n\nstatic void stbiw__linear_to_rgbe(unsigned char *rgbe, float *linear)\n{\n   int exponent;\n   float maxcomp = stbiw__max(linear[0], stbiw__max(linear[1], linear[2]));\n\n   if (maxcomp < 1e-32f) {\n      rgbe[0] = rgbe[1] = rgbe[2] = rgbe[3] = 0;\n   } else {\n      float normalize = (float) frexp(maxcomp, &exponent) * 256.0f/maxcomp;\n\n      rgbe[0] = (unsigned char)(linear[0] * normalize);\n      rgbe[1] = (unsigned char)(linear[1] * normalize);\n      rgbe[2] = (unsigned char)(linear[2] * normalize);\n      rgbe[3] = (unsigned char)(exponent + 128);\n   }\n}\n\nstatic void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte)\n{\n   unsigned char lengthbyte = STBIW_UCHAR(length+128);\n   STBIW_ASSERT(length+128 <= 255);\n   s->func(s->context, &lengthbyte, 1);\n   s->func(s->context, &databyte, 1);\n}\n\nstatic void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data)\n{\n   unsigned char lengthbyte = STBIW_UCHAR(length);\n   STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code\n   s->func(s->context, &lengthbyte, 1);\n   s->func(s->context, data, length);\n}\n\nstatic void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int ncomp, unsigned char *scratch, float *scanline)\n{\n   unsigned char scanlineheader[4] = { 2, 2, 0, 0 };\n   unsigned char rgbe[4];\n   float linear[3];\n   int x;\n\n   scanlineheader[2] = (width&0xff00)>>8;\n   scanlineheader[3] = (width&0x00ff);\n\n   /* skip RLE for images too small or large */\n   if (width < 8 || width >= 32768) {\n      for (x=0; x < width; x++) {\n         switch (ncomp) {\n            case 4: /* fallthrough */\n            case 3: linear[2] = scanline[x*ncomp + 2];\n                    linear[1] = scanline[x*ncomp + 1];\n                    linear[0] = scanline[x*ncomp + 0];\n                    break;\n            default:\n                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];\n                    break;\n         }\n         stbiw__linear_to_rgbe(rgbe, linear);\n         s->func(s->context, rgbe, 4);\n      }\n   } else {\n      int c,r;\n      /* encode into scratch buffer */\n      for (x=0; x < width; x++) {\n         switch(ncomp) {\n            case 4: /* fallthrough */\n            case 3: linear[2] = scanline[x*ncomp + 2];\n                    linear[1] = scanline[x*ncomp + 1];\n                    linear[0] = scanline[x*ncomp + 0];\n                    break;\n            default:\n                    linear[0] = linear[1] = linear[2] = scanline[x*ncomp + 0];\n                    break;\n         }\n         stbiw__linear_to_rgbe(rgbe, linear);\n         scratch[x + width*0] = rgbe[0];\n         scratch[x + width*1] = rgbe[1];\n         scratch[x + width*2] = rgbe[2];\n         scratch[x + width*3] = rgbe[3];\n      }\n\n      s->func(s->context, scanlineheader, 4);\n\n      /* RLE each component separately */\n      for (c=0; c < 4; c++) {\n         unsigned char *comp = &scratch[width*c];\n\n         x = 0;\n         while (x < width) {\n            // find first run\n            r = x;\n            while (r+2 < width) {\n               if (comp[r] == comp[r+1] && comp[r] == comp[r+2])\n                  break;\n               ++r;\n            }\n            if (r+2 >= width)\n               r = width;\n            // dump up to first run\n            while (x < r) {\n               int len = r-x;\n               if (len > 128) len = 128;\n               stbiw__write_dump_data(s, len, &comp[x]);\n               x += len;\n            }\n            // if there's a run, output it\n            if (r+2 < width) { // same test as what we break out of in search loop, so only true if we break'd\n               // find next byte after run\n               while (r < width && comp[r] == comp[x])\n                  ++r;\n               // output run up to r\n               while (x < r) {\n                  int len = r-x;\n                  if (len > 127) len = 127;\n                  stbiw__write_run_data(s, len, comp[x]);\n                  x += len;\n               }\n            }\n         }\n      }\n   }\n}\n\nstatic int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data)\n{\n   if (y <= 0 || x <= 0 || data == NULL)\n      return 0;\n   else {\n      // Each component is stored separately. Allocate scratch space for full output scanline.\n      unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4);\n      int i, len;\n      char buffer[128];\n      char header[] = \"#?RADIANCE\\n# Written by stb_image_write.h\\nFORMAT=32-bit_rle_rgbe\\n\";\n      s->func(s->context, header, sizeof(header)-1);\n\n#ifdef __STDC_WANT_SECURE_LIB__\n      len = sprintf_s(buffer, sizeof(buffer), \"EXPOSURE=          1.0000000000000\\n\\n-Y %d +X %d\\n\", y, x);\n#else\n      len = sprintf(buffer, \"EXPOSURE=          1.0000000000000\\n\\n-Y %d +X %d\\n\", y, x);\n#endif\n      s->func(s->context, buffer, len);\n\n      for(i=0; i < y; i++)\n         stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*x*(stbi__flip_vertically_on_write ? y-1-i : i));\n      STBIW_FREE(scratch);\n      return 1;\n   }\n}\n\nSTBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data)\n{\n   stbi__write_context s = { 0 };\n   stbi__start_write_callbacks(&s, func, context);\n   return stbi_write_hdr_core(&s, x, y, comp, (float *) data);\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data)\n{\n   stbi__write_context s = { 0 };\n   if (stbi__start_write_file(&s,filename)) {\n      int r = stbi_write_hdr_core(&s, x, y, comp, (float *) data);\n      stbi__end_write_file(&s);\n      return r;\n   } else\n      return 0;\n}\n#endif // STBI_WRITE_NO_STDIO\n\n\n//////////////////////////////////////////////////////////////////////////////\n//\n// PNG writer\n//\n\n#ifndef STBIW_ZLIB_COMPRESS\n// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount() == vector<>::size()\n#define stbiw__sbraw(a) ((int *) (void *) (a) - 2)\n#define stbiw__sbm(a)   stbiw__sbraw(a)[0]\n#define stbiw__sbn(a)   stbiw__sbraw(a)[1]\n\n#define stbiw__sbneedgrow(a,n)  ((a)==0 || stbiw__sbn(a)+n >= stbiw__sbm(a))\n#define stbiw__sbmaybegrow(a,n) (stbiw__sbneedgrow(a,(n)) ? stbiw__sbgrow(a,n) : 0)\n#define stbiw__sbgrow(a,n)  stbiw__sbgrowf((void **) &(a), (n), sizeof(*(a)))\n\n#define stbiw__sbpush(a, v)      (stbiw__sbmaybegrow(a,1), (a)[stbiw__sbn(a)++] = (v))\n#define stbiw__sbcount(a)        ((a) ? stbiw__sbn(a) : 0)\n#define stbiw__sbfree(a)         ((a) ? STBIW_FREE(stbiw__sbraw(a)),0 : 0)\n\nstatic void *stbiw__sbgrowf(void **arr, int increment, int itemsize)\n{\n   int m = *arr ? 2*stbiw__sbm(*arr)+increment : increment+1;\n   void *p = STBIW_REALLOC_SIZED(*arr ? stbiw__sbraw(*arr) : 0, *arr ? (stbiw__sbm(*arr)*itemsize + sizeof(int)*2) : 0, itemsize * m + sizeof(int)*2);\n   STBIW_ASSERT(p);\n   if (p) {\n      if (!*arr) ((int *) p)[1] = 0;\n      *arr = (void *) ((int *) p + 2);\n      stbiw__sbm(*arr) = m;\n   }\n   return *arr;\n}\n\nstatic unsigned char *stbiw__zlib_flushf(unsigned char *data, unsigned int *bitbuffer, int *bitcount)\n{\n   while (*bitcount >= 8) {\n      stbiw__sbpush(data, STBIW_UCHAR(*bitbuffer));\n      *bitbuffer >>= 8;\n      *bitcount -= 8;\n   }\n   return data;\n}\n\nstatic int stbiw__zlib_bitrev(int code, int codebits)\n{\n   int res=0;\n   while (codebits--) {\n      res = (res << 1) | (code & 1);\n      code >>= 1;\n   }\n   return res;\n}\n\nstatic unsigned int stbiw__zlib_countm(unsigned char *a, unsigned char *b, int limit)\n{\n   int i;\n   for (i=0; i < limit && i < 258; ++i)\n      if (a[i] != b[i]) break;\n   return i;\n}\n\nstatic unsigned int stbiw__zhash(unsigned char *data)\n{\n   stbiw_uint32 hash = data[0] + (data[1] << 8) + (data[2] << 16);\n   hash ^= hash << 3;\n   hash += hash >> 5;\n   hash ^= hash << 4;\n   hash += hash >> 17;\n   hash ^= hash << 25;\n   hash += hash >> 6;\n   return hash;\n}\n\n#define stbiw__zlib_flush() (out = stbiw__zlib_flushf(out, &bitbuf, &bitcount))\n#define stbiw__zlib_add(code,codebits) \\\n      (bitbuf |= (code) << bitcount, bitcount += (codebits), stbiw__zlib_flush())\n#define stbiw__zlib_huffa(b,c)  stbiw__zlib_add(stbiw__zlib_bitrev(b,c),c)\n// default huffman tables\n#define stbiw__zlib_huff1(n)  stbiw__zlib_huffa(0x30 + (n), 8)\n#define stbiw__zlib_huff2(n)  stbiw__zlib_huffa(0x190 + (n)-144, 9)\n#define stbiw__zlib_huff3(n)  stbiw__zlib_huffa(0 + (n)-256,7)\n#define stbiw__zlib_huff4(n)  stbiw__zlib_huffa(0xc0 + (n)-280,8)\n#define stbiw__zlib_huff(n)  ((n) <= 143 ? stbiw__zlib_huff1(n) : (n) <= 255 ? stbiw__zlib_huff2(n) : (n) <= 279 ? stbiw__zlib_huff3(n) : stbiw__zlib_huff4(n))\n#define stbiw__zlib_huffb(n) ((n) <= 143 ? stbiw__zlib_huff1(n) : stbiw__zlib_huff2(n))\n\n#define stbiw__ZHASH   16384\n\n#endif // STBIW_ZLIB_COMPRESS\n\nSTBIWDEF unsigned char * stbi_zlib_compress(unsigned char *data, int data_len, int *out_len, int quality)\n{\n#ifdef STBIW_ZLIB_COMPRESS\n   // user provided a zlib compress implementation, use that\n   return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality);\n#else // use builtin\n   static unsigned short lengthc[] = { 3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258, 259 };\n   static unsigned char  lengtheb[]= { 0,0,0,0,0,0,0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4,  4,  5,  5,  5,  5,  0 };\n   static unsigned short distc[]   = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 32768 };\n   static unsigned char  disteb[]  = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 };\n   unsigned int bitbuf=0;\n   int i,j, bitcount=0;\n   unsigned char *out = NULL;\n   unsigned char ***hash_table = (unsigned char***) STBIW_MALLOC(stbiw__ZHASH * sizeof(unsigned char**));\n   if (hash_table == NULL)\n      return NULL;\n   if (quality < 5) quality = 5;\n\n   stbiw__sbpush(out, 0x78);   // DEFLATE 32K window\n   stbiw__sbpush(out, 0x5e);   // FLEVEL = 1\n   stbiw__zlib_add(1,1);  // BFINAL = 1\n   stbiw__zlib_add(1,2);  // BTYPE = 1 -- fixed huffman\n\n   for (i=0; i < stbiw__ZHASH; ++i)\n      hash_table[i] = NULL;\n\n   i=0;\n   while (i < data_len-3) {\n      // hash next 3 bytes of data to be compressed\n      int h = stbiw__zhash(data+i)&(stbiw__ZHASH-1), best=3;\n      unsigned char *bestloc = 0;\n      unsigned char **hlist = hash_table[h];\n      int n = stbiw__sbcount(hlist);\n      for (j=0; j < n; ++j) {\n         if (hlist[j]-data > i-32768) { // if entry lies within window\n            int d = stbiw__zlib_countm(hlist[j], data+i, data_len-i);\n            if (d >= best) { best=d; bestloc=hlist[j]; }\n         }\n      }\n      // when hash table entry is too long, delete half the entries\n      if (hash_table[h] && stbiw__sbn(hash_table[h]) == 2*quality) {\n         STBIW_MEMMOVE(hash_table[h], hash_table[h]+quality, sizeof(hash_table[h][0])*quality);\n         stbiw__sbn(hash_table[h]) = quality;\n      }\n      stbiw__sbpush(hash_table[h],data+i);\n\n      if (bestloc) {\n         // \"lazy matching\" - check match at *next* byte, and if it's better, do cur byte as literal\n         h = stbiw__zhash(data+i+1)&(stbiw__ZHASH-1);\n         hlist = hash_table[h];\n         n = stbiw__sbcount(hlist);\n         for (j=0; j < n; ++j) {\n            if (hlist[j]-data > i-32767) {\n               int e = stbiw__zlib_countm(hlist[j], data+i+1, data_len-i-1);\n               if (e > best) { // if next match is better, bail on current match\n                  bestloc = NULL;\n                  break;\n               }\n            }\n         }\n      }\n\n      if (bestloc) {\n         int d = (int) (data+i - bestloc); // distance back\n         STBIW_ASSERT(d <= 32767 && best <= 258);\n         for (j=0; best > lengthc[j+1]-1; ++j);\n         stbiw__zlib_huff(j+257);\n         if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]);\n         for (j=0; d > distc[j+1]-1; ++j);\n         stbiw__zlib_add(stbiw__zlib_bitrev(j,5),5);\n         if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]);\n         i += best;\n      } else {\n         stbiw__zlib_huffb(data[i]);\n         ++i;\n      }\n   }\n   // write out final bytes\n   for (;i < data_len; ++i)\n      stbiw__zlib_huffb(data[i]);\n   stbiw__zlib_huff(256); // end of block\n   // pad with 0 bits to byte boundary\n   while (bitcount)\n      stbiw__zlib_add(0,1);\n\n   for (i=0; i < stbiw__ZHASH; ++i)\n      (void) stbiw__sbfree(hash_table[i]);\n   STBIW_FREE(hash_table);\n\n   {\n      // compute adler32 on input\n      unsigned int s1=1, s2=0;\n      int blocklen = (int) (data_len % 5552);\n      j=0;\n      while (j < data_len) {\n         for (i=0; i < blocklen; ++i) { s1 += data[j+i]; s2 += s1; }\n         s1 %= 65521; s2 %= 65521;\n         j += blocklen;\n         blocklen = 5552;\n      }\n      stbiw__sbpush(out, STBIW_UCHAR(s2 >> 8));\n      stbiw__sbpush(out, STBIW_UCHAR(s2));\n      stbiw__sbpush(out, STBIW_UCHAR(s1 >> 8));\n      stbiw__sbpush(out, STBIW_UCHAR(s1));\n   }\n   *out_len = stbiw__sbn(out);\n   // make returned pointer freeable\n   STBIW_MEMMOVE(stbiw__sbraw(out), out, *out_len);\n   return (unsigned char *) stbiw__sbraw(out);\n#endif // STBIW_ZLIB_COMPRESS\n}\n\nstatic unsigned int stbiw__crc32(unsigned char *buffer, int len)\n{\n#ifdef STBIW_CRC32\n    return STBIW_CRC32(buffer, len);\n#else\n   static unsigned int crc_table[256] =\n   {\n      0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,\n      0x0eDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,\n      0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,\n      0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,\n      0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,\n      0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,\n      0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,\n      0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,\n      0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,\n      0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,\n      0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,\n      0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,\n      0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,\n      0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,\n      0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,\n      0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,\n      0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,\n      0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,\n      0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,\n      0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,\n      0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,\n      0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,\n      0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,\n      0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,\n      0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,\n      0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,\n      0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,\n      0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,\n      0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,\n      0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,\n      0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,\n      0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D\n   };\n\n   unsigned int crc = ~0u;\n   int i;\n   for (i=0; i < len; ++i)\n      crc = (crc >> 8) ^ crc_table[buffer[i] ^ (crc & 0xff)];\n   return ~crc;\n#endif\n}\n\n#define stbiw__wpng4(o,a,b,c,d) ((o)[0]=STBIW_UCHAR(a),(o)[1]=STBIW_UCHAR(b),(o)[2]=STBIW_UCHAR(c),(o)[3]=STBIW_UCHAR(d),(o)+=4)\n#define stbiw__wp32(data,v) stbiw__wpng4(data, (v)>>24,(v)>>16,(v)>>8,(v));\n#define stbiw__wptag(data,s) stbiw__wpng4(data, s[0],s[1],s[2],s[3])\n\nstatic void stbiw__wpcrc(unsigned char **data, int len)\n{\n   unsigned int crc = stbiw__crc32(*data - len - 4, len+4);\n   stbiw__wp32(*data, crc);\n}\n\nstatic unsigned char stbiw__paeth(int a, int b, int c)\n{\n   int p = a + b - c, pa = abs(p-a), pb = abs(p-b), pc = abs(p-c);\n   if (pa <= pb && pa <= pc) return STBIW_UCHAR(a);\n   if (pb <= pc) return STBIW_UCHAR(b);\n   return STBIW_UCHAR(c);\n}\n\n// @OPTIMIZE: provide an option that always forces left-predict or paeth predict\nstatic void stbiw__encode_png_line(unsigned char *pixels, int stride_bytes, int width, int height, int y, int n, int filter_type, signed char *line_buffer)\n{\n   static int mapping[] = { 0,1,2,3,4 };\n   static int firstmap[] = { 0,1,0,5,6 };\n   int *mymap = (y != 0) ? mapping : firstmap;\n   int i;\n   int type = mymap[filter_type];\n   unsigned char *z = pixels + stride_bytes * (stbi__flip_vertically_on_write ? height-1-y : y);\n   int signed_stride = stbi__flip_vertically_on_write ? -stride_bytes : stride_bytes;\n\n   if (type==0) {\n      memcpy(line_buffer, z, width*n);\n      return;\n   }\n\n   // first loop isn't optimized since it's just one pixel\n   for (i = 0; i < n; ++i) {\n      switch (type) {\n         case 1: line_buffer[i] = z[i]; break;\n         case 2: line_buffer[i] = z[i] - z[i-signed_stride]; break;\n         case 3: line_buffer[i] = z[i] - (z[i-signed_stride]>>1); break;\n         case 4: line_buffer[i] = (signed char) (z[i] - stbiw__paeth(0,z[i-signed_stride],0)); break;\n         case 5: line_buffer[i] = z[i]; break;\n         case 6: line_buffer[i] = z[i]; break;\n      }\n   }\n   switch (type) {\n      case 1: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-n]; break;\n      case 2: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - z[i-signed_stride]; break;\n      case 3: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - ((z[i-n] + z[i-signed_stride])>>1); break;\n      case 4: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], z[i-signed_stride], z[i-signed_stride-n]); break;\n      case 5: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - (z[i-n]>>1); break;\n      case 6: for (i=n; i < width*n; ++i) line_buffer[i] = z[i] - stbiw__paeth(z[i-n], 0,0); break;\n   }\n}\n\nSTBIWDEF unsigned char *stbi_write_png_to_mem(const unsigned char *pixels, int stride_bytes, int x, int y, int n, int *out_len)\n{\n   int force_filter = stbi_write_force_png_filter;\n   int ctype[5] = { -1, 0, 4, 2, 6 };\n   unsigned char sig[8] = { 137,80,78,71,13,10,26,10 };\n   unsigned char *out,*o, *filt, *zlib;\n   signed char *line_buffer;\n   int j,zlen;\n\n   if (stride_bytes == 0)\n      stride_bytes = x * n;\n\n   if (force_filter >= 5) {\n      force_filter = -1;\n   }\n\n   filt = (unsigned char *) STBIW_MALLOC((x*n+1) * y); if (!filt) return 0;\n   line_buffer = (signed char *) STBIW_MALLOC(x * n); if (!line_buffer) { STBIW_FREE(filt); return 0; }\n   for (j=0; j < y; ++j) {\n      int filter_type;\n      if (force_filter > -1) {\n         filter_type = force_filter;\n         stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, force_filter, line_buffer);\n      } else { // Estimate the best filter by running through all of them:\n         int best_filter = 0, best_filter_val = 0x7fffffff, est, i;\n         for (filter_type = 0; filter_type < 5; filter_type++) {\n            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, filter_type, line_buffer);\n\n            // Estimate the entropy of the line using this filter; the less, the better.\n            est = 0;\n            for (i = 0; i < x*n; ++i) {\n               est += abs((signed char) line_buffer[i]);\n            }\n            if (est < best_filter_val) {\n               best_filter_val = est;\n               best_filter = filter_type;\n            }\n         }\n         if (filter_type != best_filter) {  // If the last iteration already got us the best filter, don't redo it\n            stbiw__encode_png_line((unsigned char*)(pixels), stride_bytes, x, y, j, n, best_filter, line_buffer);\n            filter_type = best_filter;\n         }\n      }\n      // when we get here, filter_type contains the filter type, and line_buffer contains the data\n      filt[j*(x*n+1)] = (unsigned char) filter_type;\n      STBIW_MEMMOVE(filt+j*(x*n+1)+1, line_buffer, x*n);\n   }\n   STBIW_FREE(line_buffer);\n   zlib = stbi_zlib_compress(filt, y*( x*n+1), &zlen, stbi_write_png_compression_level);\n   STBIW_FREE(filt);\n   if (!zlib) return 0;\n\n   // each tag requires 12 bytes of overhead\n   out = (unsigned char *) STBIW_MALLOC(8 + 12+13 + 12+zlen + 12);\n   if (!out) return 0;\n   *out_len = 8 + 12+13 + 12+zlen + 12;\n\n   o=out;\n   STBIW_MEMMOVE(o,sig,8); o+= 8;\n   stbiw__wp32(o, 13); // header length\n   stbiw__wptag(o, \"IHDR\");\n   stbiw__wp32(o, x);\n   stbiw__wp32(o, y);\n   *o++ = 8;\n   *o++ = STBIW_UCHAR(ctype[n]);\n   *o++ = 0;\n   *o++ = 0;\n   *o++ = 0;\n   stbiw__wpcrc(&o,13);\n\n   stbiw__wp32(o, zlen);\n   stbiw__wptag(o, \"IDAT\");\n   STBIW_MEMMOVE(o, zlib, zlen);\n   o += zlen;\n   STBIW_FREE(zlib);\n   stbiw__wpcrc(&o, zlen);\n\n   stbiw__wp32(o,0);\n   stbiw__wptag(o, \"IEND\");\n   stbiw__wpcrc(&o,0);\n\n   STBIW_ASSERT(o == out + *out_len);\n\n   return out;\n}\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)\n{\n   FILE *f;\n   int len;\n   unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);\n   if (png == NULL) return 0;\n\n   f = stbiw__fopen(filename, \"wb\");\n   if (!f) { STBIW_FREE(png); return 0; }\n   fwrite(png, 1, len, f);\n   fclose(f);\n   STBIW_FREE(png);\n   return 1;\n}\n#endif\n\nSTBIWDEF int stbi_write_png_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int stride_bytes)\n{\n   int len;\n   unsigned char *png = stbi_write_png_to_mem((const unsigned char *) data, stride_bytes, x, y, comp, &len);\n   if (png == NULL) return 0;\n   func(context, png, len);\n   STBIW_FREE(png);\n   return 1;\n}\n\n\n/* ***************************************************************************\n *\n * JPEG writer\n *\n * This is based on Jon Olick's jo_jpeg.cpp:\n * public domain Simple, Minimalistic JPEG writer - http://www.jonolick.com/code.html\n */\n\nstatic const unsigned char stbiw__jpg_ZigZag[] = { 0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,\n      24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63 };\n\nstatic void stbiw__jpg_writeBits(stbi__write_context *s, int *bitBufP, int *bitCntP, const unsigned short *bs) {\n   int bitBuf = *bitBufP, bitCnt = *bitCntP;\n   bitCnt += bs[1];\n   bitBuf |= bs[0] << (24 - bitCnt);\n   while(bitCnt >= 8) {\n      unsigned char c = (bitBuf >> 16) & 255;\n      stbiw__putc(s, c);\n      if(c == 255) {\n         stbiw__putc(s, 0);\n      }\n      bitBuf <<= 8;\n      bitCnt -= 8;\n   }\n   *bitBufP = bitBuf;\n   *bitCntP = bitCnt;\n}\n\nstatic void stbiw__jpg_DCT(float *d0p, float *d1p, float *d2p, float *d3p, float *d4p, float *d5p, float *d6p, float *d7p) {\n   float d0 = *d0p, d1 = *d1p, d2 = *d2p, d3 = *d3p, d4 = *d4p, d5 = *d5p, d6 = *d6p, d7 = *d7p;\n   float z1, z2, z3, z4, z5, z11, z13;\n\n   float tmp0 = d0 + d7;\n   float tmp7 = d0 - d7;\n   float tmp1 = d1 + d6;\n   float tmp6 = d1 - d6;\n   float tmp2 = d2 + d5;\n   float tmp5 = d2 - d5;\n   float tmp3 = d3 + d4;\n   float tmp4 = d3 - d4;\n\n   // Even part\n   float tmp10 = tmp0 + tmp3;   // phase 2\n   float tmp13 = tmp0 - tmp3;\n   float tmp11 = tmp1 + tmp2;\n   float tmp12 = tmp1 - tmp2;\n\n   d0 = tmp10 + tmp11;       // phase 3\n   d4 = tmp10 - tmp11;\n\n   z1 = (tmp12 + tmp13) * 0.707106781f; // c4\n   d2 = tmp13 + z1;       // phase 5\n   d6 = tmp13 - z1;\n\n   // Odd part\n   tmp10 = tmp4 + tmp5;       // phase 2\n   tmp11 = tmp5 + tmp6;\n   tmp12 = tmp6 + tmp7;\n\n   // The rotator is modified from fig 4-8 to avoid extra negations.\n   z5 = (tmp10 - tmp12) * 0.382683433f; // c6\n   z2 = tmp10 * 0.541196100f + z5; // c2-c6\n   z4 = tmp12 * 1.306562965f + z5; // c2+c6\n   z3 = tmp11 * 0.707106781f; // c4\n\n   z11 = tmp7 + z3;      // phase 5\n   z13 = tmp7 - z3;\n\n   *d5p = z13 + z2;         // phase 6\n   *d3p = z13 - z2;\n   *d1p = z11 + z4;\n   *d7p = z11 - z4;\n\n   *d0p = d0;  *d2p = d2;  *d4p = d4;  *d6p = d6;\n}\n\nstatic void stbiw__jpg_calcBits(int val, unsigned short bits[2]) {\n   int tmp1 = val < 0 ? -val : val;\n   val = val < 0 ? val-1 : val;\n   bits[1] = 1;\n   while(tmp1 >>= 1) {\n      ++bits[1];\n   }\n   bits[0] = val & ((1<<bits[1])-1);\n}\n\nstatic int stbiw__jpg_processDU(stbi__write_context *s, int *bitBuf, int *bitCnt, float *CDU, int du_stride, float *fdtbl, int DC, const unsigned short HTDC[256][2], const unsigned short HTAC[256][2]) {\n   const unsigned short EOB[2] = { HTAC[0x00][0], HTAC[0x00][1] };\n   const unsigned short M16zeroes[2] = { HTAC[0xF0][0], HTAC[0xF0][1] };\n   int dataOff, i, j, n, diff, end0pos, x, y;\n   int DU[64];\n\n   // DCT rows\n   for(dataOff=0, n=du_stride*8; dataOff<n; dataOff+=du_stride) {\n      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+1], &CDU[dataOff+2], &CDU[dataOff+3], &CDU[dataOff+4], &CDU[dataOff+5], &CDU[dataOff+6], &CDU[dataOff+7]);\n   }\n   // DCT columns\n   for(dataOff=0; dataOff<8; ++dataOff) {\n      stbiw__jpg_DCT(&CDU[dataOff], &CDU[dataOff+du_stride], &CDU[dataOff+du_stride*2], &CDU[dataOff+du_stride*3], &CDU[dataOff+du_stride*4],\n                     &CDU[dataOff+du_stride*5], &CDU[dataOff+du_stride*6], &CDU[dataOff+du_stride*7]);\n   }\n   // Quantize/descale/zigzag the coefficients\n   for(y = 0, j=0; y < 8; ++y) {\n      for(x = 0; x < 8; ++x,++j) {\n         float v;\n         i = y*du_stride+x;\n         v = CDU[i]*fdtbl[j];\n         // DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? ceilf(v - 0.5f) : floorf(v + 0.5f));\n         // ceilf() and floorf() are C99, not C89, but I /think/ they're not needed here anyway?\n         DU[stbiw__jpg_ZigZag[j]] = (int)(v < 0 ? v - 0.5f : v + 0.5f);\n      }\n   }\n\n   // Encode DC\n   diff = DU[0] - DC;\n   if (diff == 0) {\n      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[0]);\n   } else {\n      unsigned short bits[2];\n      stbiw__jpg_calcBits(diff, bits);\n      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTDC[bits[1]]);\n      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);\n   }\n   // Encode ACs\n   end0pos = 63;\n   for(; (end0pos>0)&&(DU[end0pos]==0); --end0pos) {\n   }\n   // end0pos = first element in reverse order !=0\n   if(end0pos == 0) {\n      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);\n      return DU[0];\n   }\n   for(i = 1; i <= end0pos; ++i) {\n      int startpos = i;\n      int nrzeroes;\n      unsigned short bits[2];\n      for (; DU[i]==0 && i<=end0pos; ++i) {\n      }\n      nrzeroes = i-startpos;\n      if ( nrzeroes >= 16 ) {\n         int lng = nrzeroes>>4;\n         int nrmarker;\n         for (nrmarker=1; nrmarker <= lng; ++nrmarker)\n            stbiw__jpg_writeBits(s, bitBuf, bitCnt, M16zeroes);\n         nrzeroes &= 15;\n      }\n      stbiw__jpg_calcBits(DU[i], bits);\n      stbiw__jpg_writeBits(s, bitBuf, bitCnt, HTAC[(nrzeroes<<4)+bits[1]]);\n      stbiw__jpg_writeBits(s, bitBuf, bitCnt, bits);\n   }\n   if(end0pos != 63) {\n      stbiw__jpg_writeBits(s, bitBuf, bitCnt, EOB);\n   }\n   return DU[0];\n}\n\nstatic int stbi_write_jpg_core(stbi__write_context *s, int width, int height, int comp, const void* data, int quality) {\n   // Constants that don't pollute global namespace\n   static const unsigned char std_dc_luminance_nrcodes[] = {0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0};\n   static const unsigned char std_dc_luminance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};\n   static const unsigned char std_ac_luminance_nrcodes[] = {0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d};\n   static const unsigned char std_ac_luminance_values[] = {\n      0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12,0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07,0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08,\n      0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0,0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16,0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28,\n      0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59,\n      0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89,\n      0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6,\n      0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2,\n      0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa\n   };\n   static const unsigned char std_dc_chrominance_nrcodes[] = {0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0};\n   static const unsigned char std_dc_chrominance_values[] = {0,1,2,3,4,5,6,7,8,9,10,11};\n   static const unsigned char std_ac_chrominance_nrcodes[] = {0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77};\n   static const unsigned char std_ac_chrominance_values[] = {\n      0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21,0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71,0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91,\n      0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0,0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34,0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26,\n      0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38,0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58,\n      0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87,\n      0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,\n      0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,\n      0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa\n   };\n   // Huffman tables\n   static const unsigned short YDC_HT[256][2] = { {0,2},{2,3},{3,3},{4,3},{5,3},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9}};\n   static const unsigned short UVDC_HT[256][2] = { {0,2},{1,2},{2,2},{6,3},{14,4},{30,5},{62,6},{126,7},{254,8},{510,9},{1022,10},{2046,11}};\n   static const unsigned short YAC_HT[256][2] = {\n      {10,4},{0,2},{1,2},{4,3},{11,4},{26,5},{120,7},{248,8},{1014,10},{65410,16},{65411,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {12,4},{27,5},{121,7},{502,9},{2038,11},{65412,16},{65413,16},{65414,16},{65415,16},{65416,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {28,5},{249,8},{1015,10},{4084,12},{65417,16},{65418,16},{65419,16},{65420,16},{65421,16},{65422,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {58,6},{503,9},{4085,12},{65423,16},{65424,16},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {59,6},{1016,10},{65430,16},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {122,7},{2039,11},{65438,16},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {123,7},{4086,12},{65446,16},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {250,8},{4087,12},{65454,16},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {504,9},{32704,15},{65462,16},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {505,9},{65470,16},{65471,16},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {506,9},{65479,16},{65480,16},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {1017,10},{65488,16},{65489,16},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {1018,10},{65497,16},{65498,16},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {2040,11},{65506,16},{65507,16},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {65515,16},{65516,16},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {2041,11},{65525,16},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}\n   };\n   static const unsigned short UVAC_HT[256][2] = {\n      {0,2},{1,2},{4,3},{10,4},{24,5},{25,5},{56,6},{120,7},{500,9},{1014,10},{4084,12},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {11,4},{57,6},{246,8},{501,9},{2038,11},{4085,12},{65416,16},{65417,16},{65418,16},{65419,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {26,5},{247,8},{1015,10},{4086,12},{32706,15},{65420,16},{65421,16},{65422,16},{65423,16},{65424,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {27,5},{248,8},{1016,10},{4087,12},{65425,16},{65426,16},{65427,16},{65428,16},{65429,16},{65430,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {58,6},{502,9},{65431,16},{65432,16},{65433,16},{65434,16},{65435,16},{65436,16},{65437,16},{65438,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {59,6},{1017,10},{65439,16},{65440,16},{65441,16},{65442,16},{65443,16},{65444,16},{65445,16},{65446,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {121,7},{2039,11},{65447,16},{65448,16},{65449,16},{65450,16},{65451,16},{65452,16},{65453,16},{65454,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {122,7},{2040,11},{65455,16},{65456,16},{65457,16},{65458,16},{65459,16},{65460,16},{65461,16},{65462,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {249,8},{65463,16},{65464,16},{65465,16},{65466,16},{65467,16},{65468,16},{65469,16},{65470,16},{65471,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {503,9},{65472,16},{65473,16},{65474,16},{65475,16},{65476,16},{65477,16},{65478,16},{65479,16},{65480,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {504,9},{65481,16},{65482,16},{65483,16},{65484,16},{65485,16},{65486,16},{65487,16},{65488,16},{65489,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {505,9},{65490,16},{65491,16},{65492,16},{65493,16},{65494,16},{65495,16},{65496,16},{65497,16},{65498,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {506,9},{65499,16},{65500,16},{65501,16},{65502,16},{65503,16},{65504,16},{65505,16},{65506,16},{65507,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {2041,11},{65508,16},{65509,16},{65510,16},{65511,16},{65512,16},{65513,16},{65514,16},{65515,16},{65516,16},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {16352,14},{65517,16},{65518,16},{65519,16},{65520,16},{65521,16},{65522,16},{65523,16},{65524,16},{65525,16},{0,0},{0,0},{0,0},{0,0},{0,0},\n      {1018,10},{32707,15},{65526,16},{65527,16},{65528,16},{65529,16},{65530,16},{65531,16},{65532,16},{65533,16},{65534,16},{0,0},{0,0},{0,0},{0,0},{0,0}\n   };\n   static const int YQT[] = {16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,\n                             37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99};\n   static const int UVQT[] = {17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,\n                              99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99};\n   static const float aasf[] = { 1.0f * 2.828427125f, 1.387039845f * 2.828427125f, 1.306562965f * 2.828427125f, 1.175875602f * 2.828427125f,\n                                 1.0f * 2.828427125f, 0.785694958f * 2.828427125f, 0.541196100f * 2.828427125f, 0.275899379f * 2.828427125f };\n\n   int row, col, i, k, subsample;\n   float fdtbl_Y[64], fdtbl_UV[64];\n   unsigned char YTable[64], UVTable[64];\n\n   if(!data || !width || !height || comp > 4 || comp < 1) {\n      return 0;\n   }\n\n   quality = quality ? quality : 90;\n   subsample = quality <= 90 ? 1 : 0;\n   quality = quality < 1 ? 1 : quality > 100 ? 100 : quality;\n   quality = quality < 50 ? 5000 / quality : 200 - quality * 2;\n\n   for(i = 0; i < 64; ++i) {\n      int uvti, yti = (YQT[i]*quality+50)/100;\n      YTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (yti < 1 ? 1 : yti > 255 ? 255 : yti);\n      uvti = (UVQT[i]*quality+50)/100;\n      UVTable[stbiw__jpg_ZigZag[i]] = (unsigned char) (uvti < 1 ? 1 : uvti > 255 ? 255 : uvti);\n   }\n\n   for(row = 0, k = 0; row < 8; ++row) {\n      for(col = 0; col < 8; ++col, ++k) {\n         fdtbl_Y[k]  = 1 / (YTable [stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);\n         fdtbl_UV[k] = 1 / (UVTable[stbiw__jpg_ZigZag[k]] * aasf[row] * aasf[col]);\n      }\n   }\n\n   // Write Headers\n   {\n      static const unsigned char head0[] = { 0xFF,0xD8,0xFF,0xE0,0,0x10,'J','F','I','F',0,1,1,0,0,1,0,1,0,0,0xFF,0xDB,0,0x84,0 };\n      static const unsigned char head2[] = { 0xFF,0xDA,0,0xC,3,1,0,2,0x11,3,0x11,0,0x3F,0 };\n      const unsigned char head1[] = { 0xFF,0xC0,0,0x11,8,(unsigned char)(height>>8),STBIW_UCHAR(height),(unsigned char)(width>>8),STBIW_UCHAR(width),\n                                      3,1,(unsigned char)(subsample?0x22:0x11),0,2,0x11,1,3,0x11,1,0xFF,0xC4,0x01,0xA2,0 };\n      s->func(s->context, (void*)head0, sizeof(head0));\n      s->func(s->context, (void*)YTable, sizeof(YTable));\n      stbiw__putc(s, 1);\n      s->func(s->context, UVTable, sizeof(UVTable));\n      s->func(s->context, (void*)head1, sizeof(head1));\n      s->func(s->context, (void*)(std_dc_luminance_nrcodes+1), sizeof(std_dc_luminance_nrcodes)-1);\n      s->func(s->context, (void*)std_dc_luminance_values, sizeof(std_dc_luminance_values));\n      stbiw__putc(s, 0x10); // HTYACinfo\n      s->func(s->context, (void*)(std_ac_luminance_nrcodes+1), sizeof(std_ac_luminance_nrcodes)-1);\n      s->func(s->context, (void*)std_ac_luminance_values, sizeof(std_ac_luminance_values));\n      stbiw__putc(s, 1); // HTUDCinfo\n      s->func(s->context, (void*)(std_dc_chrominance_nrcodes+1), sizeof(std_dc_chrominance_nrcodes)-1);\n      s->func(s->context, (void*)std_dc_chrominance_values, sizeof(std_dc_chrominance_values));\n      stbiw__putc(s, 0x11); // HTUACinfo\n      s->func(s->context, (void*)(std_ac_chrominance_nrcodes+1), sizeof(std_ac_chrominance_nrcodes)-1);\n      s->func(s->context, (void*)std_ac_chrominance_values, sizeof(std_ac_chrominance_values));\n      s->func(s->context, (void*)head2, sizeof(head2));\n   }\n\n   // Encode 8x8 macroblocks\n   {\n      static const unsigned short fillBits[] = {0x7F, 7};\n      int DCY=0, DCU=0, DCV=0;\n      int bitBuf=0, bitCnt=0;\n      // comp == 2 is grey+alpha (alpha is ignored)\n      int ofsG = comp > 2 ? 1 : 0, ofsB = comp > 2 ? 2 : 0;\n      const unsigned char *dataR = (const unsigned char *)data;\n      const unsigned char *dataG = dataR + ofsG;\n      const unsigned char *dataB = dataR + ofsB;\n      int x, y, pos;\n      if(subsample) {\n         for(y = 0; y < height; y += 16) {\n            for(x = 0; x < width; x += 16) {\n               float Y[256], U[256], V[256];\n               for(row = y, pos = 0; row < y+16; ++row) {\n                  // row >= height => use last input row\n                  int clamped_row = (row < height) ? row : height - 1;\n                  int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;\n                  for(col = x; col < x+16; ++col, ++pos) {\n                     // if col >= width => use pixel from last input column\n                     int p = base_p + ((col < width) ? col : (width-1))*comp;\n                     float r = dataR[p], g = dataG[p], b = dataB[p];\n                     Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;\n                     U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;\n                     V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;\n                  }\n               }\n               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+0,   16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+8,   16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+128, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y+136, 16, fdtbl_Y, DCY, YDC_HT, YAC_HT);\n\n               // subsample U,V\n               {\n                  float subU[64], subV[64];\n                  int yy, xx;\n                  for(yy = 0, pos = 0; yy < 8; ++yy) {\n                     for(xx = 0; xx < 8; ++xx, ++pos) {\n                        int j = yy*32+xx*2;\n                        subU[pos] = (U[j+0] + U[j+1] + U[j+16] + U[j+17]) * 0.25f;\n                        subV[pos] = (V[j+0] + V[j+1] + V[j+16] + V[j+17]) * 0.25f;\n                     }\n                  }\n                  DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subU, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);\n                  DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, subV, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);\n               }\n            }\n         }\n      } else {\n         for(y = 0; y < height; y += 8) {\n            for(x = 0; x < width; x += 8) {\n               float Y[64], U[64], V[64];\n               for(row = y, pos = 0; row < y+8; ++row) {\n                  // row >= height => use last input row\n                  int clamped_row = (row < height) ? row : height - 1;\n                  int base_p = (stbi__flip_vertically_on_write ? (height-1-clamped_row) : clamped_row)*width*comp;\n                  for(col = x; col < x+8; ++col, ++pos) {\n                     // if col >= width => use pixel from last input column\n                     int p = base_p + ((col < width) ? col : (width-1))*comp;\n                     float r = dataR[p], g = dataG[p], b = dataB[p];\n                     Y[pos]= +0.29900f*r + 0.58700f*g + 0.11400f*b - 128;\n                     U[pos]= -0.16874f*r - 0.33126f*g + 0.50000f*b;\n                     V[pos]= +0.50000f*r - 0.41869f*g - 0.08131f*b;\n                  }\n               }\n\n               DCY = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, Y, 8, fdtbl_Y,  DCY, YDC_HT, YAC_HT);\n               DCU = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, U, 8, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);\n               DCV = stbiw__jpg_processDU(s, &bitBuf, &bitCnt, V, 8, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);\n            }\n         }\n      }\n\n      // Do the bit alignment of the EOI marker\n      stbiw__jpg_writeBits(s, &bitBuf, &bitCnt, fillBits);\n   }\n\n   // EOI\n   stbiw__putc(s, 0xFF);\n   stbiw__putc(s, 0xD9);\n\n   return 1;\n}\n\nSTBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality)\n{\n   stbi__write_context s = { 0 };\n   stbi__start_write_callbacks(&s, func, context);\n   return stbi_write_jpg_core(&s, x, y, comp, (void *) data, quality);\n}\n\n\n#ifndef STBI_WRITE_NO_STDIO\nSTBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality)\n{\n   stbi__write_context s = { 0 };\n   if (stbi__start_write_file(&s,filename)) {\n      int r = stbi_write_jpg_core(&s, x, y, comp, data, quality);\n      stbi__end_write_file(&s);\n      return r;\n   } else\n      return 0;\n}\n#endif\n\n#endif // STB_IMAGE_WRITE_IMPLEMENTATION\n\n/* Revision history\n      1.14  (2020-02-02) updated JPEG writer to downsample chroma channels\n      1.13\n      1.12\n      1.11  (2019-08-11)\n\n      1.10  (2019-02-07)\n             support utf8 filenames in Windows; fix warnings and platform ifdefs\n      1.09  (2018-02-11)\n             fix typo in zlib quality API, improve STB_I_W_STATIC in C++\n      1.08  (2018-01-29)\n             add stbi__flip_vertically_on_write, external zlib, zlib quality, choose PNG filter\n      1.07  (2017-07-24)\n             doc fix\n      1.06 (2017-07-23)\n             writing JPEG (using Jon Olick's code)\n      1.05   ???\n      1.04 (2017-03-03)\n             monochrome BMP expansion\n      1.03   ???\n      1.02 (2016-04-02)\n             avoid allocating large structures on the stack\n      1.01 (2016-01-16)\n             STBIW_REALLOC_SIZED: support allocators with no realloc support\n             avoid race-condition in crc initialization\n             minor compile issues\n      1.00 (2015-09-14)\n             installable file IO function\n      0.99 (2015-09-13)\n             warning fixes; TGA rle support\n      0.98 (2015-04-08)\n             added STBIW_MALLOC, STBIW_ASSERT etc\n      0.97 (2015-01-18)\n             fixed HDR asserts, rewrote HDR rle logic\n      0.96 (2015-01-17)\n             add HDR output\n             fix monochrome BMP\n      0.95 (2014-08-17)\n\t\t       add monochrome TGA output\n      0.94 (2014-05-31)\n             rename private functions to avoid conflicts with stb_image.h\n      0.93 (2014-05-27)\n             warning fixes\n      0.92 (2010-08-01)\n             casts to unsigned char to fix warnings\n      0.91 (2010-07-17)\n             first public release\n      0.90   first internal release\n*/\n\n/*\n------------------------------------------------------------------------------\nThis software is available under 2 licenses -- choose whichever you prefer.\n------------------------------------------------------------------------------\nALTERNATIVE A - MIT License\nCopyright (c) 2017 Sean Barrett\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n------------------------------------------------------------------------------\nALTERNATIVE B - Public Domain (www.unlicense.org)\nThis is free and unencumbered software released into the public domain.\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute this\nsoftware, either in source code form or as a compiled binary, for any purpose,\ncommercial or non-commercial, and by any means.\nIn jurisdictions that recognize copyright laws, the author or authors of this\nsoftware dedicate any and all copyright interest in the software to the public\ndomain. We make this dedication for the benefit of the public at large and to\nthe detriment of our heirs and successors. We intend this dedication to be an\novert act of relinquishment in perpetuity of all present and future rights to\nthis software under copyright law.\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\nACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n------------------------------------------------------------------------------\n*/\n"
  },
  {
    "path": "CodeOfConduct.md",
    "content": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, we as\ncontributors and maintainers pledge to making participation in our project and\nour community a harassment-free experience for everyone, regardless of age, body\nsize, disability, ethnicity, gender identity and expression, level of experience,\neducation, socio-economic status, nationality, personal appearance, race,\nreligion, or sexual identity and orientation.\n\n## Our Standards\n\nExamples of behavior that contributes to creating a positive environment\ninclude:\n\n* Using welcoming and inclusive language\n* Being respectful of differing viewpoints and experiences\n* Gracefully accepting constructive criticism\n* Focusing on what is best for the community\n* Showing empathy towards other community members\n\nExamples of unacceptable behavior by participants include:\n\n* The use of sexualized language or imagery and unwelcome sexual attention or\n  advances\n* Trolling, insulting/derogatory comments, and personal or political attacks\n* Public or private harassment\n* Publishing others' private information, such as a physical or electronic\n  address, without explicit permission\n* Other conduct which could reasonably be considered inappropriate in a\n  professional setting\n\n## Our Responsibilities\n\nProject maintainers are responsible for clarifying the standards of acceptable\nbehavior and are expected to take appropriate and fair corrective action in\nresponse to any instances of unacceptable behavior.\n\nProject maintainers have the right and responsibility to remove, edit, or\nreject comments, commits, code, wiki edits, issues, and other contributions\nthat are not aligned to this Code of Conduct, or to ban temporarily or\npermanently any contributor for other behaviors that they deem inappropriate,\nthreatening, offensive, or harmful.\n\n## Scope\n\nThis Code of Conduct applies both within project spaces and in public spaces\nwhen an individual is representing the project or its community. Examples of\nrepresenting a project or community include using an official project e-mail\naddress, posting via an official social media account, or acting as an appointed\nrepresentative at an online or offline event. Representation of a project may be\nfurther defined and clarified by project maintainers.\n\n## Enforcement\n\nInstances of abusive, harassing, or otherwise unacceptable behavior may be\nreported by contacting the project team at dag.agren@wolt.com. All\ncomplaints will be reviewed and investigated and will result in a response that\nis deemed necessary and appropriate to the circumstances. The project team is\nobligated to maintain confidentiality with regard to the reporter of an incident.\nFurther details of specific enforcement policies may be posted separately.\n\nProject maintainers who do not follow or enforce the Code of Conduct in good\nfaith may face temporary or permanent repercussions as determined by other\nmembers of the project's leadership.\n\n## Attribution\n\nThis Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,\navailable at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html\n\n[homepage]: https://www.contributor-covenant.org\n\n"
  },
  {
    "path": "Kotlin/.gitignore",
    "content": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\n\n# Gradle files\n.gradle/\nbuild/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n\n.idea/.workspace\n\n# http://stackoverflow.com/questions/16736856/what-should-be-in-my-gitignore-for-an-android-studio-project\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n.idea\n**/*.iml\n*.hprof\n**/*.project\n"
  },
  {
    "path": "Kotlin/Readme.md",
    "content": "# BlurHash in Kotlin, for Android\n\n\n"
  },
  {
    "path": "Kotlin/build.gradle",
    "content": "\nbuildscript {\n\n    ext.kotlin_version = '1.3.72'\n\n    repositories {\n        google()\n        jcenter()\n    }\n\n    dependencies {\n        classpath 'com.android.tools.build:gradle:3.5.0'\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version\"\n    }\n\n}\n\nallprojects {\n\n    repositories {\n        google()\n        jcenter()\n    }\n\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n"
  },
  {
    "path": "Kotlin/demo/build.gradle",
    "content": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-android-extensions'\n\nandroid {\n\n    compileSdkVersion 29\n\n    defaultConfig {\n        applicationId \"com.wolt.blurhash\"\n        minSdkVersion 14\n        targetSdkVersion 29\n        versionCode 1\n        versionName \"1.0\"\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n\n}\n\ndependencies {\n    implementation project(path: ':lib')\n    implementation 'androidx.appcompat:appcompat:1.1.0'\n}\n"
  },
  {
    "path": "Kotlin/demo/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "Kotlin/demo/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n          package=\"com.wolt.blurhashapp\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:roundIcon=\"@mipmap/ic_launcher_round\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\"com.wolt.blurhashapp.MainActivity\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\"/>\n\n                <category android:name=\"android.intent.category.LAUNCHER\"/>\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "Kotlin/demo/src/main/java/com/wolt/blurhashapp/MainActivity.kt",
    "content": "package com.wolt.blurhashapp\n\nimport android.graphics.Bitmap\nimport android.os.Bundle\nimport android.os.SystemClock\nimport androidx.appcompat.app.AppCompatActivity\nimport com.wolt.blurhashkt.BlurHashDecoder\nimport kotlinx.android.synthetic.main.activity_main.*\n\nclass MainActivity : AppCompatActivity() {\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n        tvDecode.setOnClickListener {\n            var bitmap: Bitmap? = null\n            val time = timed {\n                bitmap = BlurHashDecoder.decode(etInput.text.toString(), 20, 12)\n            }\n            ivResult.setImageBitmap(bitmap)\n            ivResultTime.text = \"Time: $time ms\"\n        }\n    }\n\n}\n\n/**\n * Executes a function and return the time spent in milliseconds.\n */\nprivate inline fun timed(function: () -> Unit): Long {\n    val start = SystemClock.elapsedRealtime()\n    function()\n    return SystemClock.elapsedRealtime() - start\n}\n\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/drawable/bg_blue_rounded_rect_8.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:shape=\"rectangle\">\n    <solid android:color=\"#ff009de0\"/>\n    <corners android:radius=\"8dp\"/>\n</shape>\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:width=\"108dp\"\n    android:height=\"108dp\"\n    android:viewportHeight=\"108\"\n    android:viewportWidth=\"108\">\n    <path\n        android:fillColor=\"#26A69A\"\n        android:pathData=\"M0,0h108v108h-108z\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M9,0L9,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,0L19,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,0L29,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,0L39,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,0L49,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,0L59,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,0L69,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,0L79,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M89,0L89,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M99,0L99,108\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,9L108,9\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,19L108,19\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,29L108,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,39L108,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,49L108,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,59L108,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,69L108,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,79L108,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,89L108,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M0,99L108,99\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,29L89,29\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,39L89,39\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,49L89,49\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,59L89,59\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,69L89,69\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M19,79L89,79\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M29,19L29,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M39,19L39,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M49,19L49,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M59,19L59,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M69,19L69,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n    <path\n        android:fillColor=\"#00000000\"\n        android:pathData=\"M79,19L79,89\"\n        android:strokeColor=\"#33FFFFFF\"\n        android:strokeWidth=\"0.8\"/>\n</vector>\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/drawable-v24/ic_launcher_foreground.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        xmlns:aapt=\"http://schemas.android.com/aapt\"\n        android:width=\"108dp\"\n        android:height=\"108dp\"\n        android:viewportHeight=\"108\"\n        android:viewportWidth=\"108\">\n    <path\n        android:fillType=\"evenOdd\"\n        android:pathData=\"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\">\n        <aapt:attr name=\"android:fillColor\">\n            <gradient\n                android:endX=\"78.5885\"\n                android:endY=\"90.9159\"\n                android:startX=\"48.7653\"\n                android:startY=\"61.0927\"\n                android:type=\"linear\">\n                <item\n                    android:color=\"#44000000\"\n                    android:offset=\"0.0\"/>\n                <item\n                    android:color=\"#00000000\"\n                    android:offset=\"1.0\"/>\n            </gradient>\n        </aapt:attr>\n    </path>\n    <path\n        android:fillColor=\"#FFFFFF\"\n        android:fillType=\"nonZero\"\n        android:pathData=\"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z\"\n        android:strokeColor=\"#00000000\"\n        android:strokeWidth=\"1\"/>\n</vector>\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    android:padding=\"24dp\">\n\n    <EditText\n        android:id=\"@+id/etInput\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center_horizontal\"\n        android:gravity=\"center_horizontal\"\n        android:hint=\"@string/hint_blurhash\"\n        android:inputType=\"text\"\n        android:singleLine=\"true\"\n        android:text=\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\"\n        android:textColor=\"@color/colorAccent\" />\n\n    <TextView\n        android:id=\"@+id/tvDecode\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center_horizontal\"\n        android:layout_marginTop=\"12dp\"\n        android:background=\"@color/colorPrimary\"\n        android:elevation=\"8dp\"\n        android:paddingStart=\"12dp\"\n        android:paddingTop=\"8dp\"\n        android:paddingEnd=\"12dp\"\n        android:paddingBottom=\"8dp\"\n        android:text=\"@string/title_button_decode\"\n        android:textColor=\"@color/colorAccent\"\n        android:textSize=\"16sp\" />\n\n    <ImageView\n        android:id=\"@+id/ivResult\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"24dp\"\n        android:adjustViewBounds=\"true\" />\n\n    <TextView\n        android:id=\"@+id/ivResultTime\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center\"\n        android:gravity=\"center\"\n        android:textIsSelectable=\"true\"\n        android:textSize=\"16sp\"\n        tools:text=\"0 ms\" />\n</LinearLayout>\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@drawable/ic_launcher_foreground\"/>\n</adaptive-icon>\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <color name=\"colorPrimary\">#29b6f6</color>\n    <color name=\"colorPrimaryDark\">#0086c3</color>\n    <color name=\"colorAccent\">#444444</color>\n</resources>\n\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">BlurHash</string>\n    <string name=\"hint_blurhash\">BlurHash string</string>\n    <string name=\"title_button_decode\">Decode!</string>\n</resources>\n"
  },
  {
    "path": "Kotlin/demo/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\">\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "Kotlin/gradle/wrapper/gradle-wrapper.properties",
    "content": "#Mon Jul 01 10:02:38 EEST 2019\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-5.4.1-all.zip\n"
  },
  {
    "path": "Kotlin/gradle.properties",
    "content": "# Project-wide Gradle settings.\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\nandroid.enableJetifier=true\nandroid.useAndroidX=true\norg.gradle.jvmargs=-Xmx1536m\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true\n"
  },
  {
    "path": "Kotlin/gradlew",
    "content": "#!/usr/bin/env sh\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn () {\n    echo \"$*\"\n}\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave () {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=$(save \"$@\")\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [ \"$(uname)\" = \"Darwin\" ] && [ \"$HOME\" = \"$PWD\" ]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "Kotlin/gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto init\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:init\r\n@rem Get command-line arguments, handling Windows variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\n\r\n:win9xME_args\r\n@rem Slurp the command line arguments.\r\nset CMD_LINE_ARGS=\r\nset _SKIP=2\r\n\r\n:win9xME_args_slurp\r\nif \"x%~1\" == \"x\" goto execute\r\n\r\nset CMD_LINE_ARGS=%*\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "Kotlin/lib/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'kotlin-android-extensions'\napply plugin: 'kotlin-android'\n\nandroid {\n\n    compileSdkVersion 29\n\n    defaultConfig {\n        minSdkVersion 14\n        targetSdkVersion 29\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"androidx.test.runner.AndroidJUnitRunner\"\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    implementation \"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version\"\n    androidTestImplementation 'junit:junit:4.13'\n    androidTestImplementation 'androidx.test:runner:1.2.0'\n}\n"
  },
  {
    "path": "Kotlin/lib/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "Kotlin/lib/src/androidTest/java/com/wolt/blurhashkt/BlurHashDecoderTest.kt",
    "content": "package com.wolt.blurhashkt\n\nimport android.graphics.Bitmap\nimport com.wolt.blurhashkt.BlurHashDecoder.clearCache\nimport com.wolt.blurhashkt.BlurHashDecoder.decode\nimport junit.framework.Assert.assertTrue\nimport org.junit.Before\nimport org.junit.Test\nimport java.nio.ByteBuffer\nimport java.util.*\n\n\nclass BlurHashDecoderTest {\n    @Before\n    @Throws(Exception::class)\n    fun setUp() {\n        clearCache()\n    }\n\n    @Test\n    fun decode_smallImage_cacheEnabled_shouldGetTheSameBitmapInManyRequests() {\n        val bmp1 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12)!!\n        val bmp2 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12)!!\n        val bmp3 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12)!!\n\n        bmp1.assertEquals(bmp2)\n        bmp2.assertEquals(bmp3)\n    }\n\n    @Test\n    fun decode_smallImage_differentCache_shouldGetTheSameBitmapInManyRequests() {\n        val bmp1 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12)!!\n        val bmp2 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12, useCache = false)!!\n        val bmp3 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12)!!\n\n        bmp1.assertEquals(bmp2)\n        bmp2.assertEquals(bmp3)\n    }\n\n    @Test\n    fun decode_smallImage_cacheDisabled_shouldGetTheSameBitmapInManyRequests() {\n        val bmp1 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12, useCache = false)!!\n        val bmp2 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12, useCache = false)!!\n        val bmp3 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 20, 12, useCache = false)!!\n\n        bmp1.assertEquals(bmp2)\n        bmp2.assertEquals(bmp3)\n    }\n\n    @Test\n    fun decode_bigImage_cacheEnabled_shouldGetTheSameBitmapInManyRequests() {\n        val bmp1 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100)!!\n        val bmp2 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100)!!\n        val bmp3 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100)!!\n\n        bmp1.assertEquals(bmp2)\n        bmp2.assertEquals(bmp3)\n    }\n\n    @Test\n    fun decode_bigImage_differentCache_shouldGetTheSameBitmapInManyRequests() {\n        val bmp1 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100)!!\n        val bmp2 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100, useCache = false)!!\n        val bmp3 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100)!!\n\n        bmp1.assertEquals(bmp2)\n        bmp2.assertEquals(bmp3)\n    }\n\n    @Test\n    fun decode_bigImage_cacheDisabled_shouldGetTheSameBitmapInManyRequests() {\n        val bmp1 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100, useCache = false)!!\n        val bmp2 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100, useCache = false)!!\n        val bmp3 = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 100, 100, useCache = false)!!\n\n        bmp1.assertEquals(bmp2)\n        bmp2.assertEquals(bmp3)\n    }\n}\n\nfun Bitmap.assertEquals(bitmap2: Bitmap) {\n    val buffer1: ByteBuffer = ByteBuffer.allocate(height * rowBytes)\n    copyPixelsToBuffer(buffer1)\n    val buffer2: ByteBuffer = ByteBuffer.allocate(bitmap2.height * bitmap2.rowBytes)\n    bitmap2.copyPixelsToBuffer(buffer2)\n    val equals = Arrays.equals(buffer1.array(), buffer2.array())\n    assertTrue(equals)\n}\n"
  },
  {
    "path": "Kotlin/lib/src/main/AndroidManifest.xml",
    "content": "<manifest package=\"com.wolt.blurhashkt\" />\n"
  },
  {
    "path": "Kotlin/lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt",
    "content": "package com.wolt.blurhashkt\n\nimport android.graphics.Bitmap\nimport android.graphics.Color\nimport kotlin.math.cos\nimport kotlin.math.pow\nimport kotlin.math.withSign\n\nobject BlurHashDecoder {\n\n    // cache Math.cos() calculations to improve performance.\n    // The number of calculations can be huge for many bitmaps: width * height * numCompX * numCompY * 2 * nBitmaps\n    // the cache is enabled by default, it is recommended to disable it only when just a few images are displayed\n    private val cacheCosinesX = HashMap<Int, DoubleArray>()\n    private val cacheCosinesY = HashMap<Int, DoubleArray>()\n\n    /**\n     * Clear calculations stored in memory cache.\n     * The cache is not big, but will increase when many image sizes are used,\n     * if the app needs memory it is recommended to clear it.\n     */\n    fun clearCache() {\n        cacheCosinesX.clear()\n        cacheCosinesY.clear()\n    }\n\n    /**\n     * Decode a blur hash into a new bitmap.\n     *\n     * @param useCache use in memory cache for the calculated math, reused by images with same size.\n     *                 if the cache does not exist yet it will be created and populated with new calculations.\n     *                 By default it is true.\n     */\n    fun decode(blurHash: String?, width: Int, height: Int, punch: Float = 1f, useCache: Boolean = true): Bitmap? {\n        if (blurHash == null || blurHash.length < 6) {\n            return null\n        }\n        val numCompEnc = decode83(blurHash, 0, 1)\n        val numCompX = (numCompEnc % 9) + 1\n        val numCompY = (numCompEnc / 9) + 1\n        if (blurHash.length != 4 + 2 * numCompX * numCompY) {\n            return null\n        }\n        val maxAcEnc = decode83(blurHash, 1, 2)\n        val maxAc = (maxAcEnc + 1) / 166f\n        val colors = Array(numCompX * numCompY) { i ->\n            if (i == 0) {\n                val colorEnc = decode83(blurHash, 2, 6)\n                decodeDc(colorEnc)\n            } else {\n                val from = 4 + i * 2\n                val colorEnc = decode83(blurHash, from, from + 2)\n                decodeAc(colorEnc, maxAc * punch)\n            }\n        }\n        return composeBitmap(width, height, numCompX, numCompY, colors, useCache)\n    }\n\n    private fun decode83(str: String, from: Int = 0, to: Int = str.length): Int {\n        var result = 0\n        for (i in from until to) {\n            val index = charMap[str[i]] ?: -1\n            if (index != -1) {\n                result = result * 83 + index\n            }\n        }\n        return result\n    }\n\n    private fun decodeDc(colorEnc: Int): FloatArray {\n        val r = colorEnc shr 16\n        val g = (colorEnc shr 8) and 255\n        val b = colorEnc and 255\n        return floatArrayOf(srgbToLinear(r), srgbToLinear(g), srgbToLinear(b))\n    }\n\n    private fun srgbToLinear(colorEnc: Int): Float {\n        val v = colorEnc / 255f\n        return if (v <= 0.04045f) {\n            (v / 12.92f)\n        } else {\n            ((v + 0.055f) / 1.055f).pow(2.4f)\n        }\n    }\n\n    private fun decodeAc(value: Int, maxAc: Float): FloatArray {\n        val r = value / (19 * 19)\n        val g = (value / 19) % 19\n        val b = value % 19\n        return floatArrayOf(\n                signedPow2((r - 9) / 9.0f) * maxAc,\n                signedPow2((g - 9) / 9.0f) * maxAc,\n                signedPow2((b - 9) / 9.0f) * maxAc\n        )\n    }\n\n    private fun signedPow2(value: Float) = value.pow(2f).withSign(value)\n\n    private fun composeBitmap(\n            width: Int, height: Int,\n            numCompX: Int, numCompY: Int,\n            colors: Array<FloatArray>,\n            useCache: Boolean\n    ): Bitmap {\n        // use an array for better performance when writing pixel colors\n        val imageArray = IntArray(width * height)\n        val calculateCosX = !useCache || !cacheCosinesX.containsKey(width * numCompX)\n        val cosinesX = getArrayForCosinesX(calculateCosX, width, numCompX)\n        val calculateCosY = !useCache || !cacheCosinesY.containsKey(height * numCompY)\n        val cosinesY = getArrayForCosinesY(calculateCosY, height, numCompY)\n        for (y in 0 until height) {\n            for (x in 0 until width) {\n                var r = 0f\n                var g = 0f\n                var b = 0f\n                for (j in 0 until numCompY) {\n                    for (i in 0 until numCompX) {\n                        val cosX = cosinesX.getCos(calculateCosX, i, numCompX, x, width)\n                        val cosY = cosinesY.getCos(calculateCosY, j, numCompY, y, height)\n                        val basis = (cosX * cosY).toFloat()\n                        val color = colors[j * numCompX + i]\n                        r += color[0] * basis\n                        g += color[1] * basis\n                        b += color[2] * basis\n                    }\n                }\n                imageArray[x + width * y] = Color.rgb(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b))\n            }\n        }\n        return Bitmap.createBitmap(imageArray, width, height, Bitmap.Config.ARGB_8888)\n    }\n\n    private fun getArrayForCosinesY(calculate: Boolean, height: Int, numCompY: Int) = when {\n        calculate -> {\n            DoubleArray(height * numCompY).also {\n                cacheCosinesY[height * numCompY] = it\n            }\n        }\n        else -> {\n            cacheCosinesY[height * numCompY]!!\n        }\n    }\n\n    private fun getArrayForCosinesX(calculate: Boolean, width: Int, numCompX: Int) = when {\n        calculate -> {\n            DoubleArray(width * numCompX).also {\n                cacheCosinesX[width * numCompX] = it\n            }\n        }\n        else -> cacheCosinesX[width * numCompX]!!\n    }\n\n    private fun DoubleArray.getCos(\n            calculate: Boolean,\n            x: Int,\n            numComp: Int,\n            y: Int,\n            size: Int\n    ): Double {\n        if (calculate) {\n            this[x + numComp * y] = cos(Math.PI * y * x / size)\n        }\n        return this[x + numComp * y]\n    }\n\n    private fun linearToSrgb(value: Float): Int {\n        val v = value.coerceIn(0f, 1f)\n        return if (v <= 0.0031308f) {\n            (v * 12.92f * 255f + 0.5f).toInt()\n        } else {\n            ((1.055f * v.pow(1 / 2.4f) - 0.055f) * 255 + 0.5f).toInt()\n        }\n    }\n\n    private val charMap = listOf(\n            '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G',\n            'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',\n            'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',\n            'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',',\n            '-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~'\n    )\n            .mapIndexed { i, c -> c to i }\n            .toMap()\n\n}\n"
  },
  {
    "path": "Kotlin/settings.gradle",
    "content": "include ':demo', ':lib'\n"
  },
  {
    "path": "License.md",
    "content": "MIT License\n\nCopyright (c) 2018 Wolt Enterprises\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "Readme.md",
    "content": "# [BlurHash](http://blurha.sh)\n\nBlurHash is a compact representation of a placeholder for an image.\n\n## Why would you want this?\n\nDoes your designer cry every time you load their beautifully designed screen, and it is full of empty boxes because all the\nimages have not loaded yet? Does your database engineer cry when you want to solve this by trying to cram little thumbnail\nimages into your data to show as placeholders?\n\nBlurHash will solve your problems! How? Like this:\n\n<img src=\"Media/WhyBlurHash.png\" width=\"600\">\n\nYou can also see nice examples and try it out yourself at [blurha.sh](http://blurha.sh/)!\n\n## How does it work?\n\nIn short, BlurHash takes an image, and gives you a short string (only 20-30 characters!) that represents the placeholder for this\nimage. You do this on the backend of your service, and store the string along with the image. When you send data to your\nclient, you send both the URL to the image, and the BlurHash string. Your client then takes the string, and decodes it into an\nimage that it shows while the real image is loading over the network. The string is short enough that it comfortably fits into\nwhatever data format you use. For instance, it can easily be added as a field in a JSON object.\n\nIn summary:\n\n<img src=\"Media/HowItWorks1.jpg\" width=\"250\">&nbsp;&nbsp;&nbsp;<img src=\"Media/HowItWorks2.jpg\" width=\"250\">\n\nWant to know all the gory technical details? Read the [algorithm description](Algorithm.md).\n\nImplementing the algorithm is actually quite easy! Implementations are short and easily ported to your favourite language or\nplatform.\n\n## Implementations\n\nSo far, we have created these implementations:\n\n* [C](C) - An encoder implementation in portable C code.\n* [Swift](Swift) - Encoder and decoder implementations, and a larger library offering advanced features.\n  There is also an example app to play around with the algorithm.\n* [Kotlin](Kotlin) - A decoder implementation for Android.\n* [TypeScript](TypeScript) - Encoder and decoder implementations, and an example page to test.\n* [Python](https://github.com/woltapp/blurhash-python) - Integration of the C encoder code into Python.\n\nThese cover our use cases, but could probably use polishing, extending and improving. There are also these third party implementations that we know of:\n\n* [Pure Python](https://github.com/halcy/blurhash-python) - Implementation of both the encoder and decoder in pure Python.\n* [One version in Go](https://github.com/bbrks/go-blurhash), and [another version in Go](https://github.com/buckket/go-blurhash).\n* [PHP](https://github.com/kornrunner/php-blurhash) - Encoder and decoder implementations in pure PHP.\n* [Java](https://github.com/hsch/blurhash-java) - Encoder implementation in Java.\n* [Clojure](https://github.com/siili-core/blurhash) - Encoder and decoder implementations in Clojure.\n* [Nim](https://github.com/SolitudeSF/blurhash) - Encoder and decoder implementation in pure Nim.\n* [Rust and WebAssembly](https://github.com/fpapado/blurhash-rust-wasm) - Encoder and decoder implementations in Rust. Distributed as both native Rust and WebAssembly packages.\n* [Ruby](https://github.com/Gargron/blurhash) - Encoder implementation in Ruby.\n* [Crystal](https://github.com/Sija/blurhash.cr) - Encoder implementation in pure Crystal.\n* [Elm](https://github.com/WhileTruu/elm-blurhash) - Encoder and decoder in Elm.\n* [Dart](https://github.com/folksable/blurhash_ffi) - Encoder and decoder implementation in C into Dart using dart-ffi.\n* [Pure Dart](https://github.com/justacid/blurhash-dart) - Encoder and decoder implementation in pure Dart.\n* [.NET](https://github.com/MarkusPalcer/blurhash.net) - Encoder and decoder in C#.\n* [JavaScript](https://github.com/Dens49/blurhash-js) - Encoder and decoder implementation in pure JavaScript.\n* [.NET](https://github.com/Bond-009/BlurHashSharp) - Encoder implementation in C#.\n* [Haskell](https://github.com/SamProtas/JuicyPixels-blurhash) - Encoder and decoder in pure Haskell.\n* [Scala](https://github.com/markussammallahti/blurhash-scala) - Encoder and decoder in Scala.\n* [Elixir](https://github.com/perzanko/blurhash-elixir) - Encoder implementation in pure Elixir.\n* [ReScript](https://github.com/armedi/rescript-blurhash) - Encoder and decoder implementation in ReScript (BuckleScript).\n* [JavaScript](https://github.com/mad-gooze/fast-blurhash) - Tiny optimized decoder implementation JS.\n* [Xojo](https://github.com/piradoiv/xojo-blurhash/) - Encoder and decoder implementation in pure Xojo.\n* [React Native](https://github.com/mrousavy/react-native-blurhash) - UI Component for React Native. (Decoder in Swift and Kotlin)\n* [Zig](https://github.com/mhoward540/blurhash-zig) - Encoder implementation in Zig.\n* [Titanium SDK](https://github.com/m1ga/ti.blurhash) - Decoder for Titanium SDK (Android)\n* [BQN](https://github.com/dancek/blurhash-bqn) - Encoder, decoder and terminal viewer in pure BQN.\n* [Jetpack Compose](https://github.com/wajahat-iqbal/BlurHashPainter) - Decoder Jetpack Compose implementation\n* [C++](https://github.com/Nheko-Reborn/blurhash) - Encoder and decoder in C++.\n* [Kotlin Multiplatform](https://github.com/vanniktech/blurhash) - Encoding & decoding for Android, iOS & JVM\n* [OCaml](https://github.com/ushitora-anqou/ocaml-blurhash) - Encoder implementation in OCaml.\n\nCan't find the language you're looking for? Try your luck with the GitHub search. For example, here are the search results for [repos which have \"blurhash\" in their name](https://github.com/search?q=blurhash+in%3Aname&type=repositories).\n\nPerhaps you'd like to help extend this list? Which brings us to...\n\n## Contributing\n\nWe'd love contributions! The algorithm is [very simple](Algorithm.md) - less than two hundred lines of code - and can easily be\nported to your platform of choice. And having support for more platforms would be wonderful! So, Java decoder? Golang encoder?\nHaskell? Rust? We want them all!\n\nWe will also try to tag any issues on our [issue tracker](https://github.com/woltapp/blurhash/issues) that we'd love help with, so\nif you just want to dip in, go have a look.\n\nYou can file a pull request with us, or you can start your own repo and project if you want to run everything yourself, we don't mind.\n\nIf you do want to contribute to this project, we have a [code of conduct](CodeOfConduct.md).\n\n## Users\n\nWho uses BlurHash? Here are some projects we know about:\n\n* [Wolt](http://wolt.com/) - We are of course using it ourselves. BlurHashes are used in the mobile clients on iOS and Android, as well as on the web, as placeholders during image loading.\n* [Mastodon](https://github.com/tootsuite/mastodon) - The Mastodon decentralised social media network uses BlurHashes both as loading placeholders, as well as for hiding media marked as sensitive.\n* [Signal](https://signal.org/) - Signal Private Messenger uses Blurhashes as placeholders before photo & video messages are downloaded in chat conversations.\n* [Jellyfin](https://jellyfin.org/) - Jellyfin the free software media system uses Blurhashes as placeholders for images of movies and TV shows when they are being downloaded.\n\n## Good Questions\n\n### How fast is encoding? Decoding?\n\nThese implementations are not very optimised. Running them on very large images can be a bit slow. The performance of\nthe encoder and decoder are about the same for the same input or output size, so decoding very large placeholders, especially\non your UI thread, can also be a bit slow.\n\nHowever! The trick to using the algorithm efficiently is to not run it on full-sized data. The fine detail of an image is all thrown away,\nso you should scale your images down before running BlurHash on them. If you are creating thumbnails, run BlurHash on those\ninstead of the full images.\n\nSimilarly, when displaying the placeholders, very small images work very well when scaled up. We usually decode placeholders\nthat are 32 or even 20 pixels wide, and then let the UI layer scale them up, which is indistinguishable from decoding them at full size.\n\n### How do I pick the number of X and Y components?\n\nIt depends a bit on taste. The more components you pick, the more information is retained in the placeholder, but the longer\nthe BlurHash string will be. Also, it doesn't always look good with too many components. We usually go with 4 by 3, which\nseems to strike a nice balance.\n\nHowever, you should adjust the number of components depending on the aspect ratio of your images. For instance, very wide\nimages should have more X components and fewer Y components.\n\nThe Swift example project contains a test app where you can play around with the parameters and see the results.\n\n### What is the `punch` parameter in some of these implementations?\n\nIt is a parameter that adjusts the contrast on the decoded image. 1 means normal, smaller values will make the effect more subtle,\nand larger values will make it stronger. This is basically a design parameter, which lets you adjust the look.\n\nTechnically, what it does is scale the AC components up or down.\n\n### Is this only useful as an image loading placeholder?\n\nWell, that is what it was designed for originally, but it turns out to be useful for a few other things:\n\n* Masking images without having to use expensive blurs - [Mastodon](http://github.com/tootsuite/mastodon) uses it for this.\n* The data representation makes it quite easy to extract colour averages of the image for different areas. You can easily find approximations of things like the average colour of the top edge of the image, or of a corner. There is some code in the Swift BlurHashKit implementation to experiment with this. Also, the average colour of the entire image is just the DC component and can be decoded even without implementing any of the more complicated DCT stuff.\n* We have been meaning to try to implement tinted drop shadows for UI elements by using the BlurHash and extending the borders. Haven't actually had time to implement this yet though.\n\n### Why base 83?\n\nFirst, 83 seems to be about how many low-ASCII characters you can find that are safe for use in all of JSON, HTML and shells.\n\nSecondly, 83 * 83 is very close to, and a little more than, 19 * 19 * 19, making it ideal for encoding three AC components in two\ncharacters.\n\n### What about using the full Unicode character set to get a more efficient encoding?\n\nWe haven't looked into how much overhead UTF-8 encoding would introduce versus base 83 in single-byte characters, but\nthe encoding and decoding would probably be a lot more complicated, so in the spirit of minimalism BlurHash uses the simpler\noption. It might also be awkward to copy-paste, depending on OS capabilities.\n\nIf you think it can be done and is worth it, though, do make your own version and show us! We'd love to see it in action.\n\n### What about other basis representations than DCT?\n\nThis is something we'd *love* to try. The DCT looks quite ugly when you increase the number of components, probably because\nthe shape of the basis functions becomes too visible. Using a different basis with more aesthetically pleasing shape might be\na big win.\n\nHowever, we have not managed come up with one. Some experimenting with a [Fourier-Bessel base](https://en.wikipedia.org/wiki/Fourier–Bessel_series),\ntargeted at images that are going to be cropped into circles has been done, but without much success. Here again we'd love\nto see what you can come up with!\n\n## Authors\n\n* [Dag Ågren](https://github.com/DagAgren) - Original algorithm design, Swift and C implementations\n* [Mykhailo Shchurov](https://github.com/shchurov) - Kotlin decoder implementation\n* [Hang Duy Khiem](https://github.com/hangduykhiem) - Android demo app\n* [Olli Mahlamäki](https://github.com/omahlama) - TypeScript decoder and encoder implementations\n* [Atte Lautanala](https://github.com/lautat) - Python integration\n* [Lorenz Diener](https://github.com/halcy) - Pure Python implementation\n* [Boris Momčilović](https://github.com/kornrunner) - Pure PHP implementation\n* [Hendrik Schnepel](https://github.com/hsch) - Java encoder implementation\n* [Tuomo Virolainen](https://github.com/tvirolai) - Clojure implementation\n* [Fotis Papadogeorgopoulos](https://github.com/fpapado) - Rust and WebAssembly implementation\n* [Sam Protas](https://github.com/SamProtas) - Pure Haskell implementation\n* [Markus Sammallahti](https://github.com/markussammallahti) - Scala implementation\n* [Kacper Perzankowski](https://github.com/perzanko) - Elixir encoder implementation\n* [Belvi Nosakhare](https://github.com/KingsMentor/BlurHashExt) - Kotlin extensions of Blurhash for ImageView, Glide, and Piccasso optimized for Android.\n* [Armedi](https://github.com/armedi) - ReScript (BuckleScript) implementation.\n* [Ricardo Cruz](https://github.com/piradoiv) - Xojo implementation.\n* [Marc Rousavy](https://github.com/mrousavy) - React Native UI Component\n* [Matt Howard](https://github.com/mhoward540) - Zig implementation\n* [Hannu Hartikainen](https://github.com/dancek) - BQN implementation\n* [Wajahat Iqbal](https://github.com/wajahat-iqbal) - Jetpack compose-based implementation optimized for using any component as a painter.\n\n\n* _Your name here?_\n"
  },
  {
    "path": "SECURITY.md",
    "content": "# Security Policy\n\n## Reporting a Vulnerability\n\nPlease report security issues to `security@wolt.com`"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section */\n\t\t1B0A250F1EC5E90C00F25F08 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0A250E1EC5E90C00F25F08 /* AppDelegate.swift */; };\n\t\t1B0A25111EC5E90C00F25F08 /* SimpleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0A25101EC5E90C00F25F08 /* SimpleViewController.swift */; };\n\t\t1B0A25141EC5E90C00F25F08 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25121EC5E90C00F25F08 /* Main.storyboard */; };\n\t\t1B0A25161EC5E90C00F25F08 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25151EC5E90C00F25F08 /* Assets.xcassets */; };\n\t\t1B0A25191EC5E90C00F25F08 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25171EC5E90C00F25F08 /* LaunchScreen.storyboard */; };\n\t\t1B0A251E1EC5EA0500F25F08 /* BlurHashKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */; };\n\t\t1B0A251F1EC5EA0500F25F08 /* BlurHashKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };\n\t\t1B0A25291EC5EAB000F25F08 /* pic1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25241EC5EAB000F25F08 /* pic1.png */; };\n\t\t1B0A252A1EC5EAB000F25F08 /* pic2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25251EC5EAB000F25F08 /* pic2.png */; };\n\t\t1B0A252B1EC5EAB000F25F08 /* pic3.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25261EC5EAB000F25F08 /* pic3.png */; };\n\t\t1B0A252C1EC5EAB000F25F08 /* pic4.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25271EC5EAB000F25F08 /* pic4.png */; };\n\t\t1B0A252D1EC5EAB000F25F08 /* pic5.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25281EC5EAB000F25F08 /* pic5.png */; };\n\t\t1B19DF602015E72C00D8FCD7 /* pic6.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B19DF5F2015E72B00D8FCD7 /* pic6.png */; };\n\t\t1B2BA1CA1F0E5EE3006057C1 /* encode.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B2BA1C81F0E5EE3006057C1 /* encode.c */; };\n\t\t1B2BA1CB1F0E5EEA006057C1 /* blurhash_stb.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B2BA1C41F0E5ED6006057C1 /* blurhash_stb.c */; };\n\t\t1B6C71FD2272453D000D3BB1 /* BlurHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */; };\n\t\t1B6C71FE2272453D000D3BB1 /* FromString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60741FF40AF200E42DD7 /* FromString.swift */; };\n\t\t1B6C71FF2272453D000D3BB1 /* ToString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60721FF40AEA00E42DD7 /* ToString.swift */; };\n\t\t1B6C72002272453D000D3BB1 /* FromUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */; };\n\t\t1B6C72012272453D000D3BB1 /* ToUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */; };\n\t\t1B6C72022272453D000D3BB1 /* Generation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7F20098E2F00A17481 /* Generation.swift */; };\n\t\t1B6C72032272453D000D3BB1 /* TupleMaths.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7D20098E1500A17481 /* TupleMaths.swift */; };\n\t\t1B6C72042272453D000D3BB1 /* ColourSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */; };\n\t\t1B6C72052272453D000D3BB1 /* StringCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */; };\n\t\t1B6C72062272453D000D3BB1 /* ColourProbes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BDE56D02011EC5F00569DCB /* ColourProbes.swift */; };\n\t\t1B83DED122D88D1500CAA12F /* EscapeSequences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B83DED022D88D1500CAA12F /* EscapeSequences.swift */; };\n\t\t1B83DED222D88D1500CAA12F /* EscapeSequences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B83DED022D88D1500CAA12F /* EscapeSequences.swift */; };\n\t\t1BAA606D1FF40A0800E42DD7 /* BlurHashEncode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B49CD261EC47243006F8E7D /* BlurHashEncode.swift */; };\n\t\t1BAA606E1FF40A0B00E42DD7 /* BlurHashDecode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B49CD281EC4724C006F8E7D /* BlurHashDecode.swift */; };\n\t\t1BAA60711FF40A2F00E42DD7 /* BlurHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */; };\n\t\t1BAA60731FF40AEA00E42DD7 /* ToString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60721FF40AEA00E42DD7 /* ToString.swift */; };\n\t\t1BAA60751FF40AF200E42DD7 /* FromString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60741FF40AF200E42DD7 /* FromString.swift */; };\n\t\t1BAA60771FF40C4C00E42DD7 /* ToUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */; };\n\t\t1BAA60791FF40C5800E42DD7 /* FromUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */; };\n\t\t1BAA607B1FF40D8900E42DD7 /* StringCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */; };\n\t\t1BAA607D1FF422AE00E42DD7 /* ColourSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */; };\n\t\t1BC34D7A2005818D00A17481 /* AdvancedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D792005818D00A17481 /* AdvancedViewController.swift */; };\n\t\t1BC34D7C200988ED00A17481 /* GeneratedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7B200988ED00A17481 /* GeneratedViewController.swift */; };\n\t\t1BC34D7E20098E1500A17481 /* TupleMaths.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7D20098E1500A17481 /* TupleMaths.swift */; };\n\t\t1BC34D8020098E2F00A17481 /* Generation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7F20098E2F00A17481 /* Generation.swift */; };\n\t\t1BDE56D12011EC5F00569DCB /* ColourProbes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BDE56D02011EC5F00569DCB /* ColourProbes.swift */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t1B0A25201EC5EA0500F25F08 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 1B49CD121EC4721A006F8E7D /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 1B49CD1A1EC4721A006F8E7D;\n\t\t\tremoteInfo = BlurHash;\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t1B0A25221EC5EA0500F25F08 /* Embed Frameworks */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"\";\n\t\t\tdstSubfolderSpec = 10;\n\t\t\tfiles = (\n\t\t\t\t1B0A251F1EC5EA0500F25F08 /* BlurHashKit.framework in Embed Frameworks */,\n\t\t\t);\n\t\t\tname = \"Embed Frameworks\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B2BA1BB1F0E5EC5006057C1 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = /usr/share/man/man1/;\n\t\t\tdstSubfolderSpec = 0;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 1;\n\t\t};\n\t\t1B6C71F42272451E000D3BB1 /* CopyFiles */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = \"include/$(PRODUCT_NAME)\";\n\t\t\tdstSubfolderSpec = 16;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t1B0A250C1EC5E90C00F25F08 /* BlurHashTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BlurHashTest.app; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t1B0A250E1EC5E90C00F25F08 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = \"<group>\"; };\n\t\t1B0A25101EC5E90C00F25F08 /* SimpleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleViewController.swift; sourceTree = \"<group>\"; };\n\t\t1B0A25131EC5E90C00F25F08 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = \"<group>\"; };\n\t\t1B0A25151EC5E90C00F25F08 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = \"<group>\"; };\n\t\t1B0A25181EC5E90C00F25F08 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = \"<group>\"; };\n\t\t1B0A251A1EC5E90C00F25F08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t1B0A25241EC5EAB000F25F08 /* pic1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic1.png; sourceTree = \"<group>\"; };\n\t\t1B0A25251EC5EAB000F25F08 /* pic2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic2.png; sourceTree = \"<group>\"; };\n\t\t1B0A25261EC5EAB000F25F08 /* pic3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic3.png; sourceTree = \"<group>\"; };\n\t\t1B0A25271EC5EAB000F25F08 /* pic4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic4.png; sourceTree = \"<group>\"; };\n\t\t1B0A25281EC5EAB000F25F08 /* pic5.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic5.png; sourceTree = \"<group>\"; };\n\t\t1B19DF5F2015E72B00D8FCD7 /* pic6.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic6.png; sourceTree = \"<group>\"; };\n\t\t1B1B249320C13E9700D8EF03 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = \"<group>\"; };\n\t\t1B1B249420C13E9700D8EF03 /* dev-requirements.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = \"dev-requirements.txt\"; sourceTree = \"<group>\"; };\n\t\t1B1B249620C13E9700D8EF03 /* pic2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic2.png; sourceTree = \"<group>\"; };\n\t\t1B1B249720C13E9700D8EF03 /* pic2_bw.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic2_bw.png; sourceTree = \"<group>\"; };\n\t\t1B1B249820C13E9700D8EF03 /* test_encode.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = test_encode.py; sourceTree = \"<group>\"; };\n\t\t1B1B249920C13E9700D8EF03 /* MANIFEST.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = MANIFEST.in; sourceTree = \"<group>\"; };\n\t\t1B1B249A20C13E9700D8EF03 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = \"<group>\"; };\n\t\t1B1B249B20C13E9700D8EF03 /* setup.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = setup.py; sourceTree = \"<group>\"; };\n\t\t1B1B249D20C13E9700D8EF03 /* tox.ini */ = {isa = PBXFileReference; lastKnownFileType = text; path = tox.ini; sourceTree = \"<group>\"; };\n\t\t1B1B249E20C13E9700D8EF03 /* setup.cfg */ = {isa = PBXFileReference; lastKnownFileType = text; path = setup.cfg; sourceTree = \"<group>\"; };\n\t\t1B1B24FF20C13E9700D8EF03 /* config.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = config.yml; sourceTree = \"<group>\"; };\n\t\t1B1B250220C13E9700D8EF03 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = \"<group>\"; };\n\t\t1B1B250320C13E9700D8EF03 /* encode.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = encode.c; sourceTree = \"<group>\"; };\n\t\t1B1B250420C13E9700D8EF03 /* build_blurhash.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = build_blurhash.py; sourceTree = \"<group>\"; };\n\t\t1B1B250520C13E9700D8EF03 /* encode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = encode.h; sourceTree = \"<group>\"; };\n\t\t1B1B250620C1491900D8EF03 /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = \"<group>\"; };\n\t\t1B2BA1BD1F0E5EC5006057C1 /* blurhash */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = blurhash; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t1B2BA1C41F0E5ED6006057C1 /* blurhash_stb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blurhash_stb.c; sourceTree = \"<group>\"; };\n\t\t1B2BA1C81F0E5EE3006057C1 /* encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = encode.c; sourceTree = \"<group>\"; };\n\t\t1B2BA1C91F0E5EE3006057C1 /* encode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = encode.h; sourceTree = \"<group>\"; };\n\t\t1B2BA1CC1F0E692F006057C1 /* stb_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_image.h; sourceTree = \"<group>\"; };\n\t\t1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BlurHashKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t1B49CD1F1EC4721A006F8E7D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t1B49CD261EC47243006F8E7D /* BlurHashEncode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurHashEncode.swift; sourceTree = \"<group>\"; };\n\t\t1B49CD281EC4724C006F8E7D /* BlurHashDecode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = \"<group>\"; };\n\t\t1B6C71F122724500000D3BB1 /* BlurHashKit copy-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = \"BlurHashKit copy-Info.plist\"; path = \"/Users/dag/Code/Toot/BlurHash/BlurHashKit copy-Info.plist\"; sourceTree = \"<absolute>\"; };\n\t\t1B6C71F62272451E000D3BB1 /* libBlurHashKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBlurHashKit.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t1B83DED022D88D1500CAA12F /* EscapeSequences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EscapeSequences.swift; sourceTree = \"<group>\"; };\n\t\t1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurHash.swift; sourceTree = \"<group>\"; };\n\t\t1BAA60721FF40AEA00E42DD7 /* ToString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToString.swift; sourceTree = \"<group>\"; };\n\t\t1BAA60741FF40AF200E42DD7 /* FromString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FromString.swift; sourceTree = \"<group>\"; };\n\t\t1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToUIImage.swift; sourceTree = \"<group>\"; };\n\t\t1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FromUIImage.swift; sourceTree = \"<group>\"; };\n\t\t1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringCoding.swift; sourceTree = \"<group>\"; };\n\t\t1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColourSpace.swift; sourceTree = \"<group>\"; };\n\t\t1BC34D792005818D00A17481 /* AdvancedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvancedViewController.swift; sourceTree = \"<group>\"; };\n\t\t1BC34D7B200988ED00A17481 /* GeneratedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedViewController.swift; sourceTree = \"<group>\"; };\n\t\t1BC34D7D20098E1500A17481 /* TupleMaths.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TupleMaths.swift; sourceTree = \"<group>\"; };\n\t\t1BC34D7F20098E2F00A17481 /* Generation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Generation.swift; sourceTree = \"<group>\"; };\n\t\t1BDE56D02011EC5F00569DCB /* ColourProbes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColourProbes.swift; sourceTree = \"<group>\"; };\n\t\t1BEFFFA720BEE66400187F3F /* index.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = index.html; sourceTree = \"<group>\"; };\n\t\t1BEFFFB520BEE66400187F3F /* webpack.config.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = webpack.config.js; sourceTree = \"<group>\"; };\n\t\t1BEFFFB720BEE66400187F3F /* package.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = package.json; sourceTree = \"<group>\"; };\n\t\t1BEFFFB820BEE66400187F3F /* tsconfig.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = tsconfig.json; sourceTree = \"<group>\"; };\n\t\t1BEFFFBA20BEE66400187F3F /* decode.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = decode.ts; sourceTree = \"<group>\"; };\n\t\t1BEFFFBB20BEE66400187F3F /* demo.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = demo.ts; sourceTree = \"<group>\"; };\n\t\t1BEFFFBC20BEE66400187F3F /* utils.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = utils.ts; sourceTree = \"<group>\"; };\n\t\t1BEFFFBD20BEE66400187F3F /* index.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = index.ts; sourceTree = \"<group>\"; };\n\t\t1BEFFFBE20BEE66400187F3F /* base83.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = base83.ts; sourceTree = \"<group>\"; };\n\t\t1BEFFFBF20BFDC1600187F3F /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = \"<group>\"; };\n\t\t1BEFFFC120BFE05600187F3F /* BlurHashDecoder.kt */ = {isa = PBXFileReference; lastKnownFileType = text; name = BlurHashDecoder.kt; path = lib/src/main/java/com/wolt/blurhashkt/BlurHashDecoder.kt; sourceTree = \"<group>\"; };\n\t\t1BEFFFC220BFE33E00187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = \"<group>\"; };\n\t\t1BEFFFC320BFE34800187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = Readme.md; path = ../Readme.md; sourceTree = \"<group>\"; };\n\t\t1BEFFFC420BFE35300187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = \"<group>\"; };\n\t\t1BEFFFC520BFE35D00187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = \"<group>\"; };\n\t\t1BEFFFC620BFF7B100187F3F /* Algorithm.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = Algorithm.md; path = ../Algorithm.md; sourceTree = \"<group>\"; };\n\t\t1BEFFFC720BFF7B100187F3F /* CodeOfConduct.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CodeOfConduct.md; path = ../CodeOfConduct.md; sourceTree = \"<group>\"; };\n\t\t1BEFFFC820C000DE00187F3F /* License.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = License.txt; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t1B0A25091EC5E90C00F25F08 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t1B0A251E1EC5EA0500F25F08 /* BlurHashKit.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B2BA1BA1F0E5EC5006057C1 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B49CD171EC4721A006F8E7D /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B6C71F32272451E000D3BB1 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t1B0A250D1EC5E90C00F25F08 /* BlurHashTest */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B0A25231EC5EAA300F25F08 /* Images */,\n\t\t\t\t1B0A250E1EC5E90C00F25F08 /* AppDelegate.swift */,\n\t\t\t\t1B0A25101EC5E90C00F25F08 /* SimpleViewController.swift */,\n\t\t\t\t1BC34D792005818D00A17481 /* AdvancedViewController.swift */,\n\t\t\t\t1BC34D7B200988ED00A17481 /* GeneratedViewController.swift */,\n\t\t\t\t1B0A25121EC5E90C00F25F08 /* Main.storyboard */,\n\t\t\t\t1B0A25151EC5E90C00F25F08 /* Assets.xcassets */,\n\t\t\t\t1B0A25171EC5E90C00F25F08 /* LaunchScreen.storyboard */,\n\t\t\t\t1B0A251A1EC5E90C00F25F08 /* Info.plist */,\n\t\t\t);\n\t\t\tpath = BlurHashTest;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B0A25231EC5EAA300F25F08 /* Images */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B0A25241EC5EAB000F25F08 /* pic1.png */,\n\t\t\t\t1B0A25251EC5EAB000F25F08 /* pic2.png */,\n\t\t\t\t1B0A25261EC5EAB000F25F08 /* pic3.png */,\n\t\t\t\t1B0A25271EC5EAB000F25F08 /* pic4.png */,\n\t\t\t\t1B0A25281EC5EAB000F25F08 /* pic5.png */,\n\t\t\t\t1B19DF5F2015E72B00D8FCD7 /* pic6.png */,\n\t\t\t);\n\t\t\tname = Images;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B1B249220C13E9700D8EF03 /* Python */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B1B250020C13E9700D8EF03 /* src */,\n\t\t\t\t1B1B249520C13E9700D8EF03 /* tests */,\n\t\t\t\t1B1B24FE20C13E9700D8EF03 /* .circleci */,\n\t\t\t\t1B1B249420C13E9700D8EF03 /* dev-requirements.txt */,\n\t\t\t\t1B1B249320C13E9700D8EF03 /* LICENSE */,\n\t\t\t\t1B1B249920C13E9700D8EF03 /* MANIFEST.in */,\n\t\t\t\t1B1B249A20C13E9700D8EF03 /* README.md */,\n\t\t\t\t1B1B249E20C13E9700D8EF03 /* setup.cfg */,\n\t\t\t\t1B1B249B20C13E9700D8EF03 /* setup.py */,\n\t\t\t\t1B1B249D20C13E9700D8EF03 /* tox.ini */,\n\t\t\t);\n\t\t\tname = Python;\n\t\t\tpath = ../Python;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B1B249520C13E9700D8EF03 /* tests */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B1B249620C13E9700D8EF03 /* pic2.png */,\n\t\t\t\t1B1B249720C13E9700D8EF03 /* pic2_bw.png */,\n\t\t\t\t1B1B249820C13E9700D8EF03 /* test_encode.py */,\n\t\t\t);\n\t\t\tpath = tests;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B1B24FE20C13E9700D8EF03 /* .circleci */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B1B24FF20C13E9700D8EF03 /* config.yml */,\n\t\t\t);\n\t\t\tpath = .circleci;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B1B250020C13E9700D8EF03 /* src */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B1B250120C13E9700D8EF03 /* blurhash */,\n\t\t\t\t1B1B250420C13E9700D8EF03 /* build_blurhash.py */,\n\t\t\t\t1B1B250320C13E9700D8EF03 /* encode.c */,\n\t\t\t\t1B1B250520C13E9700D8EF03 /* encode.h */,\n\t\t\t);\n\t\t\tpath = src;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B1B250120C13E9700D8EF03 /* blurhash */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B1B250220C13E9700D8EF03 /* __init__.py */,\n\t\t\t);\n\t\t\tpath = blurhash;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B2BA1B81F0E5E91006057C1 /* C */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B2BA1C41F0E5ED6006057C1 /* blurhash_stb.c */,\n\t\t\t\t1B2BA1C81F0E5EE3006057C1 /* encode.c */,\n\t\t\t\t1B2BA1C91F0E5EE3006057C1 /* encode.h */,\n\t\t\t\t1B2BA1CC1F0E692F006057C1 /* stb_image.h */,\n\t\t\t\t1BEFFFBF20BFDC1600187F3F /* Makefile */,\n\t\t\t\t1B1B250620C1491900D8EF03 /* Readme.md */,\n\t\t\t);\n\t\t\tname = C;\n\t\t\tpath = ../C;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B49CD111EC4721A006F8E7D = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B49CD1D1EC4721A006F8E7D /* Swift */,\n\t\t\t\t1B2BA1B81F0E5E91006057C1 /* C */,\n\t\t\t\t1BEFFFC020BFE05600187F3F /* Kotlin */,\n\t\t\t\t1BEFFFA420BEE66400187F3F /* TypeScript */,\n\t\t\t\t1B1B249220C13E9700D8EF03 /* Python */,\n\t\t\t\t1BEFFFC620BFF7B100187F3F /* Algorithm.md */,\n\t\t\t\t1BEFFFC720BFF7B100187F3F /* CodeOfConduct.md */,\n\t\t\t\t1BEFFFC820C000DE00187F3F /* License.txt */,\n\t\t\t\t1BEFFFC320BFE34800187F3F /* Readme.md */,\n\t\t\t\t1B49CD1C1EC4721A006F8E7D /* Products */,\n\t\t\t\t1B6C71F122724500000D3BB1 /* BlurHashKit copy-Info.plist */,\n\t\t\t);\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B49CD1C1EC4721A006F8E7D /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */,\n\t\t\t\t1B0A250C1EC5E90C00F25F08 /* BlurHashTest.app */,\n\t\t\t\t1B2BA1BD1F0E5EC5006057C1 /* blurhash */,\n\t\t\t\t1B6C71F62272451E000D3BB1 /* libBlurHashKit.a */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B49CD1D1EC4721A006F8E7D /* Swift */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1B0A250D1EC5E90C00F25F08 /* BlurHashTest */,\n\t\t\t\t1BAA606F1FF40A1E00E42DD7 /* BlurHashKit */,\n\t\t\t\t1B49CD261EC47243006F8E7D /* BlurHashEncode.swift */,\n\t\t\t\t1B49CD281EC4724C006F8E7D /* BlurHashDecode.swift */,\n\t\t\t\t1BEFFFC420BFE35300187F3F /* Readme.md */,\n\t\t\t);\n\t\t\tname = Swift;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1BAA606F1FF40A1E00E42DD7 /* BlurHashKit */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */,\n\t\t\t\t1B83DED022D88D1500CAA12F /* EscapeSequences.swift */,\n\t\t\t\t1BAA60741FF40AF200E42DD7 /* FromString.swift */,\n\t\t\t\t1BAA60721FF40AEA00E42DD7 /* ToString.swift */,\n\t\t\t\t1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */,\n\t\t\t\t1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */,\n\t\t\t\t1BC34D7F20098E2F00A17481 /* Generation.swift */,\n\t\t\t\t1BC34D7D20098E1500A17481 /* TupleMaths.swift */,\n\t\t\t\t1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */,\n\t\t\t\t1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */,\n\t\t\t\t1BDE56D02011EC5F00569DCB /* ColourProbes.swift */,\n\t\t\t\t1B49CD1F1EC4721A006F8E7D /* Info.plist */,\n\t\t\t);\n\t\t\tpath = BlurHashKit;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1BEFFFA420BEE66400187F3F /* TypeScript */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1BEFFFA620BEE66400187F3F /* demo */,\n\t\t\t\t1BEFFFB920BEE66400187F3F /* src */,\n\t\t\t\t1BEFFFB520BEE66400187F3F /* webpack.config.js */,\n\t\t\t\t1BEFFFB720BEE66400187F3F /* package.json */,\n\t\t\t\t1BEFFFB820BEE66400187F3F /* tsconfig.json */,\n\t\t\t\t1BEFFFC520BFE35D00187F3F /* Readme.md */,\n\t\t\t);\n\t\t\tname = TypeScript;\n\t\t\tpath = ../TypeScript;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1BEFFFA620BEE66400187F3F /* demo */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1BEFFFA720BEE66400187F3F /* index.html */,\n\t\t\t);\n\t\t\tpath = demo;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1BEFFFB920BEE66400187F3F /* src */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1BEFFFBA20BEE66400187F3F /* decode.ts */,\n\t\t\t\t1BEFFFBB20BEE66400187F3F /* demo.ts */,\n\t\t\t\t1BEFFFBC20BEE66400187F3F /* utils.ts */,\n\t\t\t\t1BEFFFBD20BEE66400187F3F /* index.ts */,\n\t\t\t\t1BEFFFBE20BEE66400187F3F /* base83.ts */,\n\t\t\t);\n\t\t\tpath = src;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1BEFFFC020BFE05600187F3F /* Kotlin */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t1BEFFFC120BFE05600187F3F /* BlurHashDecoder.kt */,\n\t\t\t\t1BEFFFC220BFE33E00187F3F /* Readme.md */,\n\t\t\t);\n\t\t\tname = Kotlin;\n\t\t\tpath = ../Kotlin;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t1B49CD181EC4721A006F8E7D /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t1B0A250B1EC5E90C00F25F08 /* BlurHashTest */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 1B0A251D1EC5E90C00F25F08 /* Build configuration list for PBXNativeTarget \"BlurHashTest\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t1B0A25081EC5E90C00F25F08 /* Sources */,\n\t\t\t\t1B0A25091EC5E90C00F25F08 /* Frameworks */,\n\t\t\t\t1B0A250A1EC5E90C00F25F08 /* Resources */,\n\t\t\t\t1B0A25221EC5EA0500F25F08 /* Embed Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t1B0A25211EC5EA0500F25F08 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = BlurHashTest;\n\t\t\tproductName = BlurHashTest;\n\t\t\tproductReference = 1B0A250C1EC5E90C00F25F08 /* BlurHashTest.app */;\n\t\t\tproductType = \"com.apple.product-type.application\";\n\t\t};\n\t\t1B2BA1BC1F0E5EC5006057C1 /* blurhash */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 1B2BA1C11F0E5EC6006057C1 /* Build configuration list for PBXNativeTarget \"blurhash\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t1B2BA1B91F0E5EC5006057C1 /* Sources */,\n\t\t\t\t1B2BA1BA1F0E5EC5006057C1 /* Frameworks */,\n\t\t\t\t1B2BA1BB1F0E5EC5006057C1 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = blurhash;\n\t\t\tproductName = blurhash;\n\t\t\tproductReference = 1B2BA1BD1F0E5EC5006057C1 /* blurhash */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t1B49CD1A1EC4721A006F8E7D /* BlurHashKit */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 1B49CD231EC4721A006F8E7D /* Build configuration list for PBXNativeTarget \"BlurHashKit\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t1B49CD161EC4721A006F8E7D /* Sources */,\n\t\t\t\t1B49CD171EC4721A006F8E7D /* Frameworks */,\n\t\t\t\t1B49CD181EC4721A006F8E7D /* Headers */,\n\t\t\t\t1B49CD191EC4721A006F8E7D /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = BlurHashKit;\n\t\t\tproductName = Blurhash;\n\t\t\tproductReference = 1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n\t\t1B6C71F52272451E000D3BB1 /* libBlurHashKit */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 1B6C71FA2272451E000D3BB1 /* Build configuration list for PBXNativeTarget \"libBlurHashKit\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t1B6C71F22272451E000D3BB1 /* Sources */,\n\t\t\t\t1B6C71F32272451E000D3BB1 /* Frameworks */,\n\t\t\t\t1B6C71F42272451E000D3BB1 /* CopyFiles */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = libBlurHashKit;\n\t\t\tproductName = libBlurHash;\n\t\t\tproductReference = 1B6C71F62272451E000D3BB1 /* libBlurHashKit.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t1B49CD121EC4721A006F8E7D /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tDefaultBuildSystemTypeForWorkspace = Latest;\n\t\t\t\tLastSwiftUpdateCheck = 1020;\n\t\t\t\tLastUpgradeCheck = 0930;\n\t\t\t\tORGANIZATIONNAME = \"Dag Ågren\";\n\t\t\t\tTargetAttributes = {\n\t\t\t\t\t1B0A250B1EC5E90C00F25F08 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 8.3.2;\n\t\t\t\t\t\tDevelopmentTeam = 6GE6LAAR8V;\n\t\t\t\t\t\tLastSwiftMigration = 0920;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t\t1B2BA1BC1F0E5EC5006057C1 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 8.3.3;\n\t\t\t\t\t\tDevelopmentTeam = 6GE6LAAR8V;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t\t1B49CD1A1EC4721A006F8E7D = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 8.3.2;\n\t\t\t\t\t\tDevelopmentTeam = 6GE6LAAR8V;\n\t\t\t\t\t\tLastSwiftMigration = 0920;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t\t1B6C71F52272451E000D3BB1 = {\n\t\t\t\t\t\tCreatedOnToolsVersion = 10.2;\n\t\t\t\t\t\tDevelopmentTeam = M9KXCWYWYR;\n\t\t\t\t\t\tProvisioningStyle = Automatic;\n\t\t\t\t\t};\n\t\t\t\t};\n\t\t\t};\n\t\t\tbuildConfigurationList = 1B49CD151EC4721A006F8E7D /* Build configuration list for PBXProject \"BlurHash\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 0;\n\t\t\tknownRegions = (\n\t\t\t\tEnglish,\n\t\t\t\ten,\n\t\t\t\tBase,\n\t\t\t);\n\t\t\tmainGroup = 1B49CD111EC4721A006F8E7D;\n\t\t\tproductRefGroup = 1B49CD1C1EC4721A006F8E7D /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t1B49CD1A1EC4721A006F8E7D /* BlurHashKit */,\n\t\t\t\t1B6C71F52272451E000D3BB1 /* libBlurHashKit */,\n\t\t\t\t1B0A250B1EC5E90C00F25F08 /* BlurHashTest */,\n\t\t\t\t1B2BA1BC1F0E5EC5006057C1 /* blurhash */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t1B0A250A1EC5E90C00F25F08 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t1B0A25291EC5EAB000F25F08 /* pic1.png in Resources */,\n\t\t\t\t1B0A252A1EC5EAB000F25F08 /* pic2.png in Resources */,\n\t\t\t\t1B0A252B1EC5EAB000F25F08 /* pic3.png in Resources */,\n\t\t\t\t1B0A252C1EC5EAB000F25F08 /* pic4.png in Resources */,\n\t\t\t\t1B19DF602015E72C00D8FCD7 /* pic6.png in Resources */,\n\t\t\t\t1B0A252D1EC5EAB000F25F08 /* pic5.png in Resources */,\n\t\t\t\t1B0A25191EC5E90C00F25F08 /* LaunchScreen.storyboard in Resources */,\n\t\t\t\t1B0A25161EC5E90C00F25F08 /* Assets.xcassets in Resources */,\n\t\t\t\t1B0A25141EC5E90C00F25F08 /* Main.storyboard in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B49CD191EC4721A006F8E7D /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t1B0A25081EC5E90C00F25F08 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t1BAA606E1FF40A0B00E42DD7 /* BlurHashDecode.swift in Sources */,\n\t\t\t\t1BC34D7A2005818D00A17481 /* AdvancedViewController.swift in Sources */,\n\t\t\t\t1B0A25111EC5E90C00F25F08 /* SimpleViewController.swift in Sources */,\n\t\t\t\t1BAA606D1FF40A0800E42DD7 /* BlurHashEncode.swift in Sources */,\n\t\t\t\t1BC34D7C200988ED00A17481 /* GeneratedViewController.swift in Sources */,\n\t\t\t\t1B0A250F1EC5E90C00F25F08 /* AppDelegate.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B2BA1B91F0E5EC5006057C1 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t1B2BA1CB1F0E5EEA006057C1 /* blurhash_stb.c in Sources */,\n\t\t\t\t1B2BA1CA1F0E5EE3006057C1 /* encode.c in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B49CD161EC4721A006F8E7D /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t1BAA60711FF40A2F00E42DD7 /* BlurHash.swift in Sources */,\n\t\t\t\t1BAA607D1FF422AE00E42DD7 /* ColourSpace.swift in Sources */,\n\t\t\t\t1BC34D7E20098E1500A17481 /* TupleMaths.swift in Sources */,\n\t\t\t\t1BAA60751FF40AF200E42DD7 /* FromString.swift in Sources */,\n\t\t\t\t1BAA607B1FF40D8900E42DD7 /* StringCoding.swift in Sources */,\n\t\t\t\t1BAA60771FF40C4C00E42DD7 /* ToUIImage.swift in Sources */,\n\t\t\t\t1B83DED122D88D1500CAA12F /* EscapeSequences.swift in Sources */,\n\t\t\t\t1BAA60731FF40AEA00E42DD7 /* ToString.swift in Sources */,\n\t\t\t\t1BC34D8020098E2F00A17481 /* Generation.swift in Sources */,\n\t\t\t\t1BDE56D12011EC5F00569DCB /* ColourProbes.swift in Sources */,\n\t\t\t\t1BAA60791FF40C5800E42DD7 /* FromUIImage.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t1B6C71F22272451E000D3BB1 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t1B6C71FE2272453D000D3BB1 /* FromString.swift in Sources */,\n\t\t\t\t1B6C72022272453D000D3BB1 /* Generation.swift in Sources */,\n\t\t\t\t1B6C72032272453D000D3BB1 /* TupleMaths.swift in Sources */,\n\t\t\t\t1B6C72002272453D000D3BB1 /* FromUIImage.swift in Sources */,\n\t\t\t\t1B6C72042272453D000D3BB1 /* ColourSpace.swift in Sources */,\n\t\t\t\t1B6C72052272453D000D3BB1 /* StringCoding.swift in Sources */,\n\t\t\t\t1B83DED222D88D1500CAA12F /* EscapeSequences.swift in Sources */,\n\t\t\t\t1B6C71FF2272453D000D3BB1 /* ToString.swift in Sources */,\n\t\t\t\t1B6C71FD2272453D000D3BB1 /* BlurHash.swift in Sources */,\n\t\t\t\t1B6C72062272453D000D3BB1 /* ColourProbes.swift in Sources */,\n\t\t\t\t1B6C72012272453D000D3BB1 /* ToUIImage.swift in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t1B0A25211EC5EA0500F25F08 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 1B49CD1A1EC4721A006F8E7D /* BlurHashKit */;\n\t\t\ttargetProxy = 1B0A25201EC5EA0500F25F08 /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin PBXVariantGroup section */\n\t\t1B0A25121EC5E90C00F25F08 /* Main.storyboard */ = {\n\t\t\tisa = PBXVariantGroup;\n\t\t\tchildren = (\n\t\t\t\t1B0A25131EC5E90C00F25F08 /* Base */,\n\t\t\t);\n\t\t\tname = Main.storyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t1B0A25171EC5E90C00F25F08 /* LaunchScreen.storyboard */ = {\n\t\t\tisa = PBXVariantGroup;\n\t\t\tchildren = (\n\t\t\t\t1B0A25181EC5E90C00F25F08 /* Base */,\n\t\t\t);\n\t\t\tname = LaunchScreen.storyboard;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXVariantGroup section */\n\n/* Begin XCBuildConfiguration section */\n\t\t1B0A251B1EC5E90C00F25F08 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tDEVELOPMENT_TEAM = 6GE6LAAR8V;\n\t\t\t\tINFOPLIST_FILE = BlurHashTest/Info.plist;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashTest;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t1B0A251C1EC5E90C00F25F08 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;\n\t\t\t\tASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;\n\t\t\t\tDEVELOPMENT_TEAM = 6GE6LAAR8V;\n\t\t\t\tINFOPLIST_FILE = BlurHashTest/Info.plist;\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashTest;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t1B2BA1C21F0E5EC6006057C1 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tDEVELOPMENT_TEAM = 6GE6LAAR8V;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.12;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t1B2BA1C31F0E5EC6006057C1 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCODE_SIGN_IDENTITY = \"-\";\n\t\t\t\tDEVELOPMENT_TEAM = 6GE6LAAR8V;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.12;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t1B49CD211EC4721A006F8E7D /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = dwarf;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tENABLE_TESTABILITY = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_PREPROCESSOR_DEFINITIONS = (\n\t\t\t\t\t\"DEBUG=1\",\n\t\t\t\t\t\"$(inherited)\",\n\t\t\t\t);\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 10.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = YES;\n\t\t\t\tONLY_ACTIVE_ARCH = YES;\n\t\t\t\tOTHER_SWIFT_FLAGS = \"-Xfrontend -warn-long-expression-type-checking=400\";\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tSWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t\tVERSIONING_SYSTEM = \"apple-generic\";\n\t\t\t\tVERSION_INFO_PREFIX = \"\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t1B49CD221EC4721A006F8E7D /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tALWAYS_SEARCH_USER_PATHS = NO;\n\t\t\t\tCLANG_ANALYZER_NONNULL = YES;\n\t\t\t\tCLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++0x\";\n\t\t\t\tCLANG_CXX_LIBRARY = \"libc++\";\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCLANG_ENABLE_OBJC_ARC = YES;\n\t\t\t\tCLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;\n\t\t\t\tCLANG_WARN_BOOL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_COMMA = YES;\n\t\t\t\tCLANG_WARN_CONSTANT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;\n\t\t\t\tCLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;\n\t\t\t\tCLANG_WARN_DOCUMENTATION_COMMENTS = YES;\n\t\t\t\tCLANG_WARN_EMPTY_BODY = YES;\n\t\t\t\tCLANG_WARN_ENUM_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_INFINITE_RECURSION = YES;\n\t\t\t\tCLANG_WARN_INT_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;\n\t\t\t\tCLANG_WARN_OBJC_LITERAL_CONVERSION = YES;\n\t\t\t\tCLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;\n\t\t\t\tCLANG_WARN_RANGE_LOOP_ANALYSIS = YES;\n\t\t\t\tCLANG_WARN_STRICT_PROTOTYPES = YES;\n\t\t\t\tCLANG_WARN_SUSPICIOUS_MOVE = YES;\n\t\t\t\tCLANG_WARN_UNREACHABLE_CODE = YES;\n\t\t\t\tCLANG_WARN__DUPLICATE_METHOD_MATCH = YES;\n\t\t\t\t\"CODE_SIGN_IDENTITY[sdk=iphoneos*]\" = \"iPhone Developer\";\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tCURRENT_PROJECT_VERSION = 1;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tENABLE_NS_ASSERTIONS = NO;\n\t\t\t\tENABLE_STRICT_OBJC_MSGSEND = YES;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu99;\n\t\t\t\tGCC_NO_COMMON_BLOCKS = YES;\n\t\t\t\tGCC_WARN_64_TO_32_BIT_CONVERSION = YES;\n\t\t\t\tGCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;\n\t\t\t\tGCC_WARN_UNDECLARED_SELECTOR = YES;\n\t\t\t\tGCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;\n\t\t\t\tGCC_WARN_UNUSED_FUNCTION = YES;\n\t\t\t\tGCC_WARN_UNUSED_VARIABLE = YES;\n\t\t\t\tIPHONEOS_DEPLOYMENT_TARGET = 10.0;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = NO;\n\t\t\t\tOTHER_SWIFT_FLAGS = \"-Xfrontend -warn-long-expression-type-checking=400\";\n\t\t\t\tSDKROOT = iphoneos;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Owholemodule\";\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t\tVALIDATE_PRODUCT = YES;\n\t\t\t\tVERSIONING_SYSTEM = \"apple-generic\";\n\t\t\t\tVERSION_INFO_PREFIX = \"\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t1B49CD241EC4721A006F8E7D /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"\";\n\t\t\t\tDEFINES_MODULE = YES;\n\t\t\t\tDEVELOPMENT_TEAM = 6GE6LAAR8V;\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tDYLIB_INSTALL_NAME_BASE = \"@rpath\";\n\t\t\t\tINFOPLIST_FILE = BlurHashKit/Info.plist;\n\t\t\t\tINSTALL_PATH = \"$(LOCAL_LIBRARY_DIR)/Frameworks\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashKit;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_OPTIMIZATION_LEVEL = \"-Onone\";\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t1B49CD251EC4721A006F8E7D /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_ENABLE_MODULES = YES;\n\t\t\t\tCODE_SIGN_IDENTITY = \"\";\n\t\t\t\tDEFINES_MODULE = YES;\n\t\t\t\tDEVELOPMENT_TEAM = 6GE6LAAR8V;\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tDYLIB_INSTALL_NAME_BASE = \"@rpath\";\n\t\t\t\tINFOPLIST_FILE = BlurHashKit/Info.plist;\n\t\t\t\tINSTALL_PATH = \"$(LOCAL_LIBRARY_DIR)/Frameworks\";\n\t\t\t\tLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks @loader_path/Frameworks\";\n\t\t\t\tPRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashKit;\n\t\t\t\tPRODUCT_NAME = \"$(TARGET_NAME)\";\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_VERSION = 4.0;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t1B6C71FB2272451E000D3BB1 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = M9KXCWYWYR;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tMTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = BlurHashKit;\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t1B6C71FC2272451E000D3BB1 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCLANG_CXX_LANGUAGE_STANDARD = \"gnu++14\";\n\t\t\t\tCLANG_ENABLE_OBJC_WEAK = YES;\n\t\t\t\tCLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;\n\t\t\t\tCODE_SIGN_IDENTITY = \"iPhone Developer\";\n\t\t\t\tCODE_SIGN_STYLE = Automatic;\n\t\t\t\tDEVELOPMENT_TEAM = M9KXCWYWYR;\n\t\t\t\tGCC_C_LANGUAGE_STANDARD = gnu11;\n\t\t\t\tMTL_FAST_MATH = YES;\n\t\t\t\tOTHER_LDFLAGS = \"-ObjC\";\n\t\t\t\tPRODUCT_NAME = BlurHashKit;\n\t\t\t\tSKIP_INSTALL = YES;\n\t\t\t\tSWIFT_VERSION = 5.0;\n\t\t\t\tTARGETED_DEVICE_FAMILY = \"1,2\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t1B0A251D1EC5E90C00F25F08 /* Build configuration list for PBXNativeTarget \"BlurHashTest\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t1B0A251B1EC5E90C00F25F08 /* Debug */,\n\t\t\t\t1B0A251C1EC5E90C00F25F08 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t1B2BA1C11F0E5EC6006057C1 /* Build configuration list for PBXNativeTarget \"blurhash\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t1B2BA1C21F0E5EC6006057C1 /* Debug */,\n\t\t\t\t1B2BA1C31F0E5EC6006057C1 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t1B49CD151EC4721A006F8E7D /* Build configuration list for PBXProject \"BlurHash\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t1B49CD211EC4721A006F8E7D /* Debug */,\n\t\t\t\t1B49CD221EC4721A006F8E7D /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t1B49CD231EC4721A006F8E7D /* Build configuration list for PBXNativeTarget \"BlurHashKit\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t1B49CD241EC4721A006F8E7D /* Debug */,\n\t\t\t\t1B49CD251EC4721A006F8E7D /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t1B6C71FA2272451E000D3BB1 /* Build configuration list for PBXNativeTarget \"libBlurHashKit\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t1B6C71FB2272451E000D3BB1 /* Debug */,\n\t\t\t\t1B6C71FC2272451E000D3BB1 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 1B49CD121EC4721A006F8E7D /* Project object */;\n}\n"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n   version = \"1.0\">\n   <FileRef\n      location = \"self:Blurhash.xcodeproj\">\n   </FileRef>\n</Workspace>\n"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/project.xcworkspace/xcshareddata/BlurHash.xcscmblueprint",
    "content": "{\n  \"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey\" : \"8D94AD06B7E57997939C2DBED75F327A184CF7B8\",\n  \"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey\" : {\n\n  },\n  \"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey\" : {\n    \"8D94AD06B7E57997939C2DBED75F327A184CF7B8\" : 9223372036854775807\n  },\n  \"DVTSourceControlWorkspaceBlueprintIdentifierKey\" : \"78AF9E08-7F50-4648-8F5B-F7536E5EB55E\",\n  \"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey\" : {\n    \"8D94AD06B7E57997939C2DBED75F327A184CF7B8\" : \"BlurHash\\/\"\n  },\n  \"DVTSourceControlWorkspaceBlueprintNameKey\" : \"BlurHash\",\n  \"DVTSourceControlWorkspaceBlueprintVersion\" : 204,\n  \"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey\" : \"BlurHash.xcodeproj\",\n  \"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey\" : [\n    {\n      \"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey\" : \"https:\\/\\/github.com\\/creditornot\\/BlurHash.git\",\n      \"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey\" : \"com.apple.dt.Xcode.sourcecontrol.Git\",\n      \"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey\" : \"8D94AD06B7E57997939C2DBED75F327A184CF7B8\"\n    },\n    {\n      \"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey\" : \"https:\\/\\/github.com\\/creditornot\\/BlurHash.git\",\n      \"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey\" : \"com.apple.dt.Xcode.sourcecontrol.Git\",\n      \"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey\" : \"8D94AD06B7E57997939C2DBED75F327A184CF7B8\"\n    }\n  ]\n}"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>IDEDidComputeMac32BitWarning</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/xcshareddata/xcschemes/BlurHashKit.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1020\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"1B49CD1A1EC4721A006F8E7D\"\n               BuildableName = \"BlurHashKit.framework\"\n               BlueprintName = \"BlurHashKit\"\n               ReferencedContainer = \"container:BlurHash.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B49CD1A1EC4721A006F8E7D\"\n            BuildableName = \"BlurHashKit.framework\"\n            BlueprintName = \"BlurHashKit\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B49CD1A1EC4721A006F8E7D\"\n            BuildableName = \"BlurHashKit.framework\"\n            BlueprintName = \"BlurHashKit\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/xcshareddata/xcschemes/BlurHashTest.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1020\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"1B0A250B1EC5E90C00F25F08\"\n               BuildableName = \"BlurHashTest.app\"\n               BlueprintName = \"BlurHashTest\"\n               ReferencedContainer = \"container:BlurHash.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B0A250B1EC5E90C00F25F08\"\n            BuildableName = \"BlurHashTest.app\"\n            BlueprintName = \"BlurHashTest\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n      <Testables>\n      </Testables>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <BuildableProductRunnable\n         runnableDebuggingMode = \"0\">\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B0A250B1EC5E90C00F25F08\"\n            BuildableName = \"BlurHashTest.app\"\n            BlueprintName = \"BlurHashTest\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </BuildableProductRunnable>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <BuildableProductRunnable\n         runnableDebuggingMode = \"0\">\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B0A250B1EC5E90C00F25F08\"\n            BuildableName = \"BlurHashTest.app\"\n            BlueprintName = \"BlurHashTest\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </BuildableProductRunnable>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/xcshareddata/xcschemes/blurhash.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1020\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"1B2BA1BC1F0E5EC5006057C1\"\n               BuildableName = \"blurhash\"\n               BlueprintName = \"blurhash\"\n               ReferencedContainer = \"container:BlurHash.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B2BA1BC1F0E5EC5006057C1\"\n            BuildableName = \"blurhash\"\n            BlueprintName = \"blurhash\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <BuildableProductRunnable\n         runnableDebuggingMode = \"0\">\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B2BA1BC1F0E5EC5006057C1\"\n            BuildableName = \"blurhash\"\n            BlueprintName = \"blurhash\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </BuildableProductRunnable>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <BuildableProductRunnable\n         runnableDebuggingMode = \"0\">\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B2BA1BC1F0E5EC5006057C1\"\n            BuildableName = \"blurhash\"\n            BlueprintName = \"blurhash\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </BuildableProductRunnable>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "Swift/BlurHash.xcodeproj/xcshareddata/xcschemes/libBlurHashKit.xcscheme",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n   LastUpgradeVersion = \"1020\"\n   version = \"1.3\">\n   <BuildAction\n      parallelizeBuildables = \"YES\"\n      buildImplicitDependencies = \"YES\">\n      <BuildActionEntries>\n         <BuildActionEntry\n            buildForTesting = \"YES\"\n            buildForRunning = \"YES\"\n            buildForProfiling = \"YES\"\n            buildForArchiving = \"YES\"\n            buildForAnalyzing = \"YES\">\n            <BuildableReference\n               BuildableIdentifier = \"primary\"\n               BlueprintIdentifier = \"1B6C71F52272451E000D3BB1\"\n               BuildableName = \"libBlurHashKit.a\"\n               BlueprintName = \"libBlurHashKit\"\n               ReferencedContainer = \"container:BlurHash.xcodeproj\">\n            </BuildableReference>\n         </BuildActionEntry>\n      </BuildActionEntries>\n   </BuildAction>\n   <TestAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\">\n      <Testables>\n      </Testables>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </TestAction>\n   <LaunchAction\n      buildConfiguration = \"Debug\"\n      selectedDebuggerIdentifier = \"Xcode.DebuggerFoundation.Debugger.LLDB\"\n      selectedLauncherIdentifier = \"Xcode.DebuggerFoundation.Launcher.LLDB\"\n      launchStyle = \"0\"\n      useCustomWorkingDirectory = \"NO\"\n      ignoresPersistentStateOnLaunch = \"NO\"\n      debugDocumentVersioning = \"YES\"\n      debugServiceExtension = \"internal\"\n      allowLocationSimulation = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B6C71F52272451E000D3BB1\"\n            BuildableName = \"libBlurHashKit.a\"\n            BlueprintName = \"libBlurHashKit\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n      <AdditionalOptions>\n      </AdditionalOptions>\n   </LaunchAction>\n   <ProfileAction\n      buildConfiguration = \"Release\"\n      shouldUseLaunchSchemeArgsEnv = \"YES\"\n      savedToolIdentifier = \"\"\n      useCustomWorkingDirectory = \"NO\"\n      debugDocumentVersioning = \"YES\">\n      <MacroExpansion>\n         <BuildableReference\n            BuildableIdentifier = \"primary\"\n            BlueprintIdentifier = \"1B6C71F52272451E000D3BB1\"\n            BuildableName = \"libBlurHashKit.a\"\n            BlueprintName = \"libBlurHashKit\"\n            ReferencedContainer = \"container:BlurHash.xcodeproj\">\n         </BuildableReference>\n      </MacroExpansion>\n   </ProfileAction>\n   <AnalyzeAction\n      buildConfiguration = \"Debug\">\n   </AnalyzeAction>\n   <ArchiveAction\n      buildConfiguration = \"Release\"\n      revealArchiveInOrganizer = \"YES\">\n   </ArchiveAction>\n</Scheme>\n"
  },
  {
    "path": "Swift/BlurHashDecode.swift",
    "content": "import UIKit\n\nextension UIImage {\n    public convenience init?(blurHash: String, size: CGSize, punch: Float = 1) {\n        guard blurHash.count >= 6 else { return nil }\n\n\t\tlet sizeFlag = String(blurHash[0]).decode83()\n\t\tlet numY = (sizeFlag / 9) + 1\n\t\tlet numX = (sizeFlag % 9) + 1\n\n\t\tlet quantisedMaximumValue = String(blurHash[1]).decode83()\n        let maximumValue = Float(quantisedMaximumValue + 1) / 166\n\n        guard blurHash.count == 4 + 2 * numX * numY else { return nil }\n\n        let colours: [(Float, Float, Float)] = (0 ..< numX * numY).map { i in\n            if i == 0 {\n\t\t\t\tlet value = String(blurHash[2 ..< 6]).decode83()\n                return decodeDC(value)\n            } else {\n                let value = String(blurHash[4 + i * 2 ..< 4 + i * 2 + 2]).decode83()\n                return decodeAC(value, maximumValue: maximumValue * punch)\n            }\n        }\n\n        let width = Int(size.width)\n        let height = Int(size.height)\n        let bytesPerRow = width * 3\n        guard let data = CFDataCreateMutable(kCFAllocatorDefault, bytesPerRow * height) else { return nil }\n        CFDataSetLength(data, bytesPerRow * height)\n        guard let pixels = CFDataGetMutableBytePtr(data) else { return nil }\n\n        for y in 0 ..< height {\n            for x in 0 ..< width {\n                var r: Float = 0\n                var g: Float = 0\n                var b: Float = 0\n\n                for j in 0 ..< numY {\n                    for i in 0 ..< numX {\n                        let basis = cos(Float.pi * Float(x) * Float(i) / Float(width)) * cos(Float.pi * Float(y) * Float(j) / Float(height))\n                        let colour = colours[i + j * numX]\n                        r += colour.0 * basis\n                        g += colour.1 * basis\n                        b += colour.2 * basis\n                    }\n                }\n\n                let intR = UInt8(linearTosRGB(r))\n                let intG = UInt8(linearTosRGB(g))\n                let intB = UInt8(linearTosRGB(b))\n\n                pixels[3 * x + 0 + y * bytesPerRow] = intR\n                pixels[3 * x + 1 + y * bytesPerRow] = intG\n                pixels[3 * x + 2 + y * bytesPerRow] = intB\n            }\n        }\n\n        let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue)\n\n        guard let provider = CGDataProvider(data: data) else { return nil }\n        guard let cgImage = CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 24, bytesPerRow: bytesPerRow,\n        space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: bitmapInfo, provider: provider, decode: nil, shouldInterpolate: true, intent: .defaultIntent) else { return nil }\n\n        self.init(cgImage: cgImage)\n    }\n}\n\nprivate func decodeDC(_ value: Int) -> (Float, Float, Float) {\n    let intR = value >> 16\n    let intG = (value >> 8) & 255\n    let intB = value & 255\n    return (sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB))\n}\n\nprivate func decodeAC(_ value: Int, maximumValue: Float) -> (Float, Float, Float) {\n\tlet quantR = value / (19 * 19)\n\tlet quantG = (value / 19) % 19\n\tlet quantB = value % 19\n\n\tlet rgb = (\n\t\tsignPow((Float(quantR) - 9) / 9, 2) * maximumValue,\n\t\tsignPow((Float(quantG) - 9) / 9, 2) * maximumValue,\n\t\tsignPow((Float(quantB) - 9) / 9, 2) * maximumValue\n\t)\n\n\treturn rgb\n}\n\nprivate func signPow(_ value: Float, _ exp: Float) -> Float {\n    return copysign(pow(abs(value), exp), value)\n}\n\nprivate func linearTosRGB(_ value: Float) -> Int {\n    let v = max(0, min(1, value))\n    if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }\n    else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }\n}\n\nprivate func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {\n    let v = Float(Int64(value)) / 255\n    if v <= 0.04045 { return v / 12.92 }\n    else { return pow((v + 0.055) / 1.055, 2.4) }\n}\n\nprivate let encodeCharacters: [String] = {\n    return \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~\".map { String($0) }\n}()\n\nprivate let decodeCharacters: [String: Int] = {\n\tvar dict: [String: Int] = [:]\n\tfor (index, character) in encodeCharacters.enumerated() {\n\t\tdict[character] = index\n\t}\n\treturn dict\n}()\n\nextension String {\n\tfunc decode83() -> Int {\n\t\tvar value: Int = 0\n\t\tfor character in self {\n\t\t\tif let digit = decodeCharacters[String(character)] {\n\t\t\t\tvalue = value * 83 + digit\n\t\t\t}\n\t\t}\n\t\treturn value\n\t}\n}\n\nprivate extension String {\n\tsubscript (offset: Int) -> Character {\n\t\treturn self[index(startIndex, offsetBy: offset)]\n\t}\n\n\tsubscript (bounds: CountableClosedRange<Int>) -> Substring {\n\t\tlet start = index(startIndex, offsetBy: bounds.lowerBound)\n\t\tlet end = index(startIndex, offsetBy: bounds.upperBound)\n\t\treturn self[start...end]\n\t}\n\n\tsubscript (bounds: CountableRange<Int>) -> Substring {\n\t\tlet start = index(startIndex, offsetBy: bounds.lowerBound)\n\t\tlet end = index(startIndex, offsetBy: bounds.upperBound)\n\t\treturn self[start..<end]\n\t}\n}\n"
  },
  {
    "path": "Swift/BlurHashEncode.swift",
    "content": "import UIKit\n\nextension UIImage {\n    public func blurHash(numberOfComponents components: (Int, Int)) -> String? {\n\t\tlet pixelWidth = Int(round(size.width * scale))\n\t\tlet pixelHeight = Int(round(size.height * scale))\n\n\t\tlet context = CGContext(\n\t\t\tdata: nil,\n\t\t\twidth: pixelWidth,\n\t\t\theight: pixelHeight,\n\t\t\tbitsPerComponent: 8,\n\t\t\tbytesPerRow: pixelWidth * 4,\n\t\t\tspace: CGColorSpace(name: CGColorSpace.sRGB)!,\n\t\t\tbitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue\n\t\t)!\n\t\tcontext.scaleBy(x: scale, y: -scale)\n\t\tcontext.translateBy(x: 0, y: -size.height)\n\n\t\tUIGraphicsPushContext(context)\n\t\tdraw(at: .zero)\n\t\tUIGraphicsPopContext()\n\n\t\tguard let cgImage = context.makeImage(),\n\t\tlet dataProvider = cgImage.dataProvider,\n\t\tlet data = dataProvider.data,\n\t\tlet pixels = CFDataGetBytePtr(data) else {\n\t\t\tassertionFailure(\"Unexpected error!\")\n\t\t\treturn nil\n\t\t}\n\n        let width = cgImage.width\n        let height = cgImage.height\n        let bytesPerRow = cgImage.bytesPerRow\n\n        var factors: [(Float, Float, Float)] = []\n        for y in 0 ..< components.1 {\n            for x in 0 ..< components.0 {\n                let normalisation: Float = (x == 0 && y == 0) ? 1 : 2\n                let factor = multiplyBasisFunction(pixels: pixels, width: width, height: height, bytesPerRow: bytesPerRow, bytesPerPixel: cgImage.bitsPerPixel / 8, pixelOffset: 0) {\n                    normalisation * cos(Float.pi * Float(x) * $0 / Float(width)) as Float * cos(Float.pi * Float(y) * $1 / Float(height)) as Float\n                }\n                factors.append(factor)\n            }\n        }\n\n        let dc = factors.first!\n        let ac = factors.dropFirst()\n\n        var hash = \"\"\n\n\t\tlet sizeFlag = (components.0 - 1) + (components.1 - 1) * 9\n\t\thash += sizeFlag.encode83(length: 1)\n\n\t\tlet maximumValue: Float\n\t\tif ac.count > 0 {\n\t\t\tlet actualMaximumValue = ac.map({ max(abs($0.0), abs($0.1), abs($0.2)) }).max()!\n\t\t\tlet quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5))))\n\t\t\tmaximumValue = Float(quantisedMaximumValue + 1) / 166\n\t\t\thash += quantisedMaximumValue.encode83(length: 1)\n\t\t} else {\n\t\t\tmaximumValue = 1\n\t\t\thash += 0.encode83(length: 1)\n\t\t}\n\n        hash += encodeDC(dc).encode83(length: 4)\n\n        for factor in ac {\n            hash += encodeAC(factor, maximumValue: maximumValue).encode83(length: 2)\n        }\n\n        return hash\n    }\n\n    private func multiplyBasisFunction(pixels: UnsafePointer<UInt8>, width: Int, height: Int, bytesPerRow: Int, bytesPerPixel: Int, pixelOffset: Int, basisFunction: (Float, Float) -> Float) -> (Float, Float, Float) {\n        var r: Float = 0\n        var g: Float = 0\n        var b: Float = 0\n\n        let buffer = UnsafeBufferPointer(start: pixels, count: height * bytesPerRow)\n\n        for x in 0 ..< width {\n            for y in 0 ..< height {\n                let basis = basisFunction(Float(x), Float(y))\n                r += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 0 + y * bytesPerRow])\n                g += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 1 + y * bytesPerRow])\n                b += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 2 + y * bytesPerRow])\n            }\n        }\n\n        let scale = 1 / Float(width * height)\n\n        return (r * scale, g * scale, b * scale)\n    }\n}\n\nprivate func encodeDC(_ value: (Float, Float, Float)) -> Int {\n    let roundedR = linearTosRGB(value.0)\n    let roundedG = linearTosRGB(value.1)\n    let roundedB = linearTosRGB(value.2)\n    return (roundedR << 16) + (roundedG << 8) + roundedB\n}\n\nprivate func encodeAC(_ value: (Float, Float, Float), maximumValue: Float) -> Int {\n\tlet quantR = Int(max(0, min(18, floor(signPow(value.0 / maximumValue, 0.5) * 9 + 9.5))))\n\tlet quantG = Int(max(0, min(18, floor(signPow(value.1 / maximumValue, 0.5) * 9 + 9.5))))\n\tlet quantB = Int(max(0, min(18, floor(signPow(value.2 / maximumValue, 0.5) * 9 + 9.5))))\n\n\treturn quantR * 19 * 19 + quantG * 19 + quantB\n}\n\nprivate func signPow(_ value: Float, _ exp: Float) -> Float {\n    return copysign(pow(abs(value), exp), value)\n}\n\nprivate func linearTosRGB(_ value: Float) -> Int {\n    let v = max(0, min(1, value))\n    if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }\n    else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }\n}\n\nprivate func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {\n    let v = Float(Int64(value)) / 255\n    if v <= 0.04045 { return v / 12.92 }\n    else { return pow((v + 0.055) / 1.055, 2.4) }\n}\n\nprivate let encodeCharacters: [String] = {\n    return \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~\".map { String($0) }\n}()\n\nextension BinaryInteger {\n\tfunc encode83(length: Int) -> String {\n\t\tvar result = \"\"\n\t\tfor i in 1 ... length {\n\t\t\tlet digit = (Int(self) / pow(83, length - i)) % 83\n\t\t\tresult += encodeCharacters[Int(digit)]\n\t\t}\n\t\treturn result\n\t}\n}\n\nprivate func pow(_ base: Int, _ exponent: Int) -> Int {\n    return (0 ..< exponent).reduce(1) { value, _ in value * base }\n}\n"
  },
  {
    "path": "Swift/BlurHashKit/BlurHash.swift",
    "content": "import Foundation\n\npublic struct BlurHash {\n\tpublic let components: [[(Float, Float, Float)]]\n\n\tpublic var numberOfHorizontalComponents: Int { return components.first!.count }\n\tpublic var numberOfVerticalComponents: Int { return components.count }\n\n\tpublic init(components: [[(Float, Float, Float)]]) {\n\t\tself.components = components\n\t}\n\n\tpublic func punch(_ factor: Float) -> BlurHash {\n\t\treturn BlurHash(components: components.enumerated().map { (j, horizontalComponents) -> [(Float, Float, Float)] in\n\t\t\treturn horizontalComponents.enumerated().map { (i, component) -> (Float, Float, Float) in\n\t\t\t\tif i == 0 && j == 0 {\n\t\t\t\t\treturn component\n\t\t\t\t} else {\n\t\t\t\t\treturn component * factor\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n}\n\npublic func +(lhs: BlurHash, rhs: BlurHash) throws -> BlurHash {\n\treturn BlurHash(components: paddedZip(lhs.components, rhs.components, [], []).map {\n\t\tpaddedZip($0.0, $0.1, (0, 0, 0) as (Float, Float, Float), (0, 0, 0) as (Float, Float, Float)).map { ($0.0.0 + $0.1.0, $0.0.1 + $0.1.1, $0.0.2 + $0.1.2) }\n\t})\n}\n\npublic func -(lhs: BlurHash, rhs: BlurHash) throws -> BlurHash {\n\treturn BlurHash(components: paddedZip(lhs.components, rhs.components, [], []).map {\n\t\tpaddedZip($0.0, $0.1, (0, 0, 0) as (Float, Float, Float), (0, 0, 0) as (Float, Float, Float)).map { ($0.0.0 - $0.1.0, $0.0.1 - $0.1.1, $0.0.2 - $0.1.2) }\n\t})\n}\n\nprivate func paddedZip<Collection1, Collection2>(_ collection1: Collection1, _ collection2: Collection2, _ padding1: Collection1.Element, _ padding2: Collection2.Element) -> Zip2Sequence<[Collection1.Element], [Collection2.Element]> where Collection1: Collection, Collection2: Collection {\n\tif collection1.count < collection2.count {\n\t\tlet padded = collection1 + Array(repeating: padding1, count: collection2.count - collection1.count)\n\t\treturn zip(padded, Array(collection2))\n\t} else if collection2.count < collection1.count {\n\t\tlet padded = collection2 + Array(repeating: padding2, count: collection1.count - collection2.count)\n\t\treturn zip(Array(collection1), padded)\n\t} else {\n\t\treturn zip(Array(collection1), Array(collection2))\n\t}\n\n}\n\n"
  },
  {
    "path": "Swift/BlurHashKit/ColourProbes.swift",
    "content": "import Foundation\n\nextension BlurHash {\n    public func linearRGB(atX x: Float) -> (Float, Float, Float) {\n        return components[0].enumerated().reduce((0, 0, 0)) { (sum, horizontalEnumerated) -> (Float, Float, Float) in\n            let (i, component) = horizontalEnumerated\n            return sum + component * cos(Float.pi * Float(i) * x)\n        }\n    }\n\n    public func linearRGB(atY y: Float) -> (Float, Float, Float) {\n        return components.enumerated().reduce((0, 0, 0)) { (sum, verticalEnumerated) in\n            let (j, horizontalComponents) = verticalEnumerated\n            return sum + horizontalComponents[0] * cos(Float.pi * Float(j) * y)\n        }\n    }\n\n    public func linearRGB(at position: (Float, Float)) -> (Float, Float, Float) {\n        return components.enumerated().reduce((0, 0, 0)) { (sum, verticalEnumerated) in\n            let (j, horizontalComponents) = verticalEnumerated\n            return horizontalComponents.enumerated().reduce(sum) { (sum, horizontalEnumerated) in\n                let (i, component) = horizontalEnumerated\n                return sum + component * cos(Float.pi * Float(i) * position.0) * cos(Float.pi * Float(j) * position.1)\n            }\n        }\n    }\n\n    public func linearRGB(from upperLeft: (Float, Float), to lowerRight: (Float, Float)) -> (Float, Float, Float) {\n        return components.enumerated().reduce((0, 0, 0)) { (sum, verticalEnumerated) in\n            let (j, horizontalComponents) = verticalEnumerated\n            return horizontalComponents.enumerated().reduce(sum) { (sum, horizontalEnumerated) in\n                let (i, component) = horizontalEnumerated\n                let horizontalAverage: Float = i == 0 ? 1 : (sin(Float.pi * Float(i) * lowerRight.0) - sin(Float.pi * Float(i) * upperLeft.0)) / (Float(i) * Float.pi * (lowerRight.0 - upperLeft.0))\n                let veritcalAverage: Float = j == 0 ? 1 : (sin(Float.pi * Float(j) * lowerRight.1) - sin(Float.pi * Float(j) * upperLeft.1)) / (Float(j) * Float.pi * (lowerRight.1 - upperLeft.1))\n                return sum + component * horizontalAverage * veritcalAverage\n            }\n        }\n    }\n\n    public func linearRGB(at upperLeft: (Float, Float), size: (Float, Float)) -> (Float, Float, Float) {\n        return linearRGB(from: upperLeft, to: (upperLeft.0 + size.0, upperLeft.1 + size.1))\n    }\n\n    public var averageLinearRGB: (Float, Float, Float) {\n        return components[0][0]\n    }\n\n    public var leftEdgeLinearRGB: (Float, Float, Float) { return linearRGB(atX: 0) }\n    public var rightEdgeLinearRGB: (Float, Float, Float) { return linearRGB(atX: 1) }\n    public var topEdgeLinearRGB: (Float, Float, Float) { return linearRGB(atY: 0) }\n    public var bottomEdgeLinearRGB: (Float, Float, Float) { return linearRGB(atY: 1) }\n    public var topLeftCornerLinearRGB: (Float, Float, Float) { return linearRGB(at: (0, 0)) }\n    public var topRightCornerLinearRGB: (Float, Float, Float) { return linearRGB(at: (1, 0)) }\n    public var bottomLeftCornerLinearRGB: (Float, Float, Float) { return linearRGB(at: (0, 1)) }\n    public var bottomRightCornerLinearRGB: (Float, Float, Float) { return linearRGB(at: (1, 1)) }\n}\n\nextension BlurHash {\n    public func isDark(linearRGB rgb: (Float, Float, Float), threshold: Float = 0.3) -> Bool {\n        return rgb.0 * 0.299 + rgb.1 * 0.587 + rgb.2 * 0.114 < threshold\n    }\n\n    public func isDark(threshold: Float = 0.3) -> Bool { return isDark(linearRGB: averageLinearRGB, threshold: threshold) }\n\n    public func isDark(atX x: Float, threshold: Float = 0.3) -> Bool { return isDark(linearRGB: linearRGB(atX: x), threshold: threshold) }\n    public func isDark(atY y: Float, threshold: Float = 0.3) -> Bool { return isDark(linearRGB: linearRGB(atY: y), threshold: threshold) }\n    public func isDark(at position: (Float, Float), threshold: Float = 0.3) -> Bool { return isDark(linearRGB: linearRGB(at: position), threshold: threshold) }\n    public func isDark(from upperLeft: (Float, Float), to lowerRight: (Float, Float), threshold: Float = 0.3) -> Bool { return isDark(linearRGB: linearRGB(from: upperLeft, to: lowerRight), threshold: threshold) }\n    public func isDark(at upperLeft: (Float, Float), size: (Float, Float), threshold: Float = 0.3) -> Bool { return isDark(linearRGB: linearRGB(at: upperLeft, size: size), threshold: threshold) }\n\n    public var isLeftEdgeDark: Bool { return isDark(atX: 0) }\n    public var isRightEdgeDark: Bool { return isDark(atX: 1) }\n    public var isTopEdgeDark: Bool { return isDark(atY: 0) }\n    public var isBottomEdgeDark: Bool { return isDark(atY: 1) }\n    public var isTopLeftCornerDark: Bool { return isDark(at: (0, 0)) }\n    public var isTopRightCornerDark: Bool { return isDark(at: (1, 0)) }\n    public var isBottomLeftCornerDark: Bool { return isDark(at: (0, 1)) }\n    public var isBottomRightCornerDark: Bool { return isDark(at: (1, 1)) }\n}\n"
  },
  {
    "path": "Swift/BlurHashKit/ColourSpace.swift",
    "content": "import Foundation\n\nfunc signPow(_ value: Float, _ exp: Float) -> Float {\n\treturn copysign(pow(abs(value), exp), value)\n}\n\nfunc linearTosRGB(_ value: Float) -> Int {\n\tlet v = max(0, min(1, value))\n\tif v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }\n\telse { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }\n}\n\nfunc sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {\n\tlet v = Float(Int64(value)) / 255\n\tif v <= 0.04045 { return v / 12.92 }\n\telse { return pow((v + 0.055) / 1.055, 2.4) }\n}\n"
  },
  {
    "path": "Swift/BlurHashKit/EscapeSequences.swift",
    "content": "import Foundation\n\nextension BlurHash {\n    var twoByThreeEscapeSequence: String {\n        let areas: [(from: (Float, Float), to: (Float, Float))] = [\n            (from: (0, 0), to: (0.333, 0.5)),\n            (from: (0, 0.5), to: (0.333, 1.0)),\n            (from: (0.333, 0), to: (0.666, 0.5)),\n            (from: (0.333, 0.5), to: (0.666, 1.0)),\n            (from: (0.666, 0), to: (1.0, 0.5)),\n            (from: (0.666, 0.5), to: (1.0, 1.0)),\n        ]\n\n        let rgb: [(Float, Float, Float)] = areas.map { area in\n            linearRGB(from: area.from, to: area.to)\n        }\n\n        let maxRgb: (Float, Float, Float) = rgb.reduce((-Float.infinity, -Float.infinity, -Float.infinity), max)\n        let minRgb: (Float, Float, Float) = rgb.reduce((Float.infinity, Float.infinity, Float.infinity), min)\n\n        let positiveScale: (Float, Float, Float) = ((1, 1, 1) - averageLinearRGB) / (maxRgb - averageLinearRGB)\n        let negativeScale: (Float, Float, Float) = averageLinearRGB / (averageLinearRGB - minRgb)\n        let scale: (Float, Float, Float) = min(positiveScale, negativeScale)\n\n        let scaledRgb: [(Float, Float, Float)] = rgb.map { rgb in\n            return (rgb - averageLinearRGB) * scale + averageLinearRGB\n        }\n\n        let c = scaledRgb.map { rgb in\n            return (linearTosRGB(rgb.0) / 51) * 36 + (linearTosRGB(rgb.1) / 51) * 6 + (linearTosRGB(rgb.2) / 51) + 16\n        }\n\n        return \"\\u{1b}[38;5;\\(c[1]);48;5;\\(c[0])m▄\\u{1b}[38;5;\\(c[3]);48;5;\\(c[2])m▄\\u{1b}[38;5;\\(c[5]);48;5;\\(c[4])m▄\\u{1b}[m\"\n    }\n}\n\n"
  },
  {
    "path": "Swift/BlurHashKit/FromString.swift",
    "content": "import Foundation\n\npublic extension BlurHash {\n\tinit?(string: String) {\n\t\tguard string.count >= 6 else { return nil }\n\n\t\tlet sizeFlag = String(string[0]).decode83()\n\t\tlet numberOfHorizontalComponents = (sizeFlag % 9) + 1\n\t\tlet numberOfVerticalComponents = (sizeFlag / 9) + 1\n\n\t\tlet quantisedMaximumValue = String(string[1]).decode83()\n\t\tlet maximumValue = Float(quantisedMaximumValue + 1) / 166\n\n\t\tguard string.count == 4 + 2 * numberOfHorizontalComponents * numberOfVerticalComponents else { return nil }\n\n\t\tself.components = (0 ..< numberOfVerticalComponents).map { j in\n\t\t\treturn (0 ..< numberOfHorizontalComponents).map { i in\n\t\t\t\tif i == 0 && j == 0 {\n\t\t\t\t\tlet value = String(string[2 ..< 6]).decode83()\n\t\t\t\t\treturn BlurHash.decodeDC(value)\n\t\t\t\t} else {\n\t\t\t\t\tlet index = i + j * numberOfHorizontalComponents\n\t\t\t\t\tlet value = String(string[4 + index * 2 ..< 4 + index * 2 + 2]).decode83()\n\t\t\t\t\treturn BlurHash.decodeAC(value, maximumValue: maximumValue)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static func decodeDC(_ value: Int) -> (Float, Float, Float) {\n\t\tlet intR = value >> 16\n\t\tlet intG = (value >> 8) & 255\n\t\tlet intB = value & 255\n\t\treturn (sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB))\n\t}\n\n\tprivate static func decodeAC(_ value: Int, maximumValue: Float) -> (Float, Float, Float) {\n\t\tlet quantR = value / (19 * 19)\n\t\tlet quantG = (value / 19) % 19\n\t\tlet quantB = value % 19\n\n\t\tlet rgb = (\n\t\t\tsignPow((Float(quantR) - 9) / 9, 2) * maximumValue,\n\t\t\tsignPow((Float(quantG) - 9) / 9, 2) * maximumValue,\n\t\t\tsignPow((Float(quantB) - 9) / 9, 2) * maximumValue\n\t\t)\n\n\t\treturn rgb\n\t}\n}\n\nprivate extension String {\n\tsubscript (offset: Int) -> Character {\n\t\treturn self[index(startIndex, offsetBy: offset)]\n\t}\n\n\tsubscript (bounds: CountableClosedRange<Int>) -> Substring {\n\t\tlet start = index(startIndex, offsetBy: bounds.lowerBound)\n\t\tlet end = index(startIndex, offsetBy: bounds.upperBound)\n\t\treturn self[start...end]\n\t}\n\n\tsubscript (bounds: CountableRange<Int>) -> Substring {\n\t\tlet start = index(startIndex, offsetBy: bounds.lowerBound)\n\t\tlet end = index(startIndex, offsetBy: bounds.upperBound)\n\t\treturn self[start..<end]\n\t}\n}\n"
  },
  {
    "path": "Swift/BlurHashKit/FromUIImage.swift",
    "content": "import UIKit\n\npublic extension BlurHash {\n\tinit?(image: UIImage, numberOfComponents components: (Int, Int)) {\n\t\tguard components.0 >= 1, components.0 <= 9,\n\t\tcomponents.1 >= 1, components.1 <= 9 else {\n\t\t\tfatalError(\"Number of components bust be between 1 and 9 inclusive on each axis\")\n\t\t}\n\n\t\tlet pixelWidth = Int(round(image.size.width * image.scale))\n\t\tlet pixelHeight = Int(round(image.size.height * image.scale))\n\n\t\tlet context = CGContext(\n\t\t\tdata: nil,\n\t\t\twidth: pixelWidth,\n\t\t\theight: pixelHeight,\n\t\t\tbitsPerComponent: 8,\n\t\t\tbytesPerRow: pixelWidth * 4,\n\t\t\tspace: CGColorSpace(name: CGColorSpace.sRGB)!,\n\t\t\tbitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue\n\t\t)!\n\t\tcontext.scaleBy(x: image.scale, y: -image.scale)\n\t\tcontext.translateBy(x: 0, y: -image.size.height)\n\n\t\tUIGraphicsPushContext(context)\n\t\timage.draw(at: .zero)\n\t\tUIGraphicsPopContext()\n\n\t\tguard let cgImage = context.makeImage(),\n\t\tlet dataProvider = cgImage.dataProvider,\n\t\tlet data = dataProvider.data,\n\t\tlet pixels = CFDataGetBytePtr(data) else {\n\t\t\tassertionFailure(\"Unexpected error!\")\n\t\t\treturn nil\n\t\t}\n\n\t\tlet width = cgImage.width\n\t\tlet height = cgImage.height\n\t\tlet bytesPerRow = cgImage.bytesPerRow\n\n\t\tself.components = (0 ..< components.1).map { j -> [(Float, Float, Float)] in\n\t\t\treturn (0 ..< components.0).map { i -> (Float, Float, Float) in\n\t\t\t\tlet normalisation: Float = (i == 0 && j == 0) ? 1 : 2\n\t\t\t\treturn BlurHash.multiplyBasisFunction(pixels: pixels, width: width, height: height, bytesPerRow: bytesPerRow, bytesPerPixel: cgImage.bitsPerPixel / 8) { x, y in\n\t\t\t\t\tnormalisation * cos(Float.pi * Float(i) * x / Float(width)) as Float * cos(Float.pi * Float(j) * y / Float(height)) as Float\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstatic private func multiplyBasisFunction(pixels: UnsafePointer<UInt8>, width: Int, height: Int, bytesPerRow: Int, bytesPerPixel: Int, basisFunction: (Float, Float) -> Float) -> (Float, Float, Float) {\n\t\tvar c: (Float, Float, Float) = (0, 0, 0)\n\n\t\tlet buffer = UnsafeBufferPointer(start: pixels, count: height * bytesPerRow)\n\n\t\tfor x in 0 ..< width {\n\t\t\tfor y in 0 ..< height {\n\t\t\t\tc += basisFunction(Float(x), Float(y)) * (\n\t\t\t\t\tsRGBToLinear(buffer[bytesPerPixel * x + 0 + y * bytesPerRow]),\n\t\t\t\t\tsRGBToLinear(buffer[bytesPerPixel * x + 1 + y * bytesPerRow]),\n\t\t\t\t\tsRGBToLinear(buffer[bytesPerPixel * x + 2 + y * bytesPerRow])\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\treturn c / Float(width * height)\n\t}\n}\n\n"
  },
  {
    "path": "Swift/BlurHashKit/Generation.swift",
    "content": "import UIKit\n\nextension BlurHash {\n\tpublic init(blendingTop top: BlurHash, bottom: BlurHash) {\n\t\tguard top.components.count == 1, bottom.components.count == 1 else {\n\t\t\tfatalError(\"Blended BlurHashses must have only one vertical component\")\n\t\t}\n\n\t\tlet average = zip(top.components[0], bottom.components[0]).map { ($0 + $1) / 2 }\n\t\tlet difference = zip(top.components[0], bottom.components[0]).map { ($0 - $1) / 2 }\n\t\tself.init(components: [average, difference])\n\t}\n\n\tpublic init(blendingLeft left: BlurHash, right: BlurHash) {\n\t\tself = BlurHash(blendingTop: left.transposed, bottom: right.transposed).transposed\n\t}\n}\n\nextension BlurHash {\n\tpublic init(colour: UIColor) {\n\t\tself.init(components: [[colour.linear]])\n\t}\n\n\tpublic init(blendingTop topColour: UIColor, bottom bottomColour: UIColor) {\n\t\tself = BlurHash(blendingTop: .init(colour: topColour), bottom: .init(colour: bottomColour))\n\t}\n\n\tpublic init(blendingLeft leftColour: UIColor, right rightColour: UIColor) {\n\t\tself = BlurHash(blendingLeft: .init(colour: leftColour), right: .init(colour: rightColour))\n\t}\n\n\tpublic init(blendingTopLeft topLeftColour: UIColor, topRight topRightColour: UIColor, bottomLeft bottomLeftColour: UIColor, bottomRight bottomRightColour: UIColor) {\n\t\tself = BlurHash(\n\t\t\tblendingTop: BlurHash(blendingTop: topLeftColour, bottom: topRightColour).transposed,\n\t\t\tbottom: BlurHash(blendingTop: bottomLeftColour, bottom: bottomRightColour).transposed\n\t\t)\n\t}\n}\n\nextension BlurHash {\n\tpublic init(horizontalColours colours: [(Float, Float, Float)], numberOfComponents: Int) {\n\t\tguard numberOfComponents >= 1, numberOfComponents <= 9 else {\n\t\t\tfatalError(\"Number of components bust be between 1 and 9 inclusive\")\n\t\t}\n\n\t\tself.init(components: [(0 ..< numberOfComponents).map { i in\n\t\t\tlet normalisation: Float = i == 0 ? 1 : 2\n\t\t\tvar sum: (Float, Float, Float) = (0, 0, 0)\n\t\t\tfor x in 0 ..< colours.count {\n\t\t\t\tlet basis = normalisation * cos(Float.pi * Float(i) * Float(x) / Float(colours.count - 1))\n\t\t\t\tsum += basis * colours[x]\n\t\t\t}\n\n\t\t\treturn sum / Float(colours.count)\n\t\t}])\n\t}\n}\n\nextension BlurHash {\n\tpublic var mirroredHorizontally: BlurHash {\n\t\treturn .init(components: (0 ..< numberOfVerticalComponents).map { j -> [(Float, Float, Float)] in\n\t\t\t(0 ..< numberOfHorizontalComponents).map { i -> (Float, Float, Float) in\n\t\t\t\tcomponents[j][i] * (i % 2 == 0 ? 1 : -1)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic var mirroredVertically: BlurHash {\n\t\treturn .init(components: (0 ..< numberOfVerticalComponents).map { j -> [(Float, Float, Float)] in\n\t\t\t(0 ..< numberOfHorizontalComponents).map { i -> (Float, Float, Float) in\n\t\t\t\tcomponents[j][i] * (j % 2 == 0 ? 1 : -1)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic var transposed: BlurHash {\n\t\treturn .init(components: (0 ..< numberOfHorizontalComponents).map { i in\n\t\t\t(0 ..< numberOfVerticalComponents).map { j in\n\t\t\t\tcomponents[j][i]\n\t\t\t}\n\t\t})\n\t}\n}\n\nextension UIColor {\n\tvar linear: (Float, Float, Float) {\n\t\tguard let c = cgColor.converted(to: CGColorSpace(name: CGColorSpace.sRGB)!, intent: .defaultIntent, options: nil)?.components else { return (0, 0, 0) }\n\n\t\tswitch c.count {\n\t\t\tcase 1, 2: return (sRGBToLinear(c[0]), sRGBToLinear(c[0]), sRGBToLinear(c[0]))\n\t\t\tcase 3, 4: return (sRGBToLinear(c[0]), sRGBToLinear(c[1]), sRGBToLinear(c[2]))\n\t\t\tdefault: return (0, 0, 0)\n\t\t}\n\t}\n}\n\nfunc sRGBToLinear(_ value: CGFloat) -> Float {\n\tlet v = Float(value)\n\tif v <= 0.04045 { return v / 12.92 }\n\telse { return pow((v + 0.055) / 1.055, 2.4) }\n}\n\n"
  },
  {
    "path": "Swift/BlurHashKit/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>en</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>FMWK</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleVersion</key>\n\t<string>$(CURRENT_PROJECT_VERSION)</string>\n\t<key>NSPrincipalClass</key>\n\t<string></string>\n</dict>\n</plist>\n"
  },
  {
    "path": "Swift/BlurHashKit/StringCoding.swift",
    "content": "import Foundation\n\nprivate let encodeCharacters: [String] = {\n    return \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~\".map { String($0) }\n}()\n\nprivate let decodeCharacters: [String: Int] = {\n\tvar dict: [String: Int] = [:]\n\tfor (index, character) in encodeCharacters.enumerated() {\n\t\tdict[character] = index\n\t}\n\treturn dict\n}()\n\nextension BinaryInteger {\n\tfunc encode83(length: Int) -> String {\n\t\tvar result = \"\"\n\t\tfor i in 1 ... length {\n\t\t\tlet digit = (Int(self) / pow(83, length - i)) % 83\n\t\t\tresult += encodeCharacters[Int(digit)]\n\t\t}\n\t\treturn result\n\t}\n}\n\nextension String {\n\tfunc decode83() -> Int {\n\t\tvar value: Int = 0\n\t\tfor character in self {\n\t\t\tif let digit = decodeCharacters[String(character)] {\n\t\t\t\tvalue = value * 83 + digit\n\t\t\t}\n\t\t}\n\t\treturn value\n\t}\n}\n\nprivate func pow(_ base: Int, _ exponent: Int) -> Int {\n    return (0 ..< exponent).reduce(1) { value, _ in value * base }\n}\n"
  },
  {
    "path": "Swift/BlurHashKit/ToString.swift",
    "content": "import Foundation\n\npublic extension BlurHash {\n\tvar string: String {\n\t\tlet flatComponents = components.reduce([]) { $0 + $1 }\n\t\tlet dc = flatComponents.first!\n\t\tlet ac = flatComponents.dropFirst()\n\n\t\tvar hash = \"\"\n\n\t\tlet sizeFlag = (numberOfHorizontalComponents - 1) + (numberOfVerticalComponents - 1) * 9\n\t\thash += sizeFlag.encode83(length: 1)\n\n\t\tlet maximumValue: Float\n\t\tif ac.count > 0 {\n\t\t\tlet actualMaximumValue = ac.map({ max(abs($0.0), abs($0.1), abs($0.2)) }).max()!\n\t\t\tlet quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5))))\n\t\t\tmaximumValue = Float(quantisedMaximumValue + 1) / 166\n\t\t\thash += quantisedMaximumValue.encode83(length: 1)\n\t\t} else {\n\t\t\tmaximumValue = 1\n\t\t\thash += 0.encode83(length: 1)\n\t\t}\n\n\t\thash += encodeDC(dc).encode83(length: 4)\n\n\t\tfor factor in ac {\n\t\t\thash += encodeAC(factor, maximumValue: maximumValue).encode83(length: 2)\n\t\t}\n\n\t\treturn hash\n\t}\n\n\tprivate func encodeDC(_ value: (Float, Float, Float)) -> Int {\n\t\tlet roundedR = linearTosRGB(value.0)\n\t\tlet roundedG = linearTosRGB(value.1)\n\t\tlet roundedB = linearTosRGB(value.2)\n\t\treturn (roundedR << 16) + (roundedG << 8) + roundedB\n\t}\n\n\tprivate func encodeAC(_ value: (Float, Float, Float), maximumValue: Float) -> Int {\n\t\tlet quantR = Int(max(0, min(18, floor(signPow(value.0 / maximumValue, 0.5) * 9 + 9.5))))\n\t\tlet quantG = Int(max(0, min(18, floor(signPow(value.1 / maximumValue, 0.5) * 9 + 9.5))))\n\t\tlet quantB = Int(max(0, min(18, floor(signPow(value.2 / maximumValue, 0.5) * 9 + 9.5))))\n\n\t\treturn quantR * 19 * 19 + quantG * 19 + quantB\n\t}\n}\n"
  },
  {
    "path": "Swift/BlurHashKit/ToUIImage.swift",
    "content": "import UIKit\n\nextension BlurHash {\n\tpublic func cgImage(size: CGSize) -> CGImage? {\n\t\tlet width = Int(size.width)\n\t\tlet height = Int(size.height)\n\t\tlet bytesPerRow = width * 3\n\n\t\tguard let data = CFDataCreateMutable(kCFAllocatorDefault, bytesPerRow * height) else { return nil }\n\t\tCFDataSetLength(data, bytesPerRow * height)\n\n\t\tguard let pixels = CFDataGetMutableBytePtr(data) else { return nil }\n\n\t\tfor y in 0 ..< height {\n\t\t\tfor x in 0 ..< width {\n\t\t\t\tvar c: (Float, Float, Float) = (0, 0, 0)\n\n\t\t\t\tfor j in 0 ..< numberOfVerticalComponents {\n\t\t\t\t\tfor i in 0 ..< numberOfHorizontalComponents {\n\t\t\t\t\t\tlet basis = cos(Float.pi * Float(x) * Float(i) / Float(width)) * cos(Float.pi * Float(y) * Float(j) / Float(height))\n\t\t\t\t\t\tlet component = components[j][i]\n\t\t\t\t\t\tc += component * basis\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlet intR = UInt8(linearTosRGB(c.0))\n\t\t\t\tlet intG = UInt8(linearTosRGB(c.1))\n\t\t\t\tlet intB = UInt8(linearTosRGB(c.2))\n\n\t\t\t\tpixels[3 * x + 0 + y * bytesPerRow] = intR\n\t\t\t\tpixels[3 * x + 1 + y * bytesPerRow] = intG\n\t\t\t\tpixels[3 * x + 2 + y * bytesPerRow] = intB\n\t\t\t}\n\t\t}\n\n\t\tlet bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue)\n\n\t\tguard let provider = CGDataProvider(data: data) else { return nil }\n\t\tguard let cgImage = CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 24, bytesPerRow: bytesPerRow,\n\t\tspace: CGColorSpaceCreateDeviceRGB(), bitmapInfo: bitmapInfo, provider: provider, decode: nil, shouldInterpolate: true, intent: .defaultIntent) else { return nil }\n\n\t\treturn cgImage\n\t}\n\n\tpublic func cgImage(numberOfPixels: Int = 1024, originalSize size: CGSize) -> CGImage? {\n\t\tlet width: CGFloat\n\t\tlet height: CGFloat\n\t\tif size.width > size.height {\n\t\t\twidth = floor(sqrt(CGFloat(numberOfPixels) * size.width / size.height) + 0.5)\n\t\t\theight = floor(CGFloat(numberOfPixels) / width + 0.5)\n\t\t} else {\n\t\t\theight = floor(sqrt(CGFloat(numberOfPixels) * size.height / size.width) + 0.5)\n\t\t\twidth = floor(CGFloat(numberOfPixels) / height + 0.5)\n\t\t}\n\t\treturn cgImage(size: CGSize(width: width, height: height))\n\t}\n\n\tpublic func image(size: CGSize) -> UIImage? {\n\t\tguard let cgImage = cgImage(size: size) else { return nil }\n\t\treturn UIImage(cgImage: cgImage)\n\t}\n\n\tpublic func image(numberOfPixels: Int = 1024, originalSize size: CGSize) -> UIImage? {\n\t\tguard let cgImage = cgImage(numberOfPixels: numberOfPixels, originalSize: size) else { return nil }\n\t\treturn UIImage(cgImage: cgImage)\n\t}\n}\n\n@objc extension UIImage {\n    public convenience init?(blurHash string: String, size: CGSize, punch: Float = 1) {\n        guard let blurHash = BlurHash(string: string),\n        let cgImage = blurHash.punch(punch).cgImage(size: size) else { return nil }\n        self.init(cgImage: cgImage)\n    }\n\n    public convenience init?(blurHash string: String, numberOfPixels: Int = 1024, originalSize size: CGSize, punch: Float = 1) {\n        guard let blurHash = BlurHash(string: string),\n        let cgImage = blurHash.punch(punch).cgImage(numberOfPixels: numberOfPixels, originalSize: size) else { return nil }\n        self.init(cgImage: cgImage)\n    }\n}\n"
  },
  {
    "path": "Swift/BlurHashKit/TupleMaths.swift",
    "content": "import Foundation\n\nfunc +(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {\n\treturn (lhs.0 + rhs.0, lhs.1 + rhs.1, lhs.2 + rhs.2)\n}\n\nfunc -(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {\n\treturn (lhs.0 - rhs.0, lhs.1 - rhs.1, lhs.2 - rhs.2)\n}\n\nfunc *(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {\n    return (lhs.0 * rhs.0, lhs.1 * rhs.1, lhs.2 * rhs.2)\n}\n\nfunc *(lhs: (Float, Float, Float), rhs: Float) -> (Float, Float, Float) {\n\treturn (lhs.0 * rhs, lhs.1 * rhs, lhs.2 * rhs)\n}\n\nfunc *(lhs: Float, rhs: (Float, Float, Float)) -> (Float, Float, Float) {\n\treturn (lhs * rhs.0, lhs * rhs.1, lhs * rhs.2)\n}\n\nfunc /(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {\n    return (lhs.0 / rhs.0, lhs.1 / rhs.1, lhs.2 / rhs.2)\n}\n\nfunc /(lhs: (Float, Float, Float), rhs: Float) -> (Float, Float, Float) {\n\treturn (lhs.0 / rhs, lhs.1 / rhs, lhs.2 / rhs)\n}\n\nfunc +=(lhs: inout (Float, Float, Float), rhs: (Float, Float, Float)) {\n\tlhs = lhs + rhs\n}\n\nfunc -=(lhs: inout (Float, Float, Float), rhs: (Float, Float, Float)) {\n\tlhs = lhs - rhs\n}\n\nfunc *=(lhs: inout (Float, Float, Float), rhs: Float) {\n\tlhs = lhs * rhs\n}\n\nfunc /=(lhs: inout (Float, Float, Float), rhs: Float) {\n\tlhs = lhs / rhs\n}\n\nfunc min(_ a: (Float, Float, Float), _ b: (Float, Float, Float)) -> (Float, Float, Float) {\n    return (min(a.0, b.0), min(a.1, b.1), min(a.2, b.2))\n}\n\nfunc max(_ a: (Float, Float, Float), _ b: (Float, Float, Float)) -> (Float, Float, Float) {\n    return (max(a.0, b.0), max(a.1, b.1), max(a.2, b.2))\n}\n"
  },
  {
    "path": "Swift/BlurHashTest/AdvancedViewController.swift",
    "content": "import UIKit\nimport BlurHashKit\n\nclass AdvancedViewController: UIViewController {\n    @IBOutlet weak var originalImageView: UIImageView?\n    @IBOutlet weak var uncompressedBlurImageView: UIImageView?\n    @IBOutlet weak var hashLabel: UILabel?\n    @IBOutlet weak var compressedBlurImageView: UIImageView?\n\n    @IBOutlet weak var darknessBlurImageView: UIImageView?\n    @IBOutlet weak var topLeftCornerLabel: UILabel?\n    @IBOutlet weak var topEdgeLabel: UILabel?\n    @IBOutlet weak var topRightCornerLabel: UILabel?\n    @IBOutlet weak var leftEdgeLabel: UILabel?\n    @IBOutlet weak var centreLabel: UILabel?\n    @IBOutlet weak var rightEdgeLabel: UILabel?\n    @IBOutlet weak var bottomLeftCornerLabel: UILabel?\n    @IBOutlet weak var bottomEdgeLabel: UILabel?\n    @IBOutlet weak var bottomRightCornerLabel: UILabel?\n\n    @IBOutlet weak var xComponentsLabel: UILabel?\n    @IBOutlet weak var yComponentsLabel: UILabel?\n\n    let images: [UIImage] = [\n        UIImage(named: \"pic2.png\")!,\n        UIImage(named: \"pic1.png\")!,\n        UIImage(named: \"pic3.png\")!,\n        UIImage(named: \"pic6.png\")!,\n        UIImage(named: \"pic4.png\")!,\n        UIImage(named: \"pic5.png\")!,\n    ]\n\n    var imageIndex: Int = 0\n    var xComponents: Int = 4\n    var yComponents: Int = 3\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        update()\n    }\n\n    @IBAction func imageTapped() {\n        imageIndex = (imageIndex + 1) % images.count\n        update()\n    }\n\n    @IBAction func xPlusTapped() {\n        if xComponents < 9 {\n            xComponents += 1\n            update()\n        }\n    }\n\n    @IBAction func xMinusTapped() {\n        if xComponents > 1 {\n            xComponents -= 1\n            update()\n        }\n    }\n\n    @IBAction func yPlusTapped() {\n        if yComponents < 9 {\n            yComponents += 1\n            update()\n        }\n    }\n\n    @IBAction func yMinusTapped() {\n        if yComponents > 1 {\n            yComponents -= 1\n            update()\n        }\n     }\n\n\n    func update() {\n    \tlet image = images[imageIndex]\n\n        originalImageView?.image = image\n\n        let blurHash = BlurHash(image: images[imageIndex], numberOfComponents: (xComponents, yComponents))!\n\t\tuncompressedBlurImageView?.image = blurHash.image(numberOfPixels: 1024, originalSize: image.size)\n\n        hashLabel?.text = blurHash.string\n        let decodedBlurHash = BlurHash(string: blurHash.string)!\n\n        compressedBlurImageView?.image = decodedBlurHash.image(numberOfPixels: 1024, originalSize: image.size)\n        darknessBlurImageView?.image = decodedBlurHash.image(numberOfPixels: 1024, originalSize: image.size)\n\n        setDarkness(label: topLeftCornerLabel, isDark: decodedBlurHash.isTopLeftCornerDark, light: \"Ⓛ\", dark: \"Ⓓ\")\n        setDarkness(label: topEdgeLabel, isDark: decodedBlurHash.isTopEdgeDark, light: \"------Light------\", dark: \"------Dark------\")\n        setDarkness(label: topRightCornerLabel, isDark: decodedBlurHash.isTopRightCornerDark, light: \"Ⓛ\", dark: \"Ⓓ\")\n        setDarkness(label: leftEdgeLabel, isDark: decodedBlurHash.isLeftEdgeDark, light: \"|\\n|\\nLight\\n|\\n|\", dark: \"|\\n|\\nDark\\n|\\n|\")\n        setDarkness(label: centreLabel, isDark: decodedBlurHash.isDark(), light: \"Light\", dark: \"Dark\")\n        setDarkness(label: rightEdgeLabel, isDark: decodedBlurHash.isRightEdgeDark, light: \"|\\n|\\nLight\\n|\\n|\", dark: \"|\\n|\\nDark\\n|\\n|\")\n        setDarkness(label: bottomLeftCornerLabel, isDark: decodedBlurHash.isBottomLeftCornerDark, light: \"Ⓛ\", dark: \"Ⓓ\")\n        setDarkness(label: bottomEdgeLabel, isDark: decodedBlurHash.isBottomEdgeDark, light: \"------Light------\", dark: \"------Dark------\")\n        setDarkness(label: bottomRightCornerLabel, isDark: decodedBlurHash.isBottomRightCornerDark, light: \"Ⓛ\", dark: \"Ⓓ\")\n\n        xComponentsLabel?.text = String(xComponents)\n        yComponentsLabel?.text = String(yComponents)\n\n    }\n\n    func setDarkness(label: UILabel?, isDark: Bool, light: String, dark: String) {\n        if isDark {\n            label?.textColor = .white\n            label?.text = dark\n        } else {\n            label?.textColor = .black\n            label?.text = light\n        }\n    }\n\n}\n\n"
  },
  {
    "path": "Swift/BlurHashTest/AppDelegate.swift",
    "content": "import UIKit\n\n@UIApplicationMain\nclass AppDelegate: UIResponder, UIApplicationDelegate {\n\n    var window: UIWindow?\n\n    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {\n        return true\n    }\n}\n\n"
  },
  {
    "path": "Swift/BlurHashTest/Assets.xcassets/AppIcon.appiconset/Contents.json",
    "content": "{\n  \"images\" : [\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"60x60\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"iphone\",\n      \"size\" : \"60x60\",\n      \"scale\" : \"3x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"20x20\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"29x29\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"40x40\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"76x76\",\n      \"scale\" : \"1x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"76x76\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ipad\",\n      \"size\" : \"83.5x83.5\",\n      \"scale\" : \"2x\"\n    },\n    {\n      \"idiom\" : \"ios-marketing\",\n      \"size\" : \"1024x1024\",\n      \"scale\" : \"1x\"\n    }\n  ],\n  \"info\" : {\n    \"version\" : 1,\n    \"author\" : \"xcode\"\n  }\n}"
  },
  {
    "path": "Swift/BlurHashTest/Base.lproj/LaunchScreen.storyboard",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3.0\" toolsVersion=\"11134\" systemVersion=\"15F34\" targetRuntime=\"iOS.CocoaTouch\" propertyAccessControl=\"none\" useAutolayout=\"YES\" launchScreen=\"YES\" useTraitCollections=\"YES\" colorMatched=\"YES\" initialViewController=\"01J-lp-oVM\">\n    <dependencies>\n        <plugIn identifier=\"com.apple.InterfaceBuilder.IBCocoaTouchPlugin\" version=\"11106\"/>\n        <capability name=\"documents saved in the Xcode 8 format\" minToolsVersion=\"8.0\"/>\n    </dependencies>\n    <scenes>\n        <!--View Controller-->\n        <scene sceneID=\"EHf-IW-A2E\">\n            <objects>\n                <viewController id=\"01J-lp-oVM\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"Llm-lL-Icb\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"xb3-aO-Qok\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"Ze5-6b-2t3\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"667\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <color key=\"backgroundColor\" red=\"1\" green=\"1\" blue=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>\n                    </view>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"iYj-Kq-Ea1\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"53\" y=\"375\"/>\n        </scene>\n    </scenes>\n</document>\n"
  },
  {
    "path": "Swift/BlurHashTest/Base.lproj/Main.storyboard",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3.0\" toolsVersion=\"13771\" targetRuntime=\"iOS.CocoaTouch\" propertyAccessControl=\"none\" useAutolayout=\"YES\" useTraitCollections=\"YES\" colorMatched=\"YES\" initialViewController=\"ow8-qa-tQW\">\n    <device id=\"retina4_7\" orientation=\"portrait\">\n        <adaptation id=\"fullscreen\"/>\n    </device>\n    <dependencies>\n        <deployment identifier=\"iOS\"/>\n        <plugIn identifier=\"com.apple.InterfaceBuilder.IBCocoaTouchPlugin\" version=\"13772\"/>\n        <capability name=\"Aspect ratio constraints\" minToolsVersion=\"5.1\"/>\n        <capability name=\"Constraints to layout margins\" minToolsVersion=\"6.0\"/>\n        <capability name=\"Constraints with non-1.0 multipliers\" minToolsVersion=\"5.1\"/>\n        <capability name=\"documents saved in the Xcode 8 format\" minToolsVersion=\"8.0\"/>\n    </dependencies>\n    <customFonts key=\"customFonts\">\n        <array key=\"Courier.ttc\">\n            <string>Courier</string>\n        </array>\n    </customFonts>\n    <scenes>\n        <!--Advanced-->\n        <scene sceneID=\"aAy-aP-fMy\">\n            <objects>\n                <viewController id=\"GoA-CQ-Oko\" customClass=\"AdvancedViewController\" customModule=\"BlurHashTest\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"RAf-iQ-3dY\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"Pfy-5l-wbH\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"fAH-Mr-gHV\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"1000\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <scrollView clipsSubviews=\"YES\" multipleTouchEnabled=\"YES\" contentMode=\"scaleToFill\" alwaysBounceVertical=\"YES\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"aHD-uZ-0hI\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"890\"/>\n                                <subviews>\n                                    <stackView opaque=\"NO\" contentMode=\"scaleToFill\" axis=\"vertical\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"bKs-dk-VVG\">\n                                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"692\"/>\n                                        <subviews>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"nkq-Mg-0Wb\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"129\"/>\n                                                <subviews>\n                                                    <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" placeholderIntrinsicWidth=\"240\" placeholderIntrinsicHeight=\"128\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"jbW-pm-Cg6\">\n                                                        <rect key=\"frame\" x=\"67.5\" y=\"0.0\" width=\"240\" height=\"129\"/>\n                                                        <gestureRecognizers/>\n                                                    </imageView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"jbW-pm-Cg6\" secondAttribute=\"bottom\" id=\"RYV-59-qwc\"/>\n                                                    <constraint firstItem=\"jbW-pm-Cg6\" firstAttribute=\"top\" secondItem=\"nkq-Mg-0Wb\" secondAttribute=\"top\" id=\"c9F-TY-uXD\"/>\n                                                    <constraint firstItem=\"jbW-pm-Cg6\" firstAttribute=\"centerX\" secondItem=\"nkq-Mg-0Wb\" secondAttribute=\"centerX\" id=\"koS-jd-wdS\"/>\n                                                </constraints>\n                                            </view>\n                                            <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"⇩\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"YbM-uf-zDn\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"129\" width=\"375\" height=\"48\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"height\" constant=\"48\" id=\"1mZ-Zg-TtV\"/>\n                                                </constraints>\n                                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                <nil key=\"textColor\"/>\n                                                <nil key=\"highlightedColor\"/>\n                                            </label>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"YL9-oY-UoD\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"177\" width=\"375\" height=\"129\"/>\n                                                <subviews>\n                                                    <imageView userInteractionEnabled=\"NO\" contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" placeholderIntrinsicWidth=\"240\" placeholderIntrinsicHeight=\"128\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"oPc-dA-gI3\">\n                                                        <rect key=\"frame\" x=\"67.5\" y=\"0.0\" width=\"240\" height=\"129\"/>\n                                                    </imageView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstItem=\"oPc-dA-gI3\" firstAttribute=\"centerX\" secondItem=\"YL9-oY-UoD\" secondAttribute=\"centerX\" id=\"IgK-K5-keA\"/>\n                                                    <constraint firstItem=\"oPc-dA-gI3\" firstAttribute=\"top\" secondItem=\"YL9-oY-UoD\" secondAttribute=\"top\" id=\"Qdb-Tg-I23\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"oPc-dA-gI3\" secondAttribute=\"bottom\" id=\"rF5-9n-uMY\"/>\n                                                </constraints>\n                                            </view>\n                                            <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"⇩\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"CsB-nl-iuH\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"306\" width=\"375\" height=\"48\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"height\" constant=\"48\" id=\"gnc-RN-bd3\"/>\n                                                </constraints>\n                                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                <nil key=\"textColor\"/>\n                                                <nil key=\"highlightedColor\"/>\n                                            </label>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"zj1-m7-k55\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"354\" width=\"375\" height=\"16\"/>\n                                                <subviews>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"1000\" text=\"Hash goes here\" textAlignment=\"center\" lineBreakMode=\"characterWrap\" numberOfLines=\"0\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"APC-rp-edX\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"16\"/>\n                                                        <fontDescription key=\"fontDescription\" name=\"Courier\" family=\"Courier\" pointSize=\"16\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"APC-rp-edX\" secondAttribute=\"bottom\" id=\"51S-aL-tb0\"/>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"APC-rp-edX\" secondAttribute=\"trailing\" constant=\"16\" id=\"Hba-H7-Skh\"/>\n                                                    <constraint firstItem=\"APC-rp-edX\" firstAttribute=\"leading\" secondItem=\"zj1-m7-k55\" secondAttribute=\"leading\" constant=\"16\" id=\"hwA-N8-Db1\"/>\n                                                    <constraint firstItem=\"APC-rp-edX\" firstAttribute=\"top\" secondItem=\"zj1-m7-k55\" secondAttribute=\"top\" id=\"kUD-4j-Ik3\"/>\n                                                </constraints>\n                                            </view>\n                                            <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"⇩\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"CCV-8y-anE\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"370\" width=\"375\" height=\"48\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"height\" constant=\"48\" id=\"Iyh-Uc-8SK\"/>\n                                                </constraints>\n                                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                <nil key=\"textColor\"/>\n                                                <nil key=\"highlightedColor\"/>\n                                            </label>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"kkk-a2-0ke\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"418\" width=\"375\" height=\"129\"/>\n                                                <subviews>\n                                                    <imageView userInteractionEnabled=\"NO\" contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" placeholderIntrinsicWidth=\"240\" placeholderIntrinsicHeight=\"128\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"wVZ-tm-8wt\">\n                                                        <rect key=\"frame\" x=\"67.5\" y=\"0.0\" width=\"240\" height=\"129\"/>\n                                                    </imageView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"wVZ-tm-8wt\" secondAttribute=\"bottom\" id=\"4kq-pb-fVP\"/>\n                                                    <constraint firstItem=\"wVZ-tm-8wt\" firstAttribute=\"top\" secondItem=\"kkk-a2-0ke\" secondAttribute=\"top\" id=\"5dv-VQ-Xrw\"/>\n                                                    <constraint firstItem=\"wVZ-tm-8wt\" firstAttribute=\"centerX\" secondItem=\"kkk-a2-0ke\" secondAttribute=\"centerX\" id=\"gqq-M2-see\"/>\n                                                </constraints>\n                                            </view>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"TkK-nz-dPp\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"547\" width=\"375\" height=\"145\"/>\n                                                <subviews>\n                                                    <imageView userInteractionEnabled=\"NO\" contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" placeholderIntrinsicWidth=\"240\" placeholderIntrinsicHeight=\"128\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"AIg-aT-T27\">\n                                                        <rect key=\"frame\" x=\"67.5\" y=\"16\" width=\"240\" height=\"129\"/>\n                                                    </imageView>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"L\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"QbV-sR-2CC\">\n                                                        <rect key=\"frame\" x=\"71.5\" y=\"20\" width=\"13\" height=\"29\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"Light\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Ivf-jp-J0F\">\n                                                        <rect key=\"frame\" x=\"168\" y=\"20\" width=\"39\" height=\"20.5\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"L\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"g5m-pZ-G50\">\n                                                        <rect key=\"frame\" x=\"290.5\" y=\"20\" width=\"13\" height=\"29\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"Light\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Y1h-NI-DD4\">\n                                                        <rect key=\"frame\" x=\"149.5\" y=\"59\" width=\"76\" height=\"43\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" weight=\"light\" pointSize=\"36\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"L\" textAlignment=\"right\" lineBreakMode=\"tailTruncation\" numberOfLines=\"0\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"rwg-7e-Nii\">\n                                                        <rect key=\"frame\" x=\"294\" y=\"70.5\" width=\"9.5\" height=\"20.5\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"L\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"XNZ-ZV-PDL\">\n                                                        <rect key=\"frame\" x=\"71.5\" y=\"112\" width=\"13\" height=\"29\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"Light\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"752-5V-jQ8\">\n                                                        <rect key=\"frame\" x=\"168\" y=\"120.5\" width=\"39\" height=\"20.5\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"L\" textAlignment=\"natural\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Lxh-2a-bSu\">\n                                                        <rect key=\"frame\" x=\"290.5\" y=\"112\" width=\"13\" height=\"29\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"L\" lineBreakMode=\"tailTruncation\" numberOfLines=\"0\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Hyz-JK-uvv\">\n                                                        <rect key=\"frame\" x=\"71.5\" y=\"70\" width=\"9.5\" height=\"20.5\"/>\n                                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstItem=\"Lxh-2a-bSu\" firstAttribute=\"bottom\" secondItem=\"AIg-aT-T27\" secondAttribute=\"bottom\" constant=\"-4\" id=\"2a7-ym-egB\"/>\n                                                    <constraint firstItem=\"Ivf-jp-J0F\" firstAttribute=\"centerX\" secondItem=\"AIg-aT-T27\" secondAttribute=\"centerX\" id=\"6d4-fs-VN3\"/>\n                                                    <constraint firstItem=\"Hyz-JK-uvv\" firstAttribute=\"centerY\" secondItem=\"AIg-aT-T27\" secondAttribute=\"centerY\" id=\"6oe-4p-vbH\"/>\n                                                    <constraint firstItem=\"AIg-aT-T27\" firstAttribute=\"centerX\" secondItem=\"TkK-nz-dPp\" secondAttribute=\"centerX\" id=\"Ayg-GV-m1p\"/>\n                                                    <constraint firstItem=\"Y1h-NI-DD4\" firstAttribute=\"centerX\" secondItem=\"AIg-aT-T27\" secondAttribute=\"centerX\" id=\"BrA-QK-N3Y\"/>\n                                                    <constraint firstItem=\"Lxh-2a-bSu\" firstAttribute=\"trailing\" secondItem=\"AIg-aT-T27\" secondAttribute=\"trailing\" constant=\"-4\" id=\"DlN-ub-REN\"/>\n                                                    <constraint firstItem=\"g5m-pZ-G50\" firstAttribute=\"top\" secondItem=\"AIg-aT-T27\" secondAttribute=\"top\" constant=\"4\" id=\"Fsq-Gh-GHs\"/>\n                                                    <constraint firstItem=\"AIg-aT-T27\" firstAttribute=\"top\" secondItem=\"TkK-nz-dPp\" secondAttribute=\"top\" constant=\"16\" id=\"H93-y6-jZC\"/>\n                                                    <constraint firstItem=\"Ivf-jp-J0F\" firstAttribute=\"top\" secondItem=\"AIg-aT-T27\" secondAttribute=\"top\" constant=\"4\" id=\"HME-KE-TEj\"/>\n                                                    <constraint firstItem=\"752-5V-jQ8\" firstAttribute=\"bottom\" secondItem=\"AIg-aT-T27\" secondAttribute=\"bottom\" constant=\"-4\" id=\"Tlf-EL-gQB\"/>\n                                                    <constraint firstItem=\"Hyz-JK-uvv\" firstAttribute=\"leading\" secondItem=\"AIg-aT-T27\" secondAttribute=\"leading\" constant=\"4\" id=\"WqR-7p-X2q\"/>\n                                                    <constraint firstItem=\"Y1h-NI-DD4\" firstAttribute=\"centerY\" secondItem=\"AIg-aT-T27\" secondAttribute=\"centerY\" id=\"XTf-le-JVg\"/>\n                                                    <constraint firstItem=\"QbV-sR-2CC\" firstAttribute=\"leading\" secondItem=\"AIg-aT-T27\" secondAttribute=\"leading\" constant=\"4\" id=\"ccx-W9-tWJ\"/>\n                                                    <constraint firstItem=\"g5m-pZ-G50\" firstAttribute=\"trailing\" secondItem=\"AIg-aT-T27\" secondAttribute=\"trailing\" constant=\"-4\" id=\"cia-Yt-Vg4\"/>\n                                                    <constraint firstItem=\"XNZ-ZV-PDL\" firstAttribute=\"bottom\" secondItem=\"AIg-aT-T27\" secondAttribute=\"bottom\" constant=\"-4\" id=\"drB-h2-OWB\"/>\n                                                    <constraint firstItem=\"QbV-sR-2CC\" firstAttribute=\"top\" secondItem=\"AIg-aT-T27\" secondAttribute=\"top\" constant=\"4\" id=\"gxS-1R-Uo9\"/>\n                                                    <constraint firstItem=\"752-5V-jQ8\" firstAttribute=\"centerX\" secondItem=\"AIg-aT-T27\" secondAttribute=\"centerX\" id=\"iov-xV-TCy\"/>\n                                                    <constraint firstItem=\"rwg-7e-Nii\" firstAttribute=\"centerY\" secondItem=\"AIg-aT-T27\" secondAttribute=\"centerY\" id=\"mkO-VW-55t\"/>\n                                                    <constraint firstItem=\"XNZ-ZV-PDL\" firstAttribute=\"leading\" secondItem=\"AIg-aT-T27\" secondAttribute=\"leading\" constant=\"4\" id=\"sSW-sf-a7n\"/>\n                                                    <constraint firstItem=\"rwg-7e-Nii\" firstAttribute=\"trailing\" secondItem=\"AIg-aT-T27\" secondAttribute=\"trailing\" constant=\"-4\" id=\"tZI-o8-W7e\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"AIg-aT-T27\" secondAttribute=\"bottom\" id=\"zpL-eF-oFD\"/>\n                                                </constraints>\n                                            </view>\n                                        </subviews>\n                                        <gestureRecognizers/>\n                                        <constraints>\n                                            <constraint firstItem=\"AIg-aT-T27\" firstAttribute=\"height\" secondItem=\"wVZ-tm-8wt\" secondAttribute=\"height\" id=\"CuJ-Al-plZ\"/>\n                                            <constraint firstItem=\"oPc-dA-gI3\" firstAttribute=\"height\" secondItem=\"jbW-pm-Cg6\" secondAttribute=\"height\" id=\"Hau-lk-Q0e\"/>\n                                            <constraint firstItem=\"jbW-pm-Cg6\" firstAttribute=\"height\" secondItem=\"wVZ-tm-8wt\" secondAttribute=\"height\" id=\"Z6u-D5-24l\"/>\n                                            <constraint firstItem=\"wVZ-tm-8wt\" firstAttribute=\"width\" secondItem=\"jbW-pm-Cg6\" secondAttribute=\"width\" id=\"cbL-D5-7RY\"/>\n                                            <constraint firstItem=\"AIg-aT-T27\" firstAttribute=\"width\" secondItem=\"wVZ-tm-8wt\" secondAttribute=\"width\" id=\"hyt-gJ-oJ4\"/>\n                                            <constraint firstItem=\"oPc-dA-gI3\" firstAttribute=\"width\" secondItem=\"jbW-pm-Cg6\" secondAttribute=\"width\" id=\"qzN-lh-p8Y\"/>\n                                        </constraints>\n                                        <connections>\n                                            <outletCollection property=\"gestureRecognizers\" destination=\"auZ-KF-fNX\" appends=\"YES\" id=\"9pp-sP-0id\"/>\n                                        </connections>\n                                    </stackView>\n                                </subviews>\n                                <constraints>\n                                    <constraint firstAttribute=\"trailing\" secondItem=\"bKs-dk-VVG\" secondAttribute=\"trailing\" id=\"DFw-Rh-Alp\"/>\n                                    <constraint firstItem=\"bKs-dk-VVG\" firstAttribute=\"width\" secondItem=\"aHD-uZ-0hI\" secondAttribute=\"width\" id=\"bJq-QF-sJi\"/>\n                                    <constraint firstItem=\"bKs-dk-VVG\" firstAttribute=\"leading\" secondItem=\"aHD-uZ-0hI\" secondAttribute=\"leading\" id=\"iYn-Zx-rpg\"/>\n                                    <constraint firstItem=\"bKs-dk-VVG\" firstAttribute=\"top\" secondItem=\"aHD-uZ-0hI\" secondAttribute=\"top\" id=\"l7b-RK-ayz\"/>\n                                    <constraint firstAttribute=\"bottom\" secondItem=\"bKs-dk-VVG\" secondAttribute=\"bottom\" id=\"vKw-mX-8Ta\"/>\n                                </constraints>\n                            </scrollView>\n                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"k8L-yh-Uc9\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"890\" width=\"375\" height=\"61\"/>\n                                <subviews>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"t9s-30-kSA\">\n                                        <rect key=\"frame\" x=\"92\" y=\"8\" width=\"45\" height=\"45\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"45\" id=\"2Qd-SN-JZG\"/>\n                                            <constraint firstAttribute=\"height\" constant=\"45\" id=\"oJq-j6-j6D\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"+\"/>\n                                        <connections>\n                                            <action selector=\"xPlusTapped\" destination=\"GoA-CQ-Oko\" eventType=\"touchUpInside\" id=\"CQb-RI-hPa\"/>\n                                        </connections>\n                                    </button>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"dcv-3g-vPH\">\n                                        <rect key=\"frame\" x=\"8\" y=\"6\" width=\"48\" height=\"48\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"48\" id=\"06k-fn-X6r\"/>\n                                            <constraint firstAttribute=\"height\" constant=\"48\" id=\"s9s-VF-ac5\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"-\"/>\n                                        <connections>\n                                            <action selector=\"xMinusTapped\" destination=\"GoA-CQ-Oko\" eventType=\"touchUpInside\" id=\"N05-Gv-FL5\"/>\n                                        </connections>\n                                    </button>\n                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"1000\" text=\"8\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"UVT-7V-jBv\">\n                                        <rect key=\"frame\" x=\"64\" y=\"16\" width=\"20\" height=\"29\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"20\" id=\"InF-nv-eHU\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                        <nil key=\"textColor\"/>\n                                        <nil key=\"highlightedColor\"/>\n                                    </label>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"spt-ih-YyW\">\n                                        <rect key=\"frame\" x=\"322\" y=\"8\" width=\"45\" height=\"45\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"45\" id=\"Glg-Nm-gax\"/>\n                                            <constraint firstAttribute=\"height\" constant=\"45\" id=\"NfN-i3-zZd\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"+\"/>\n                                        <connections>\n                                            <action selector=\"yPlusTapped\" destination=\"GoA-CQ-Oko\" eventType=\"touchUpInside\" id=\"ZSc-o4-g8c\"/>\n                                        </connections>\n                                    </button>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"4FP-Tx-TxJ\">\n                                        <rect key=\"frame\" x=\"238\" y=\"6\" width=\"48\" height=\"48\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"48\" id=\"Tds-KD-4FW\"/>\n                                            <constraint firstAttribute=\"height\" constant=\"48\" id=\"tk6-6o-D7K\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"-\"/>\n                                        <connections>\n                                            <action selector=\"yMinusTapped\" destination=\"GoA-CQ-Oko\" eventType=\"touchUpInside\" id=\"KTx-Hq-JVL\"/>\n                                        </connections>\n                                    </button>\n                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"8\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"nFP-Bd-1kw\">\n                                        <rect key=\"frame\" x=\"294\" y=\"16\" width=\"20\" height=\"29\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"20\" id=\"4ZW-PT-QlK\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                        <nil key=\"textColor\"/>\n                                        <nil key=\"highlightedColor\"/>\n                                    </label>\n                                </subviews>\n                                <color key=\"backgroundColor\" red=\"1\" green=\"1\" blue=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>\n                                <constraints>\n                                    <constraint firstItem=\"UVT-7V-jBv\" firstAttribute=\"top\" secondItem=\"k8L-yh-Uc9\" secondAttribute=\"top\" constant=\"16\" id=\"1Rg-vC-ASB\"/>\n                                    <constraint firstItem=\"dcv-3g-vPH\" firstAttribute=\"leading\" secondItem=\"k8L-yh-Uc9\" secondAttribute=\"leadingMargin\" id=\"5Cn-HL-FpK\"/>\n                                    <constraint firstAttribute=\"bottom\" secondItem=\"UVT-7V-jBv\" secondAttribute=\"bottom\" constant=\"16\" id=\"9gx-1x-RTG\"/>\n                                    <constraint firstItem=\"UVT-7V-jBv\" firstAttribute=\"baseline\" secondItem=\"t9s-30-kSA\" secondAttribute=\"baseline\" id=\"D2P-r2-SNs\"/>\n                                    <constraint firstItem=\"spt-ih-YyW\" firstAttribute=\"trailing\" secondItem=\"k8L-yh-Uc9\" secondAttribute=\"trailingMargin\" id=\"KEc-3P-PWQ\"/>\n                                    <constraint firstItem=\"nFP-Bd-1kw\" firstAttribute=\"baseline\" secondItem=\"spt-ih-YyW\" secondAttribute=\"baseline\" id=\"Kpf-pr-0qa\"/>\n                                    <constraint firstItem=\"UVT-7V-jBv\" firstAttribute=\"leading\" secondItem=\"dcv-3g-vPH\" secondAttribute=\"trailing\" constant=\"8\" id=\"Qxq-mr-rns\"/>\n                                    <constraint firstItem=\"spt-ih-YyW\" firstAttribute=\"leading\" secondItem=\"nFP-Bd-1kw\" secondAttribute=\"trailing\" constant=\"8\" id=\"Ucw-KI-kcT\"/>\n                                    <constraint firstItem=\"UVT-7V-jBv\" firstAttribute=\"baseline\" secondItem=\"dcv-3g-vPH\" secondAttribute=\"baseline\" id=\"cs7-9b-peH\"/>\n                                    <constraint firstItem=\"nFP-Bd-1kw\" firstAttribute=\"leading\" secondItem=\"4FP-Tx-TxJ\" secondAttribute=\"trailing\" constant=\"8\" id=\"dXX-jV-D7H\"/>\n                                    <constraint firstItem=\"t9s-30-kSA\" firstAttribute=\"leading\" secondItem=\"UVT-7V-jBv\" secondAttribute=\"trailing\" constant=\"8\" id=\"gCn-aY-cY4\"/>\n                                    <constraint firstItem=\"nFP-Bd-1kw\" firstAttribute=\"baseline\" secondItem=\"UVT-7V-jBv\" secondAttribute=\"baseline\" id=\"sZI-yf-P0b\"/>\n                                    <constraint firstItem=\"nFP-Bd-1kw\" firstAttribute=\"baseline\" secondItem=\"4FP-Tx-TxJ\" secondAttribute=\"baseline\" id=\"ytX-t2-NXt\"/>\n                                </constraints>\n                            </view>\n                        </subviews>\n                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                        <constraints>\n                            <constraint firstItem=\"Pfy-5l-wbH\" firstAttribute=\"top\" secondItem=\"k8L-yh-Uc9\" secondAttribute=\"bottom\" id=\"BO1-vQ-LLV\"/>\n                            <constraint firstItem=\"aHD-uZ-0hI\" firstAttribute=\"top\" secondItem=\"fAH-Mr-gHV\" secondAttribute=\"top\" id=\"N3K-aO-MAg\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"k8L-yh-Uc9\" secondAttribute=\"trailing\" id=\"R4w-xg-Ydq\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"aHD-uZ-0hI\" secondAttribute=\"trailing\" id=\"TmE-g2-rHx\"/>\n                            <constraint firstItem=\"k8L-yh-Uc9\" firstAttribute=\"top\" secondItem=\"aHD-uZ-0hI\" secondAttribute=\"bottom\" id=\"i3H-zp-gMO\"/>\n                            <constraint firstItem=\"k8L-yh-Uc9\" firstAttribute=\"leading\" secondItem=\"fAH-Mr-gHV\" secondAttribute=\"leading\" id=\"tBt-id-pd2\"/>\n                            <constraint firstItem=\"aHD-uZ-0hI\" firstAttribute=\"leading\" secondItem=\"fAH-Mr-gHV\" secondAttribute=\"leading\" id=\"yjB-e0-YGl\"/>\n                        </constraints>\n                    </view>\n                    <tabBarItem key=\"tabBarItem\" title=\"Advanced\" id=\"hpi-sc-HlI\"/>\n                    <freeformSimulatedSizeMetrics key=\"simulatedDestinationMetrics\"/>\n                    <size key=\"freeformSize\" width=\"375\" height=\"1000\"/>\n                    <connections>\n                        <outlet property=\"bottomEdgeLabel\" destination=\"752-5V-jQ8\" id=\"bOC-GZ-QUG\"/>\n                        <outlet property=\"bottomLeftCornerLabel\" destination=\"XNZ-ZV-PDL\" id=\"6uA-8X-myp\"/>\n                        <outlet property=\"bottomRightCornerLabel\" destination=\"Lxh-2a-bSu\" id=\"PIk-6X-6lV\"/>\n                        <outlet property=\"centreLabel\" destination=\"Y1h-NI-DD4\" id=\"SDD-x8-aSv\"/>\n                        <outlet property=\"compressedBlurImageView\" destination=\"wVZ-tm-8wt\" id=\"efz-1Q-rJD\"/>\n                        <outlet property=\"darknessBlurImageView\" destination=\"AIg-aT-T27\" id=\"m4q-Gt-XEp\"/>\n                        <outlet property=\"hashLabel\" destination=\"APC-rp-edX\" id=\"dVo-oy-OH0\"/>\n                        <outlet property=\"leftEdgeLabel\" destination=\"Hyz-JK-uvv\" id=\"2wM-Nl-5wq\"/>\n                        <outlet property=\"originalImageView\" destination=\"jbW-pm-Cg6\" id=\"DkX-lD-2Us\"/>\n                        <outlet property=\"rightEdgeLabel\" destination=\"rwg-7e-Nii\" id=\"2Ra-3k-1RU\"/>\n                        <outlet property=\"topEdgeLabel\" destination=\"Ivf-jp-J0F\" id=\"V9P-yS-GZS\"/>\n                        <outlet property=\"topLeftCornerLabel\" destination=\"QbV-sR-2CC\" id=\"u7w-vL-IG4\"/>\n                        <outlet property=\"topRightCornerLabel\" destination=\"g5m-pZ-G50\" id=\"8RW-PD-joC\"/>\n                        <outlet property=\"uncompressedBlurImageView\" destination=\"oPc-dA-gI3\" id=\"k8K-yT-oIV\"/>\n                        <outlet property=\"xComponentsLabel\" destination=\"UVT-7V-jBv\" id=\"nvT-md-JYP\"/>\n                        <outlet property=\"yComponentsLabel\" destination=\"nFP-Bd-1kw\" id=\"4GY-Rs-xGV\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"Vrs-Em-liA\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n                <tapGestureRecognizer id=\"auZ-KF-fNX\">\n                    <connections>\n                        <action selector=\"imageTapped\" destination=\"GoA-CQ-Oko\" id=\"Qlx-2D-Ar2\"/>\n                    </connections>\n                </tapGestureRecognizer>\n            </objects>\n            <point key=\"canvasLocation\" x=\"198\" y=\"148\"/>\n        </scene>\n        <!--Tab Bar Controller-->\n        <scene sceneID=\"8sD-Lj-Une\">\n            <objects>\n                <tabBarController id=\"ow8-qa-tQW\" sceneMemberID=\"viewController\">\n                    <tabBar key=\"tabBar\" contentMode=\"scaleToFill\" insetsLayoutMarginsFromSafeArea=\"NO\" id=\"1We-ew-nhn\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"49\"/>\n                        <autoresizingMask key=\"autoresizingMask\"/>\n                        <color key=\"backgroundColor\" white=\"0.0\" alpha=\"0.0\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                    </tabBar>\n                    <connections>\n                        <segue destination=\"BYZ-38-t0r\" kind=\"relationship\" relationship=\"viewControllers\" id=\"MSD-JF-mP5\"/>\n                        <segue destination=\"GoA-CQ-Oko\" kind=\"relationship\" relationship=\"viewControllers\" id=\"JRu-eR-uaB\"/>\n                        <segue destination=\"ieU-Ur-ANQ\" kind=\"relationship\" relationship=\"viewControllers\" id=\"gtC-0c-rsm\"/>\n                    </connections>\n                </tabBarController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"Nxb-Ud-Oy0\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"-754\" y=\"148\"/>\n        </scene>\n        <!--Simple-->\n        <scene sceneID=\"tne-QT-ifu\">\n            <objects>\n                <viewController id=\"BYZ-38-t0r\" customClass=\"SimpleViewController\" customModule=\"BlurHashTest\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"OWy-rO-KNt\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"wEW-By-gXh\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"8bC-Xf-vdC\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"667\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <scrollView clipsSubviews=\"YES\" multipleTouchEnabled=\"YES\" contentMode=\"scaleToFill\" alwaysBounceVertical=\"YES\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"zAY-rl-FzJ\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"483\"/>\n                                <subviews>\n                                    <stackView opaque=\"NO\" contentMode=\"scaleToFill\" axis=\"vertical\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"DfD-2w-NCY\">\n                                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"368\"/>\n                                        <subviews>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Cao-yg-vDf\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"128\"/>\n                                                <subviews>\n                                                    <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" placeholderIntrinsicWidth=\"240\" placeholderIntrinsicHeight=\"128\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"P5Q-KT-MGh\">\n                                                        <rect key=\"frame\" x=\"67.5\" y=\"0.0\" width=\"240\" height=\"128\"/>\n                                                        <gestureRecognizers/>\n                                                    </imageView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstItem=\"P5Q-KT-MGh\" firstAttribute=\"centerX\" secondItem=\"Cao-yg-vDf\" secondAttribute=\"centerX\" id=\"1fy-d7-6wF\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"P5Q-KT-MGh\" secondAttribute=\"bottom\" id=\"1m7-aS-CqU\"/>\n                                                    <constraint firstItem=\"P5Q-KT-MGh\" firstAttribute=\"top\" secondItem=\"Cao-yg-vDf\" secondAttribute=\"top\" id=\"Deo-JE-3nV\"/>\n                                                </constraints>\n                                            </view>\n                                            <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"⇩\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"7an-iG-mTE\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"128\" width=\"375\" height=\"48\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"height\" constant=\"48\" id=\"xcV-Hk-lgg\"/>\n                                                </constraints>\n                                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                <nil key=\"textColor\"/>\n                                                <nil key=\"highlightedColor\"/>\n                                            </label>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"xRg-WY-LeQ\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"176\" width=\"375\" height=\"16\"/>\n                                                <subviews>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"1000\" text=\"Hash goes here\" textAlignment=\"center\" lineBreakMode=\"characterWrap\" numberOfLines=\"0\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"tub-3a-hqA\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"16\"/>\n                                                        <fontDescription key=\"fontDescription\" name=\"Courier\" family=\"Courier\" pointSize=\"16\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstItem=\"tub-3a-hqA\" firstAttribute=\"leading\" secondItem=\"xRg-WY-LeQ\" secondAttribute=\"leading\" constant=\"16\" id=\"1p2-gM-4fX\"/>\n                                                    <constraint firstItem=\"tub-3a-hqA\" firstAttribute=\"top\" secondItem=\"xRg-WY-LeQ\" secondAttribute=\"top\" id=\"ab1-kR-1tG\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"tub-3a-hqA\" secondAttribute=\"bottom\" id=\"b7z-cX-mhj\"/>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"tub-3a-hqA\" secondAttribute=\"trailing\" constant=\"16\" id=\"dJb-W1-1VB\"/>\n                                                </constraints>\n                                            </view>\n                                            <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"⇩\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"MAm-8C-hIX\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"192\" width=\"375\" height=\"48\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"height\" constant=\"48\" id=\"Oj6-ab-Qb1\"/>\n                                                </constraints>\n                                                <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"17\"/>\n                                                <nil key=\"textColor\"/>\n                                                <nil key=\"highlightedColor\"/>\n                                            </label>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"ZbH-UL-Efd\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"240\" width=\"375\" height=\"128\"/>\n                                                <subviews>\n                                                    <imageView userInteractionEnabled=\"NO\" contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" placeholderIntrinsicWidth=\"240\" placeholderIntrinsicHeight=\"128\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"aqc-Px-Q6o\">\n                                                        <rect key=\"frame\" x=\"67.5\" y=\"0.0\" width=\"240\" height=\"128\"/>\n                                                    </imageView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"aqc-Px-Q6o\" secondAttribute=\"bottom\" id=\"TxC-s2-bYz\"/>\n                                                    <constraint firstItem=\"aqc-Px-Q6o\" firstAttribute=\"centerX\" secondItem=\"ZbH-UL-Efd\" secondAttribute=\"centerX\" id=\"Wcz-k7-Dpi\"/>\n                                                    <constraint firstItem=\"aqc-Px-Q6o\" firstAttribute=\"top\" secondItem=\"ZbH-UL-Efd\" secondAttribute=\"top\" id=\"z7N-4x-hCq\"/>\n                                                </constraints>\n                                            </view>\n                                        </subviews>\n                                        <gestureRecognizers/>\n                                        <constraints>\n                                            <constraint firstItem=\"aqc-Px-Q6o\" firstAttribute=\"width\" secondItem=\"P5Q-KT-MGh\" secondAttribute=\"width\" id=\"Cx8-nh-UlJ\"/>\n                                            <constraint firstItem=\"P5Q-KT-MGh\" firstAttribute=\"height\" secondItem=\"aqc-Px-Q6o\" secondAttribute=\"height\" id=\"efH-Av-RDb\"/>\n                                        </constraints>\n                                        <connections>\n                                            <outletCollection property=\"gestureRecognizers\" destination=\"M6f-Nq-Frc\" appends=\"YES\" id=\"3We-rQ-3Ug\"/>\n                                        </connections>\n                                    </stackView>\n                                </subviews>\n                                <constraints>\n                                    <constraint firstItem=\"DfD-2w-NCY\" firstAttribute=\"top\" secondItem=\"zAY-rl-FzJ\" secondAttribute=\"top\" id=\"m5p-qy-9nQ\"/>\n                                    <constraint firstAttribute=\"bottom\" secondItem=\"DfD-2w-NCY\" secondAttribute=\"bottom\" id=\"nuF-Sc-n62\"/>\n                                    <constraint firstItem=\"DfD-2w-NCY\" firstAttribute=\"leading\" secondItem=\"zAY-rl-FzJ\" secondAttribute=\"leading\" id=\"qRl-mV-Z6G\"/>\n                                    <constraint firstAttribute=\"trailing\" secondItem=\"DfD-2w-NCY\" secondAttribute=\"trailing\" id=\"ugG-N0-s52\"/>\n                                </constraints>\n                            </scrollView>\n                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Kkc-sL-6Tw\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"482.5\" width=\"375\" height=\"135.5\"/>\n                                <subviews>\n                                    <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"wvv-YL-UbN\">\n                                        <rect key=\"frame\" x=\"131.5\" y=\"76.5\" width=\"1\" height=\"48\"/>\n                                        <color key=\"backgroundColor\" white=\"0.80000000000000004\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"height\" constant=\"48\" id=\"LmL-Ir-p41\"/>\n                                            <constraint firstAttribute=\"width\" constant=\"1\" id=\"MV8-Uo-wCe\"/>\n                                        </constraints>\n                                    </view>\n                                    <slider opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" value=\"1\" minValue=\"0.0\" maxValue=\"3\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"mow-gN-Jql\">\n                                        <rect key=\"frame\" x=\"6\" y=\"85.5\" width=\"363\" height=\"31\"/>\n                                        <connections>\n                                            <action selector=\"sliderChangedWithSlider:\" destination=\"BYZ-38-t0r\" eventType=\"valueChanged\" id=\"184-6n-FUZ\"/>\n                                        </connections>\n                                    </slider>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"dPp-EI-EPd\">\n                                        <rect key=\"frame\" x=\"92\" y=\"8\" width=\"45\" height=\"45\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"height\" constant=\"45\" id=\"nfE-Ll-WyX\"/>\n                                            <constraint firstAttribute=\"width\" constant=\"45\" id=\"wOR-j8-4DX\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"+\"/>\n                                        <connections>\n                                            <action selector=\"xPlusTapped\" destination=\"BYZ-38-t0r\" eventType=\"touchUpInside\" id=\"CKI-0w-rXD\"/>\n                                        </connections>\n                                    </button>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"pom-Zb-FA3\">\n                                        <rect key=\"frame\" x=\"8\" y=\"6\" width=\"48\" height=\"48\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"48\" id=\"H9Z-XH-SmP\"/>\n                                            <constraint firstAttribute=\"height\" constant=\"48\" id=\"Hwe-ps-XCP\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"-\"/>\n                                        <connections>\n                                            <action selector=\"xMinusTapped\" destination=\"BYZ-38-t0r\" eventType=\"touchUpInside\" id=\"Bob-w5-jEc\"/>\n                                        </connections>\n                                    </button>\n                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"1000\" text=\"8\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"nzK-83-4if\">\n                                        <rect key=\"frame\" x=\"64\" y=\"16\" width=\"20\" height=\"29\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"20\" id=\"uut-UM-ggc\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                        <nil key=\"textColor\"/>\n                                        <nil key=\"highlightedColor\"/>\n                                    </label>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"FBw-7N-Tqf\">\n                                        <rect key=\"frame\" x=\"322\" y=\"7.5\" width=\"45\" height=\"45\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"height\" constant=\"45\" id=\"Iu5-fu-LZz\"/>\n                                            <constraint firstAttribute=\"width\" constant=\"45\" id=\"cPQ-7l-vlO\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"+\"/>\n                                        <connections>\n                                            <action selector=\"yPlusTapped\" destination=\"BYZ-38-t0r\" eventType=\"touchUpInside\" id=\"KWL-2p-PkF\"/>\n                                        </connections>\n                                    </button>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"n4J-R9-MNF\">\n                                        <rect key=\"frame\" x=\"238\" y=\"6.5\" width=\"48\" height=\"48\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"height\" constant=\"48\" id=\"Gdx-xs-RnS\"/>\n                                            <constraint firstAttribute=\"width\" constant=\"48\" id=\"i3f-l7-X41\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"27\"/>\n                                        <state key=\"normal\" title=\"-\"/>\n                                        <connections>\n                                            <action selector=\"yMinusTapped\" destination=\"BYZ-38-t0r\" eventType=\"touchUpInside\" id=\"BbN-cf-MYR\"/>\n                                        </connections>\n                                    </button>\n                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" text=\"8\" textAlignment=\"center\" lineBreakMode=\"tailTruncation\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Sjj-Ih-5FV\">\n                                        <rect key=\"frame\" x=\"294\" y=\"16\" width=\"20\" height=\"29\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"width\" constant=\"20\" id=\"Luy-k4-843\"/>\n                                        </constraints>\n                                        <fontDescription key=\"fontDescription\" type=\"system\" pointSize=\"24\"/>\n                                        <nil key=\"textColor\"/>\n                                        <nil key=\"highlightedColor\"/>\n                                    </label>\n                                </subviews>\n                                <color key=\"backgroundColor\" red=\"1\" green=\"1\" blue=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>\n                                <constraints>\n                                    <constraint firstItem=\"wvv-YL-UbN\" firstAttribute=\"centerX\" secondItem=\"mow-gN-Jql\" secondAttribute=\"centerX\" multiplier=\"0.666\" constant=\"8\" id=\"4vg-Id-oX7\"/>\n                                    <constraint firstItem=\"pom-Zb-FA3\" firstAttribute=\"leading\" secondItem=\"Kkc-sL-6Tw\" secondAttribute=\"leadingMargin\" id=\"70B-84-eVj\"/>\n                                    <constraint firstItem=\"FBw-7N-Tqf\" firstAttribute=\"trailing\" secondItem=\"Kkc-sL-6Tw\" secondAttribute=\"trailingMargin\" id=\"CC1-NS-k3Y\"/>\n                                    <constraint firstItem=\"Sjj-Ih-5FV\" firstAttribute=\"baseline\" secondItem=\"FBw-7N-Tqf\" secondAttribute=\"baseline\" id=\"HfQ-2j-0zT\"/>\n                                    <constraint firstItem=\"nzK-83-4if\" firstAttribute=\"baseline\" secondItem=\"pom-Zb-FA3\" secondAttribute=\"baseline\" id=\"Mev-Dk-0c9\"/>\n                                    <constraint firstItem=\"mow-gN-Jql\" firstAttribute=\"leading\" secondItem=\"Kkc-sL-6Tw\" secondAttribute=\"leadingMargin\" id=\"TFC-Dm-vNM\"/>\n                                    <constraint firstItem=\"nzK-83-4if\" firstAttribute=\"leading\" secondItem=\"pom-Zb-FA3\" secondAttribute=\"trailing\" constant=\"8\" id=\"V7W-aw-bbd\"/>\n                                    <constraint firstItem=\"mow-gN-Jql\" firstAttribute=\"trailing\" secondItem=\"Kkc-sL-6Tw\" secondAttribute=\"trailingMargin\" id=\"Xbw-Sb-YNg\"/>\n                                    <constraint firstItem=\"nzK-83-4if\" firstAttribute=\"baseline\" secondItem=\"dPp-EI-EPd\" secondAttribute=\"baseline\" id=\"Xzb-gN-PpM\"/>\n                                    <constraint firstItem=\"wvv-YL-UbN\" firstAttribute=\"centerY\" secondItem=\"mow-gN-Jql\" secondAttribute=\"centerY\" id=\"bXJ-Ni-buf\"/>\n                                    <constraint firstAttribute=\"bottom\" secondItem=\"mow-gN-Jql\" secondAttribute=\"bottom\" constant=\"20\" id=\"dmn-M8-d5e\"/>\n                                    <constraint firstItem=\"nzK-83-4if\" firstAttribute=\"baseline\" secondItem=\"Sjj-Ih-5FV\" secondAttribute=\"baseline\" id=\"eOD-6x-tQJ\"/>\n                                    <constraint firstItem=\"dPp-EI-EPd\" firstAttribute=\"leading\" secondItem=\"nzK-83-4if\" secondAttribute=\"trailing\" constant=\"8\" id=\"gE7-s6-0TE\"/>\n                                    <constraint firstItem=\"mow-gN-Jql\" firstAttribute=\"top\" secondItem=\"nzK-83-4if\" secondAttribute=\"bottom\" constant=\"40\" id=\"gZa-ha-f2r\"/>\n                                    <constraint firstItem=\"FBw-7N-Tqf\" firstAttribute=\"leading\" secondItem=\"Sjj-Ih-5FV\" secondAttribute=\"trailing\" constant=\"8\" id=\"n9q-fF-QMT\"/>\n                                    <constraint firstItem=\"Sjj-Ih-5FV\" firstAttribute=\"leading\" secondItem=\"n4J-R9-MNF\" secondAttribute=\"trailing\" constant=\"8\" id=\"nQr-Wv-PN4\"/>\n                                    <constraint firstItem=\"nzK-83-4if\" firstAttribute=\"top\" secondItem=\"Kkc-sL-6Tw\" secondAttribute=\"top\" constant=\"16\" id=\"rSn-r5-FKR\"/>\n                                    <constraint firstItem=\"Sjj-Ih-5FV\" firstAttribute=\"baseline\" secondItem=\"n4J-R9-MNF\" secondAttribute=\"baseline\" id=\"vf3-Bt-KPp\"/>\n                                </constraints>\n                            </view>\n                        </subviews>\n                        <color key=\"backgroundColor\" red=\"1\" green=\"1\" blue=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>\n                        <constraints>\n                            <constraint firstItem=\"zAY-rl-FzJ\" firstAttribute=\"top\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"top\" id=\"5Qk-p5-GK5\"/>\n                            <constraint firstItem=\"Kkc-sL-6Tw\" firstAttribute=\"top\" secondItem=\"zAY-rl-FzJ\" secondAttribute=\"bottom\" id=\"Aov-rD-aIH\"/>\n                            <constraint firstItem=\"zAY-rl-FzJ\" firstAttribute=\"leading\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"leading\" id=\"Nm2-ev-6n6\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"zAY-rl-FzJ\" secondAttribute=\"trailing\" id=\"Rwb-RE-vFn\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"Kkc-sL-6Tw\" secondAttribute=\"trailing\" id=\"f1K-FM-fsH\"/>\n                            <constraint firstItem=\"DfD-2w-NCY\" firstAttribute=\"width\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"width\" id=\"hVX-hx-CcD\"/>\n                            <constraint firstItem=\"Kkc-sL-6Tw\" firstAttribute=\"leading\" secondItem=\"8bC-Xf-vdC\" secondAttribute=\"leading\" id=\"oca-zB-JTc\"/>\n                            <constraint firstItem=\"wEW-By-gXh\" firstAttribute=\"top\" secondItem=\"Kkc-sL-6Tw\" secondAttribute=\"bottom\" id=\"rhI-oy-Qcu\"/>\n                        </constraints>\n                    </view>\n                    <tabBarItem key=\"tabBarItem\" title=\"Simple\" id=\"9Iu-DR-LXv\"/>\n                    <connections>\n                        <outlet property=\"blurImageView\" destination=\"aqc-Px-Q6o\" id=\"vFe-RW-vBc\"/>\n                        <outlet property=\"hashLabel\" destination=\"tub-3a-hqA\" id=\"w7D-xQ-9Qn\"/>\n                        <outlet property=\"originalImageView\" destination=\"P5Q-KT-MGh\" id=\"oK0-BN-PK3\"/>\n                        <outlet property=\"xComponentsLabel\" destination=\"nzK-83-4if\" id=\"DLz-x8-yNz\"/>\n                        <outlet property=\"yComponentsLabel\" destination=\"Sjj-Ih-5FV\" id=\"k0G-pQ-GQq\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"dkx-z0-nzr\" sceneMemberID=\"firstResponder\"/>\n                <tapGestureRecognizer id=\"M6f-Nq-Frc\">\n                    <connections>\n                        <action selector=\"imageTapped\" destination=\"BYZ-38-t0r\" id=\"Hhv-Mr-j4m\"/>\n                    </connections>\n                </tapGestureRecognizer>\n            </objects>\n            <point key=\"canvasLocation\" x=\"198\" y=\"-576\"/>\n        </scene>\n        <!--Generated-->\n        <scene sceneID=\"NOY-B9-bA2\">\n            <objects>\n                <viewController id=\"ieU-Ur-ANQ\" customClass=\"GeneratedViewController\" customModule=\"BlurHashTest\" customModuleProvider=\"target\" sceneMemberID=\"viewController\">\n                    <layoutGuides>\n                        <viewControllerLayoutGuide type=\"top\" id=\"jrB-Vn-KjF\"/>\n                        <viewControllerLayoutGuide type=\"bottom\" id=\"U20-p6-Vfo\"/>\n                    </layoutGuides>\n                    <view key=\"view\" contentMode=\"scaleToFill\" id=\"9Ht-Zj-35m\">\n                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"667\"/>\n                        <autoresizingMask key=\"autoresizingMask\" widthSizable=\"YES\" heightSizable=\"YES\"/>\n                        <subviews>\n                            <scrollView clipsSubviews=\"YES\" multipleTouchEnabled=\"YES\" contentMode=\"scaleToFill\" alwaysBounceVertical=\"YES\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"OiX-cZ-DuB\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"570\"/>\n                                <subviews>\n                                    <stackView opaque=\"NO\" contentMode=\"scaleToFill\" axis=\"vertical\" spacing=\"16\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"nI3-Nb-BBU\">\n                                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"481.5\"/>\n                                        <subviews>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"zMO-tx-PSM\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"118\"/>\n                                                <subviews>\n                                                    <stackView opaque=\"NO\" contentMode=\"scaleToFill\" alignment=\"center\" spacing=\"16\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"7DP-rI-WZI\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"118\"/>\n                                                        <subviews>\n                                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"nBd-Uw-V1a\">\n                                                                <rect key=\"frame\" x=\"0.0\" y=\"44.5\" width=\"29.5\" height=\"29\"/>\n                                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"nBd-Uw-V1a\" secondAttribute=\"height\" id=\"koh-wr-pN0\"/>\n                                                                </constraints>\n                                                            </view>\n                                                            <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"uJQ-pG-3ne\">\n                                                                <rect key=\"frame\" x=\"45.5\" y=\"0.0\" width=\"118\" height=\"118\"/>\n                                                                <gestureRecognizers/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"uJQ-pG-3ne\" secondAttribute=\"height\" id=\"xSV-S2-Pmt\"/>\n                                                                </constraints>\n                                                                <connections>\n                                                                    <outletCollection property=\"gestureRecognizers\" destination=\"nbx-vo-oxi\" appends=\"YES\" id=\"x5F-rP-aMR\"/>\n                                                                </connections>\n                                                            </imageView>\n                                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"nTn-FV-dGN\">\n                                                                <rect key=\"frame\" x=\"179.5\" y=\"44\" width=\"29.5\" height=\"30\"/>\n                                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"nTn-FV-dGN\" secondAttribute=\"height\" multiplier=\"1:1\" id=\"Z1A-19-2wx\"/>\n                                                                </constraints>\n                                                            </view>\n                                                            <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"0Lz-yC-ahj\">\n                                                                <rect key=\"frame\" x=\"225\" y=\"0.0\" width=\"118\" height=\"118\"/>\n                                                                <gestureRecognizers/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"0Lz-yC-ahj\" secondAttribute=\"height\" id=\"b2d-S7-DZf\"/>\n                                                                </constraints>\n                                                            </imageView>\n                                                        </subviews>\n                                                        <constraints>\n                                                            <constraint firstItem=\"nTn-FV-dGN\" firstAttribute=\"width\" secondItem=\"0Lz-yC-ahj\" secondAttribute=\"width\" multiplier=\"1:4\" id=\"Hbz-aW-UOd\"/>\n                                                            <constraint firstItem=\"0Lz-yC-ahj\" firstAttribute=\"width\" secondItem=\"uJQ-pG-3ne\" secondAttribute=\"width\" id=\"Wyc-8k-rsK\"/>\n                                                            <constraint firstItem=\"nBd-Uw-V1a\" firstAttribute=\"width\" secondItem=\"uJQ-pG-3ne\" secondAttribute=\"width\" multiplier=\"1:4\" id=\"gDE-Vo-RZl\"/>\n                                                            <constraint firstAttribute=\"height\" secondItem=\"uJQ-pG-3ne\" secondAttribute=\"height\" id=\"rGP-ny-WRW\"/>\n                                                        </constraints>\n                                                    </stackView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"7DP-rI-WZI\" secondAttribute=\"trailing\" constant=\"16\" id=\"CcK-dH-GBi\"/>\n                                                    <constraint firstItem=\"7DP-rI-WZI\" firstAttribute=\"leading\" secondItem=\"zMO-tx-PSM\" secondAttribute=\"leading\" constant=\"16\" id=\"OWm-Uv-wxO\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"7DP-rI-WZI\" secondAttribute=\"bottom\" id=\"rMA-yQ-UHp\"/>\n                                                    <constraint firstItem=\"7DP-rI-WZI\" firstAttribute=\"top\" secondItem=\"zMO-tx-PSM\" secondAttribute=\"top\" id=\"tSA-fF-y5d\"/>\n                                                </constraints>\n                                            </view>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"OXi-in-RbQ\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"134\" width=\"375\" height=\"16\"/>\n                                                <subviews>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"1000\" text=\"Hash goes here\" textAlignment=\"center\" lineBreakMode=\"characterWrap\" numberOfLines=\"0\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"oJ9-fc-rpC\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"16\"/>\n                                                        <fontDescription key=\"fontDescription\" name=\"Courier\" family=\"Courier\" pointSize=\"16\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"oJ9-fc-rpC\" secondAttribute=\"bottom\" id=\"75l-Fa-Pwq\"/>\n                                                    <constraint firstItem=\"oJ9-fc-rpC\" firstAttribute=\"top\" secondItem=\"OXi-in-RbQ\" secondAttribute=\"top\" id=\"OBq-7z-oNI\"/>\n                                                    <constraint firstItem=\"oJ9-fc-rpC\" firstAttribute=\"leading\" secondItem=\"OXi-in-RbQ\" secondAttribute=\"leading\" constant=\"16\" id=\"XcM-n7-fZ2\"/>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"oJ9-fc-rpC\" secondAttribute=\"trailing\" constant=\"16\" id=\"mEa-MV-qjO\"/>\n                                                </constraints>\n                                            </view>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"zml-8h-D7V\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"166\" width=\"375\" height=\"118\"/>\n                                                <subviews>\n                                                    <stackView opaque=\"NO\" contentMode=\"scaleToFill\" alignment=\"center\" spacing=\"16\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"iOO-51-zGo\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"118\"/>\n                                                        <subviews>\n                                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"lds-gs-sJ2\">\n                                                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"29.5\" height=\"118\"/>\n                                                                <subviews>\n                                                                    <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"qvi-2F-PxB\">\n                                                                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"29.5\" height=\"29.5\"/>\n                                                                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                        <constraints>\n                                                                            <constraint firstAttribute=\"width\" secondItem=\"qvi-2F-PxB\" secondAttribute=\"height\" id=\"gzn-ch-ZaO\"/>\n                                                                        </constraints>\n                                                                    </view>\n                                                                    <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"te0-f2-YUl\">\n                                                                        <rect key=\"frame\" x=\"0.0\" y=\"88.5\" width=\"29.5\" height=\"29.5\"/>\n                                                                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                        <constraints>\n                                                                            <constraint firstAttribute=\"width\" secondItem=\"te0-f2-YUl\" secondAttribute=\"height\" id=\"GSS-gs-1E8\"/>\n                                                                        </constraints>\n                                                                    </view>\n                                                                </subviews>\n                                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"trailing\" secondItem=\"te0-f2-YUl\" secondAttribute=\"trailing\" id=\"8xO-JJ-MHF\"/>\n                                                                    <constraint firstItem=\"te0-f2-YUl\" firstAttribute=\"leading\" secondItem=\"lds-gs-sJ2\" secondAttribute=\"leading\" id=\"PLu-12-Zoa\"/>\n                                                                    <constraint firstItem=\"qvi-2F-PxB\" firstAttribute=\"top\" secondItem=\"lds-gs-sJ2\" secondAttribute=\"top\" id=\"bhi-Mf-ZmS\"/>\n                                                                    <constraint firstAttribute=\"trailing\" secondItem=\"qvi-2F-PxB\" secondAttribute=\"trailing\" id=\"dUf-ma-RWp\"/>\n                                                                    <constraint firstItem=\"qvi-2F-PxB\" firstAttribute=\"leading\" secondItem=\"lds-gs-sJ2\" secondAttribute=\"leading\" id=\"w58-8c-vvC\"/>\n                                                                    <constraint firstAttribute=\"bottom\" secondItem=\"te0-f2-YUl\" secondAttribute=\"bottom\" id=\"z23-LA-q1J\"/>\n                                                                </constraints>\n                                                            </view>\n                                                            <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"1z6-Mz-QyS\">\n                                                                <rect key=\"frame\" x=\"45.5\" y=\"0.0\" width=\"118\" height=\"118\"/>\n                                                                <gestureRecognizers/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"1z6-Mz-QyS\" secondAttribute=\"height\" id=\"BA1-Kw-Or5\"/>\n                                                                </constraints>\n                                                            </imageView>\n                                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"ZI8-Og-CKj\">\n                                                                <rect key=\"frame\" x=\"179.5\" y=\"0.0\" width=\"29.5\" height=\"118\"/>\n                                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                            </view>\n                                                            <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"xzE-aB-s59\">\n                                                                <rect key=\"frame\" x=\"225\" y=\"0.0\" width=\"118\" height=\"118\"/>\n                                                                <gestureRecognizers/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"xzE-aB-s59\" secondAttribute=\"height\" id=\"Bmb-kk-81B\"/>\n                                                                </constraints>\n                                                            </imageView>\n                                                        </subviews>\n                                                        <constraints>\n                                                            <constraint firstItem=\"ZI8-Og-CKj\" firstAttribute=\"width\" secondItem=\"xzE-aB-s59\" secondAttribute=\"width\" multiplier=\"1:4\" id=\"4bj-v3-0ob\"/>\n                                                            <constraint firstItem=\"ZI8-Og-CKj\" firstAttribute=\"height\" secondItem=\"iOO-51-zGo\" secondAttribute=\"height\" id=\"KKe-q6-V2l\"/>\n                                                            <constraint firstAttribute=\"height\" secondItem=\"1z6-Mz-QyS\" secondAttribute=\"height\" id=\"SWD-x6-XQf\"/>\n                                                            <constraint firstItem=\"lds-gs-sJ2\" firstAttribute=\"height\" secondItem=\"iOO-51-zGo\" secondAttribute=\"height\" id=\"TWf-2v-8sh\"/>\n                                                            <constraint firstItem=\"lds-gs-sJ2\" firstAttribute=\"width\" secondItem=\"1z6-Mz-QyS\" secondAttribute=\"width\" multiplier=\"1:4\" id=\"oVv-NO-fYW\"/>\n                                                            <constraint firstItem=\"xzE-aB-s59\" firstAttribute=\"width\" secondItem=\"1z6-Mz-QyS\" secondAttribute=\"width\" id=\"uhW-36-G23\"/>\n                                                        </constraints>\n                                                    </stackView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstItem=\"iOO-51-zGo\" firstAttribute=\"leading\" secondItem=\"zml-8h-D7V\" secondAttribute=\"leading\" constant=\"16\" id=\"g96-Gz-X5i\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"iOO-51-zGo\" secondAttribute=\"bottom\" id=\"uMQ-yd-JEb\"/>\n                                                    <constraint firstItem=\"iOO-51-zGo\" firstAttribute=\"top\" secondItem=\"zml-8h-D7V\" secondAttribute=\"top\" id=\"xtp-V1-8b4\"/>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"iOO-51-zGo\" secondAttribute=\"trailing\" constant=\"16\" id=\"y5G-jm-BRM\"/>\n                                                </constraints>\n                                            </view>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"HOn-we-vW1\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"300\" width=\"375\" height=\"16\"/>\n                                                <subviews>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"1000\" text=\"Hash goes here\" textAlignment=\"center\" lineBreakMode=\"characterWrap\" numberOfLines=\"0\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"ODR-OG-Qrx\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"16\"/>\n                                                        <fontDescription key=\"fontDescription\" name=\"Courier\" family=\"Courier\" pointSize=\"16\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstItem=\"ODR-OG-Qrx\" firstAttribute=\"top\" secondItem=\"HOn-we-vW1\" secondAttribute=\"top\" id=\"0l6-EJ-G0x\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"ODR-OG-Qrx\" secondAttribute=\"bottom\" id=\"HYb-qG-tJC\"/>\n                                                    <constraint firstItem=\"ODR-OG-Qrx\" firstAttribute=\"leading\" secondItem=\"HOn-we-vW1\" secondAttribute=\"leading\" constant=\"16\" id=\"UjN-8W-Frh\"/>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"ODR-OG-Qrx\" secondAttribute=\"trailing\" constant=\"16\" id=\"x0z-lz-3l4\"/>\n                                                </constraints>\n                                            </view>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"RO2-Tp-p9h\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"332\" width=\"375\" height=\"117.5\"/>\n                                                <subviews>\n                                                    <stackView opaque=\"NO\" contentMode=\"scaleToFill\" alignment=\"center\" spacing=\"16\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"QEz-V4-8bE\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"117.5\"/>\n                                                        <subviews>\n                                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"P8F-48-18L\">\n                                                                <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"30\" height=\"117.5\"/>\n                                                                <subviews>\n                                                                    <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"gMu-7g-yMT\">\n                                                                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"30\" height=\"30\"/>\n                                                                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                        <constraints>\n                                                                            <constraint firstAttribute=\"width\" secondItem=\"gMu-7g-yMT\" secondAttribute=\"height\" id=\"IxH-LG-fHS\"/>\n                                                                        </constraints>\n                                                                    </view>\n                                                                    <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"coh-ki-69y\">\n                                                                        <rect key=\"frame\" x=\"0.0\" y=\"87.5\" width=\"30\" height=\"30\"/>\n                                                                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                        <constraints>\n                                                                            <constraint firstAttribute=\"width\" secondItem=\"coh-ki-69y\" secondAttribute=\"height\" id=\"mxU-tr-TWD\"/>\n                                                                        </constraints>\n                                                                    </view>\n                                                                </subviews>\n                                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                <constraints>\n                                                                    <constraint firstItem=\"coh-ki-69y\" firstAttribute=\"leading\" secondItem=\"P8F-48-18L\" secondAttribute=\"leading\" id=\"4xn-aT-DrO\"/>\n                                                                    <constraint firstItem=\"gMu-7g-yMT\" firstAttribute=\"leading\" secondItem=\"P8F-48-18L\" secondAttribute=\"leading\" id=\"8ht-Ed-glO\"/>\n                                                                    <constraint firstAttribute=\"bottom\" secondItem=\"coh-ki-69y\" secondAttribute=\"bottom\" id=\"GvK-Yf-Glh\"/>\n                                                                    <constraint firstItem=\"gMu-7g-yMT\" firstAttribute=\"top\" secondItem=\"P8F-48-18L\" secondAttribute=\"top\" id=\"fH2-U8-HpM\"/>\n                                                                    <constraint firstAttribute=\"trailing\" secondItem=\"gMu-7g-yMT\" secondAttribute=\"trailing\" id=\"o5w-Ho-3cq\"/>\n                                                                    <constraint firstAttribute=\"trailing\" secondItem=\"coh-ki-69y\" secondAttribute=\"trailing\" id=\"qyC-mz-Ww5\"/>\n                                                                </constraints>\n                                                            </view>\n                                                            <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"f9s-eI-MLC\">\n                                                                <rect key=\"frame\" x=\"46\" y=\"0.0\" width=\"117.5\" height=\"117.5\"/>\n                                                                <gestureRecognizers/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"f9s-eI-MLC\" secondAttribute=\"height\" id=\"lp3-Kc-m1P\"/>\n                                                                </constraints>\n                                                            </imageView>\n                                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"foN-P7-xvH\">\n                                                                <rect key=\"frame\" x=\"179.5\" y=\"0.0\" width=\"29.5\" height=\"117.5\"/>\n                                                                <subviews>\n                                                                    <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"FNG-mj-Vnw\">\n                                                                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"29.5\" height=\"29.5\"/>\n                                                                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                        <constraints>\n                                                                            <constraint firstAttribute=\"width\" secondItem=\"FNG-mj-Vnw\" secondAttribute=\"height\" id=\"rXX-mT-vFX\"/>\n                                                                        </constraints>\n                                                                    </view>\n                                                                    <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"NGt-FT-U7U\">\n                                                                        <rect key=\"frame\" x=\"0.0\" y=\"88\" width=\"29.5\" height=\"29.5\"/>\n                                                                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                        <constraints>\n                                                                            <constraint firstAttribute=\"width\" secondItem=\"NGt-FT-U7U\" secondAttribute=\"height\" id=\"2qK-N7-bUe\"/>\n                                                                        </constraints>\n                                                                    </view>\n                                                                </subviews>\n                                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"trailing\" secondItem=\"FNG-mj-Vnw\" secondAttribute=\"trailing\" id=\"35f-Oh-Z0X\"/>\n                                                                    <constraint firstItem=\"FNG-mj-Vnw\" firstAttribute=\"leading\" secondItem=\"foN-P7-xvH\" secondAttribute=\"leading\" id=\"Hdv-BU-6fl\"/>\n                                                                    <constraint firstAttribute=\"bottom\" secondItem=\"NGt-FT-U7U\" secondAttribute=\"bottom\" id=\"JxH-DV-QNB\"/>\n                                                                    <constraint firstAttribute=\"trailing\" secondItem=\"NGt-FT-U7U\" secondAttribute=\"trailing\" id=\"Z7K-Pd-HgP\"/>\n                                                                    <constraint firstItem=\"FNG-mj-Vnw\" firstAttribute=\"top\" secondItem=\"foN-P7-xvH\" secondAttribute=\"top\" id=\"hIv-bG-JhV\"/>\n                                                                    <constraint firstItem=\"NGt-FT-U7U\" firstAttribute=\"leading\" secondItem=\"foN-P7-xvH\" secondAttribute=\"leading\" id=\"nNg-C6-faM\"/>\n                                                                </constraints>\n                                                            </view>\n                                                            <imageView contentMode=\"scaleToFill\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"251\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"HCU-rK-iSi\">\n                                                                <rect key=\"frame\" x=\"225\" y=\"0.0\" width=\"118\" height=\"117.5\"/>\n                                                                <gestureRecognizers/>\n                                                                <constraints>\n                                                                    <constraint firstAttribute=\"width\" secondItem=\"HCU-rK-iSi\" secondAttribute=\"height\" id=\"fyV-48-BI4\"/>\n                                                                </constraints>\n                                                            </imageView>\n                                                        </subviews>\n                                                        <constraints>\n                                                            <constraint firstItem=\"foN-P7-xvH\" firstAttribute=\"width\" secondItem=\"HCU-rK-iSi\" secondAttribute=\"width\" multiplier=\"1:4\" id=\"2mP-B7-9Ng\"/>\n                                                            <constraint firstItem=\"HCU-rK-iSi\" firstAttribute=\"width\" secondItem=\"f9s-eI-MLC\" secondAttribute=\"width\" id=\"Rhg-QH-6rn\"/>\n                                                            <constraint firstAttribute=\"height\" secondItem=\"f9s-eI-MLC\" secondAttribute=\"height\" id=\"hmT-we-EIh\"/>\n                                                            <constraint firstItem=\"foN-P7-xvH\" firstAttribute=\"height\" secondItem=\"QEz-V4-8bE\" secondAttribute=\"height\" id=\"i3W-To-jis\"/>\n                                                            <constraint firstItem=\"P8F-48-18L\" firstAttribute=\"height\" secondItem=\"QEz-V4-8bE\" secondAttribute=\"height\" id=\"lng-VS-o5r\"/>\n                                                            <constraint firstItem=\"P8F-48-18L\" firstAttribute=\"width\" secondItem=\"f9s-eI-MLC\" secondAttribute=\"width\" multiplier=\"1:4\" id=\"tX2-bu-MgL\"/>\n                                                        </constraints>\n                                                    </stackView>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"QEz-V4-8bE\" secondAttribute=\"bottom\" id=\"LyO-JQ-tY7\"/>\n                                                    <constraint firstItem=\"QEz-V4-8bE\" firstAttribute=\"top\" secondItem=\"RO2-Tp-p9h\" secondAttribute=\"top\" id=\"WDI-lG-DdS\"/>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"QEz-V4-8bE\" secondAttribute=\"trailing\" constant=\"16\" id=\"bIG-zK-Xtl\"/>\n                                                    <constraint firstItem=\"QEz-V4-8bE\" firstAttribute=\"leading\" secondItem=\"RO2-Tp-p9h\" secondAttribute=\"leading\" constant=\"16\" id=\"llz-Ia-h5O\"/>\n                                                </constraints>\n                                            </view>\n                                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"U76-Ud-6N8\">\n                                                <rect key=\"frame\" x=\"0.0\" y=\"465.5\" width=\"375\" height=\"16\"/>\n                                                <subviews>\n                                                    <label opaque=\"NO\" userInteractionEnabled=\"NO\" contentMode=\"left\" horizontalHuggingPriority=\"251\" verticalHuggingPriority=\"1000\" text=\"Hash goes here\" textAlignment=\"center\" lineBreakMode=\"characterWrap\" numberOfLines=\"0\" baselineAdjustment=\"alignBaselines\" adjustsFontSizeToFit=\"NO\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"fEF-Tp-CJy\">\n                                                        <rect key=\"frame\" x=\"16\" y=\"0.0\" width=\"343\" height=\"16\"/>\n                                                        <fontDescription key=\"fontDescription\" name=\"Courier\" family=\"Courier\" pointSize=\"16\"/>\n                                                        <nil key=\"textColor\"/>\n                                                        <nil key=\"highlightedColor\"/>\n                                                    </label>\n                                                </subviews>\n                                                <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                                                <constraints>\n                                                    <constraint firstAttribute=\"trailing\" secondItem=\"fEF-Tp-CJy\" secondAttribute=\"trailing\" constant=\"16\" id=\"2nF-AN-e0T\"/>\n                                                    <constraint firstAttribute=\"bottom\" secondItem=\"fEF-Tp-CJy\" secondAttribute=\"bottom\" id=\"NHU-qD-xqp\"/>\n                                                    <constraint firstItem=\"fEF-Tp-CJy\" firstAttribute=\"leading\" secondItem=\"U76-Ud-6N8\" secondAttribute=\"leading\" constant=\"16\" id=\"Xp0-Qi-Vr1\"/>\n                                                    <constraint firstItem=\"fEF-Tp-CJy\" firstAttribute=\"top\" secondItem=\"U76-Ud-6N8\" secondAttribute=\"top\" id=\"hyR-MI-8h5\"/>\n                                                </constraints>\n                                            </view>\n                                        </subviews>\n                                    </stackView>\n                                </subviews>\n                                <constraints>\n                                    <constraint firstItem=\"nI3-Nb-BBU\" firstAttribute=\"width\" secondItem=\"OiX-cZ-DuB\" secondAttribute=\"width\" id=\"084-VX-nrj\"/>\n                                    <constraint firstItem=\"nI3-Nb-BBU\" firstAttribute=\"leading\" secondItem=\"OiX-cZ-DuB\" secondAttribute=\"leading\" id=\"9w4-ej-NRk\"/>\n                                    <constraint firstItem=\"nI3-Nb-BBU\" firstAttribute=\"top\" secondItem=\"OiX-cZ-DuB\" secondAttribute=\"top\" id=\"A4B-jG-ucL\"/>\n                                    <constraint firstAttribute=\"trailing\" secondItem=\"nI3-Nb-BBU\" secondAttribute=\"trailing\" id=\"cck-ss-aa6\"/>\n                                    <constraint firstAttribute=\"bottom\" secondItem=\"nI3-Nb-BBU\" secondAttribute=\"bottom\" id=\"yCB-tR-Zdn\"/>\n                                </constraints>\n                            </scrollView>\n                            <view contentMode=\"scaleToFill\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"Rqx-x4-v7Z\">\n                                <rect key=\"frame\" x=\"0.0\" y=\"570\" width=\"375\" height=\"48\"/>\n                                <subviews>\n                                    <button opaque=\"NO\" contentMode=\"scaleToFill\" contentHorizontalAlignment=\"center\" contentVerticalAlignment=\"center\" buttonType=\"roundedRect\" lineBreakMode=\"middleTruncation\" translatesAutoresizingMaskIntoConstraints=\"NO\" id=\"gFD-tb-P7p\">\n                                        <rect key=\"frame\" x=\"0.0\" y=\"0.0\" width=\"375\" height=\"48\"/>\n                                        <constraints>\n                                            <constraint firstAttribute=\"height\" constant=\"48\" id=\"tTy-bV-PG7\"/>\n                                        </constraints>\n                                        <state key=\"normal\" title=\"Randomise\"/>\n                                        <connections>\n                                            <action selector=\"randomiseTapped\" destination=\"ieU-Ur-ANQ\" eventType=\"touchUpInside\" id=\"wHF-5D-wL9\"/>\n                                        </connections>\n                                    </button>\n                                </subviews>\n                                <color key=\"backgroundColor\" red=\"1\" green=\"1\" blue=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"sRGB\"/>\n                                <constraints>\n                                    <constraint firstItem=\"gFD-tb-P7p\" firstAttribute=\"top\" secondItem=\"Rqx-x4-v7Z\" secondAttribute=\"top\" id=\"Y2d-hA-CPb\"/>\n                                    <constraint firstAttribute=\"trailing\" secondItem=\"gFD-tb-P7p\" secondAttribute=\"trailing\" id=\"tqF-rr-C6R\"/>\n                                    <constraint firstItem=\"gFD-tb-P7p\" firstAttribute=\"leading\" secondItem=\"Rqx-x4-v7Z\" secondAttribute=\"leading\" id=\"yCR-eL-cvk\"/>\n                                </constraints>\n                            </view>\n                        </subviews>\n                        <color key=\"backgroundColor\" white=\"1\" alpha=\"1\" colorSpace=\"custom\" customColorSpace=\"genericGamma22GrayColorSpace\"/>\n                        <constraints>\n                            <constraint firstItem=\"OiX-cZ-DuB\" firstAttribute=\"leading\" secondItem=\"9Ht-Zj-35m\" secondAttribute=\"leading\" id=\"1Yw-wB-kjU\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"Rqx-x4-v7Z\" secondAttribute=\"trailing\" id=\"Bfc-eo-dyt\"/>\n                            <constraint firstItem=\"U20-p6-Vfo\" firstAttribute=\"top\" secondItem=\"gFD-tb-P7p\" secondAttribute=\"bottom\" id=\"BpF-t3-HVn\"/>\n                            <constraint firstItem=\"U20-p6-Vfo\" firstAttribute=\"top\" secondItem=\"Rqx-x4-v7Z\" secondAttribute=\"bottom\" id=\"CoA-ef-IGa\"/>\n                            <constraint firstItem=\"OiX-cZ-DuB\" firstAttribute=\"top\" secondItem=\"9Ht-Zj-35m\" secondAttribute=\"top\" id=\"PXm-Nk-9KM\"/>\n                            <constraint firstItem=\"Rqx-x4-v7Z\" firstAttribute=\"leading\" secondItem=\"9Ht-Zj-35m\" secondAttribute=\"leading\" id=\"bOi-bw-nc9\"/>\n                            <constraint firstAttribute=\"trailing\" secondItem=\"OiX-cZ-DuB\" secondAttribute=\"trailing\" id=\"l3L-ta-qKW\"/>\n                            <constraint firstItem=\"Rqx-x4-v7Z\" firstAttribute=\"top\" secondItem=\"OiX-cZ-DuB\" secondAttribute=\"bottom\" id=\"lxS-4p-8WQ\"/>\n                        </constraints>\n                    </view>\n                    <tabBarItem key=\"tabBarItem\" title=\"Generated\" id=\"8sH-aA-Ohl\"/>\n                    <connections>\n                        <outlet property=\"cornerBottomLeftView\" destination=\"coh-ki-69y\" id=\"DHw-cF-rpi\"/>\n                        <outlet property=\"cornerBottomRightView\" destination=\"NGt-FT-U7U\" id=\"CxX-vB-Fmb\"/>\n                        <outlet property=\"cornerCompressedImageView\" destination=\"HCU-rK-iSi\" id=\"XV0-Tz-RlQ\"/>\n                        <outlet property=\"cornerHashLabel\" destination=\"fEF-Tp-CJy\" id=\"uDh-GQ-zt3\"/>\n                        <outlet property=\"cornerTopLeftView\" destination=\"gMu-7g-yMT\" id=\"fO2-Rm-NYB\"/>\n                        <outlet property=\"cornerTopRightView\" destination=\"FNG-mj-Vnw\" id=\"1NB-ul-NWG\"/>\n                        <outlet property=\"cornerUncompressedImageView\" destination=\"f9s-eI-MLC\" id=\"ySq-Pg-u8e\"/>\n                        <outlet property=\"horizontalCompressedImageView\" destination=\"0Lz-yC-ahj\" id=\"4kU-Vr-xhO\"/>\n                        <outlet property=\"horizontalHashLabel\" destination=\"oJ9-fc-rpC\" id=\"gyz-92-BN7\"/>\n                        <outlet property=\"horizontalLeftView\" destination=\"nBd-Uw-V1a\" id=\"Nqk-Tc-nlm\"/>\n                        <outlet property=\"horizontalRightView\" destination=\"nTn-FV-dGN\" id=\"PQF-rD-Znn\"/>\n                        <outlet property=\"horizontalUncompressedImageView\" destination=\"uJQ-pG-3ne\" id=\"uJw-Yu-YlR\"/>\n                        <outlet property=\"verticalBottomView\" destination=\"te0-f2-YUl\" id=\"x8S-tt-4QF\"/>\n                        <outlet property=\"verticalCompressedImageView\" destination=\"xzE-aB-s59\" id=\"CDD-5m-Jtt\"/>\n                        <outlet property=\"verticalHashLabel\" destination=\"ODR-OG-Qrx\" id=\"iLI-w2-lB7\"/>\n                        <outlet property=\"verticalTopView\" destination=\"qvi-2F-PxB\" id=\"xlJ-fn-3yO\"/>\n                        <outlet property=\"verticalUncompressedImageView\" destination=\"1z6-Mz-QyS\" id=\"18k-gC-Rd9\"/>\n                    </connections>\n                </viewController>\n                <placeholder placeholderIdentifier=\"IBFirstResponder\" id=\"EVj-kF-JnH\" userLabel=\"First Responder\" sceneMemberID=\"firstResponder\"/>\n                <tapGestureRecognizer id=\"nbx-vo-oxi\"/>\n            </objects>\n            <point key=\"canvasLocation\" x=\"197.59999999999999\" y=\"903.59820089955031\"/>\n        </scene>\n    </scenes>\n</document>\n"
  },
  {
    "path": "Swift/BlurHashTest/GeneratedViewController.swift",
    "content": "import UIKit\nimport BlurHashKit\n\nclass GeneratedViewController: UIViewController {\n    @IBOutlet weak var horizontalUncompressedImageView: UIImageView?\n    @IBOutlet weak var horizontalCompressedImageView: UIImageView?\n    @IBOutlet weak var horizontalLeftView: UIView?\n    @IBOutlet weak var horizontalRightView: UIView?\n    @IBOutlet weak var horizontalHashLabel: UILabel?\n\n    @IBOutlet weak var verticalUncompressedImageView: UIImageView?\n    @IBOutlet weak var verticalCompressedImageView: UIImageView?\n    @IBOutlet weak var verticalTopView: UIView?\n    @IBOutlet weak var verticalBottomView: UIView?\n    @IBOutlet weak var verticalHashLabel: UILabel?\n\n    @IBOutlet weak var cornerUncompressedImageView: UIImageView?\n    @IBOutlet weak var cornerCompressedImageView: UIImageView?\n    @IBOutlet weak var cornerTopLeftView: UIView?\n    @IBOutlet weak var cornerTopRightView: UIView?\n    @IBOutlet weak var cornerBottomLeftView: UIView?\n    @IBOutlet weak var cornerBottomRightView: UIView?\n    @IBOutlet weak var cornerHashLabel: UILabel?\n\n/*\tprivate var horizontalLeftColour = UIColor.red\n\tprivate var horizontalRightColour = UIColor.green\n\tprivate var verticalTopColour = UIColor.white\n\tprivate var verticalBottomColour = UIColor.black\n\tprivate var cornerTopLeftColour = UIColor.white\n\tprivate var cornerTopRightColour = UIColor.red\n\tprivate var cornerBottomLeftColour = UIColor.green\n\tprivate var cornerBottomRightColour = UIColor.black\n*/\n\tprivate var horizontalLeftColour = UIColor.white\n\tprivate var horizontalRightColour = UIColor.black\n\tprivate var verticalTopColour = UIColor.white\n\tprivate var verticalBottomColour = UIColor.black\n\tprivate var cornerTopLeftColour = UIColor.white\n\tprivate var cornerTopRightColour = UIColor.black\n\tprivate var cornerBottomLeftColour = UIColor.black\n\tprivate var cornerBottomRightColour = UIColor.white\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n\t\thorizontalLeftView?.layer.borderWidth = 1\n\t\thorizontalLeftView?.layer.borderColor = UIColor.black.cgColor\n\t\thorizontalRightView?.layer.borderWidth = 1\n\t\thorizontalRightView?.layer.borderColor = UIColor.black.cgColor\n\n\t\tverticalTopView?.layer.borderWidth = 1\n\t\tverticalTopView?.layer.borderColor = UIColor.black.cgColor\n\t\tverticalBottomView?.layer.borderWidth = 1\n\t\tverticalBottomView?.layer.borderColor = UIColor.black.cgColor\n\n\t\tcornerTopLeftView?.layer.borderWidth = 1\n\t\tcornerTopLeftView?.layer.borderColor = UIColor.black.cgColor\n\t\tcornerTopRightView?.layer.borderWidth = 1\n\t\tcornerTopRightView?.layer.borderColor = UIColor.black.cgColor\n\t\tcornerBottomLeftView?.layer.borderWidth = 1\n\t\tcornerBottomLeftView?.layer.borderColor = UIColor.black.cgColor\n\t\tcornerBottomRightView?.layer.borderWidth = 1\n\t\tcornerBottomRightView?.layer.borderColor = UIColor.black.cgColor\n\n        update()\n    }\n\n    @IBAction func randomiseTapped() {\n\t\thorizontalLeftColour = .random()\n\t\thorizontalRightColour = .random()\n\t\tverticalTopColour = .random()\n\t\tverticalBottomColour = .random()\n\t\tcornerTopLeftColour = .random()\n\t\tcornerTopRightColour = .random()\n\t\tcornerBottomLeftColour = .random()\n\t\tcornerBottomRightColour = .random()\n\n        update()\n    }\n\n\n    func update() {\n\t\thorizontalLeftView?.backgroundColor = horizontalLeftColour\n\t\thorizontalRightView?.backgroundColor = horizontalRightColour\n\n\t\tverticalTopView?.backgroundColor = verticalTopColour\n\t\tverticalBottomView?.backgroundColor = verticalBottomColour\n\n\t\tcornerTopLeftView?.backgroundColor = cornerTopLeftColour\n\t\tcornerTopRightView?.backgroundColor = cornerTopRightColour\n\t\tcornerBottomLeftView?.backgroundColor = cornerBottomLeftColour\n\t\tcornerBottomRightView?.backgroundColor = cornerBottomRightColour\n\n\t\tlet horizontalBlurHash = BlurHash(blendingLeft: horizontalLeftColour, right: horizontalRightColour)\n\t\thorizontalUncompressedImageView?.image = horizontalBlurHash.image(size: CGSize(width: 32, height: 32))\n\t\thorizontalCompressedImageView?.image = BlurHash(string: horizontalBlurHash.string)?.image(size: CGSize(width: 32, height: 32))\n\t\thorizontalHashLabel?.text = horizontalBlurHash.string\n\n\t\tlet verticalBlurHash = BlurHash(blendingTop: verticalTopColour, bottom: verticalBottomColour)\n\t\tverticalUncompressedImageView?.image = verticalBlurHash.image(size: CGSize(width: 32, height: 32))\n\t\tverticalCompressedImageView?.image = BlurHash(string: verticalBlurHash.string)?.image(size: CGSize(width: 32, height: 32))\n\t\tverticalHashLabel?.text = verticalBlurHash.string\n\n\t\tlet cornerBlurHash = BlurHash(blendingTopLeft: cornerTopLeftColour, topRight: cornerTopRightColour, bottomLeft: cornerBottomLeftColour, bottomRight: cornerBottomRightColour)\n\t\tcornerUncompressedImageView?.image = cornerBlurHash.image(size: CGSize(width: 32, height: 32))\n\t\tcornerCompressedImageView?.image = BlurHash(string: cornerBlurHash.string)?.image(size: CGSize(width: 32, height: 32))\n\t\tcornerHashLabel?.text = cornerBlurHash.string\n\t}\n}\n\nextension UIColor {\n\tstatic func random() -> UIColor {\n\t\tlet hue = CGFloat(arc4random()) / CGFloat(UInt32.max)\n\t\tlet brightness = CGFloat(arc4random()) / CGFloat(UInt32.max)\n\t\tif brightness < 0.5 {\n\t\t\treturn UIColor(hue: hue, saturation: 1, brightness: brightness * 2, alpha: 1)\n\t\t} else {\n\t\t\treturn UIColor(hue: hue, saturation: 2 - brightness * 2, brightness: 1, alpha: 1)\n\t\t}\n\t}\n}\n\n"
  },
  {
    "path": "Swift/BlurHashTest/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>en</string>\n\t<key>CFBundleExecutable</key>\n\t<string>$(EXECUTABLE_NAME)</string>\n\t<key>CFBundleIdentifier</key>\n\t<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>$(PRODUCT_NAME)</string>\n\t<key>CFBundlePackageType</key>\n\t<string>APPL</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleVersion</key>\n\t<string>1</string>\n\t<key>LSRequiresIPhoneOS</key>\n\t<true/>\n\t<key>UILaunchStoryboardName</key>\n\t<string>LaunchScreen</string>\n\t<key>UIMainStoryboardFile</key>\n\t<string>Main</string>\n\t<key>UIRequiredDeviceCapabilities</key>\n\t<array>\n\t\t<string>armv7</string>\n\t</array>\n\t<key>UISupportedInterfaceOrientations</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\n\t\t<string>UIInterfaceOrientationLandscapeRight</string>\n\t</array>\n\t<key>UISupportedInterfaceOrientations~ipad</key>\n\t<array>\n\t\t<string>UIInterfaceOrientationPortrait</string>\n\t\t<string>UIInterfaceOrientationPortraitUpsideDown</string>\n\t\t<string>UIInterfaceOrientationLandscapeLeft</string>\n\t\t<string>UIInterfaceOrientationLandscapeRight</string>\n\t</array>\n</dict>\n</plist>\n"
  },
  {
    "path": "Swift/BlurHashTest/SimpleViewController.swift",
    "content": "import UIKit\n\nclass SimpleViewController: UIViewController {\n    @IBOutlet weak var originalImageView: UIImageView?\n    @IBOutlet weak var hashLabel: UILabel?\n    @IBOutlet weak var blurImageView: UIImageView?\n    @IBOutlet weak var xComponentsLabel: UILabel?\n    @IBOutlet weak var yComponentsLabel: UILabel?\n\n    let images: [UIImage] = [\n        UIImage(named: \"pic2.png\")!,\n        UIImage(named: \"pic1.png\")!,\n        UIImage(named: \"pic3.png\")!,\n        UIImage(named: \"pic6.png\")!,\n    ]\n\n    var imageIndex: Int = 0\n    var xComponents: Int = 4\n    var yComponents: Int = 3\n    var blurHash: String = \"\"\n    var punch: Float = 1\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        updateEncode()\n        updateDecode()\n    }\n\n    @IBAction func imageTapped() {\n        imageIndex = (imageIndex + 1) % images.count\n        updateEncode()\n        updateDecode()\n    }\n\n    @IBAction func xPlusTapped() {\n        if xComponents < 8 {\n            xComponents += 1\n            updateEncode()\n            updateDecode()\n        }\n    }\n\n    @IBAction func xMinusTapped() {\n        if xComponents > 1 {\n            xComponents -= 1\n            updateEncode()\n            updateDecode()\n        }\n    }\n\n    @IBAction func yPlusTapped() {\n        if yComponents < 8 {\n            yComponents += 1\n            updateEncode()\n            updateDecode()\n        }\n    }\n\n    @IBAction func yMinusTapped() {\n        if yComponents > 1 {\n            yComponents -= 1\n            updateEncode()\n            updateDecode()\n        }\n     }\n\n\n    @IBAction func sliderChanged(slider: UISlider) {\n        punch = slider.value\n        updateDecode()\n    }\n\n    func updateEncode() {\n        originalImageView?.image = images[imageIndex]\n        blurHash = images[imageIndex].blurHash(numberOfComponents: (xComponents, yComponents))!\n        hashLabel?.text = blurHash\n        xComponentsLabel?.text = String(xComponents)\n        yComponentsLabel?.text = String(yComponents)\n    }\n\n    func updateDecode() {\n        let blurImage = UIImage(blurHash: blurHash, size: CGSize(width: 32, height: 32), punch: punch)\n\n        blurImageView?.image = blurImage\n    }\n}\n\n"
  },
  {
    "path": "Swift/License.txt",
    "content": "Copyright (c) 2018 Wolt Enterprises\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "Swift/Readme.md",
    "content": "# BlurHash for iOS, in Swift\n\n## Standalone decoder and encoder\n\n[BlurHashDecode.swift](BlurHashDecode.swift) and [BlurHashEncode.swift](BlurHashEncode.swift) contain a decoder\nand encoder for BlurHash to and from `UIImage`. Both files are completeiy standalone, and can simply be copied into your\nproject directly.\n\n### Decoding\n\n[BlurHashDecode.swift](BlurHashDecode.swift) implements the following extension on `UIImage`:\n\n\tpublic convenience init?(blurHash: String, size: CGSize, punch: Float = 1)\n\nThis creates a UIImage containing the placeholder image decoded from the BlurHash string, or returns nil if decoding failed.\nThe parameters are:\n\n* `blurHash` - A string containing the BlurHash.\n* `size` - The requested output size. You should keep this small, and let UIKit scale it up for you. 32 pixels wide is plenty.\n* `punch` - Adjusts the contrast of the output image. Tweak it if you want a different look for your placeholders.\n\n### Encoding\n\n [BlurHashEncode.swift](BlurHashEncode.swift) implements the following extension on `UIImage`:\n\n\tpublic func blurHash(numberOfComponents components: (Int, Int)) -> String?\n\nThis returns a string containing the BlurHash for the image, or nil if the image was in a weird format that is not supported.\nThe parameters are:\n\n* `numberOfComponents` - a Tuple of integers specifying the number of components in the X and Y directions. Both must be\nbetween 1 and 9 inclusive, or the function will return nil.  3 to 5 is usually a good range.\n\n## BlurHashKit\n\nThis is a more advanced library, currently in development. It will let you do more advanced operations using BlurHashes,\nsuch testing whether various parts of an image are dark and light, or generating BlurHashes as gradients from corner colours.\n\nIt is currently not documented or finalised, but feel free to look into the different files and what they implement, or look at\nhow it is used by the test app.\n\n## BlurHashTest.app\n\nThis is a simple test app that shows how to use the various pieces of BlurHash functionality, and lets you play with the\nalgorithm.\n"
  },
  {
    "path": "TypeScript/.gitignore",
    "content": "node_modules/\ndist/"
  },
  {
    "path": "TypeScript/.npmignore",
    "content": ".DS_Store\n.prettierrc\ntsconfig.json\ndemo\nwebpack.config.js\n"
  },
  {
    "path": "TypeScript/.prettierrc",
    "content": "{\n  \"printWidth\": 80,\n  \"overrides\": [\n    {\n      \"files\": [\"*.ts\"],\n      \"options\": {}\n    }\n  ]\n}\n"
  },
  {
    "path": "TypeScript/CHANGELOG.md",
    "content": "# Changelog\n\n## 2.0.0 (September 12, 2022)\n\n- Modern bundling\n- Fix DC encoding\n- Drop IE11 support\n\n## 1.1.5 (February 15, 2022)\n\n- added typescript sources to npm package for source map support\n\n## 1.1.4 (August 16, 2021)\n\n- added esm build target\n\n## 1.1.2 (June 29, 2019)\n\n- added `isBlurhashValid()` utility\n\n## 1.1.1 (June 29, 2019)\n\n- fixed incorrect type declaration path in package.json\n- improved error handling\n"
  },
  {
    "path": "TypeScript/README.md",
    "content": "# blurhash\n\n[![NPM Version](https://img.shields.io/npm/v/blurhash.svg?style=flat)](https://npmjs.org/package/blurhash)\n[![NPM Downloads](https://img.shields.io/npm/dm/blurhash.svg?style=flat)](https://npmjs.org/package/blurhash)\n\n> JavaScript encoder and decoder for the [Wolt BlurHash](https://github.com/woltapp/blurhash) algorithm\n\n## Install\n\n```sh\nnpm install --save blurhash\n```\n\nSee [react-blurhash](https://github.com/woltapp/react-blurhash) to use blurhash with React.\n\n## API\n\n### `decode(blurhash: string, width: number, height: number, punch?: number) => Uint8ClampedArray`\n\n> Decodes a blurhash string to pixels\n\n#### Example\n\n```js\nimport { decode } from \"blurhash\";\n\nconst pixels = decode(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\", 32, 32);\n\nconst canvas = document.createElement(\"canvas\");\nconst ctx = canvas.getContext(\"2d\");\nconst imageData = ctx.createImageData(width, height);\nimageData.data.set(pixels);\nctx.putImageData(imageData, 0, 0);\ndocument.body.append(canvas);\n```\n\n### `encode(pixels: Uint8ClampedArray, width: number, height: number, componentX: number, componentY: number) => string`\n\n> Encodes pixels to a blurhash string\n\n```js\nimport { encode } from \"blurhash\";\n\nconst loadImage = async src =>\n  new Promise((resolve, reject) => {\n    const img = new Image();\n    img.onload = () => resolve(img);\n    img.onerror = (...args) => reject(args);\n    img.src = src;\n  });\n\nconst getImageData = image => {\n  const canvas = document.createElement(\"canvas\");\n  canvas.width = image.width;\n  canvas.height = image.height;\n  const context = canvas.getContext(\"2d\");\n  context.drawImage(image, 0, 0);\n  return context.getImageData(0, 0, image.width, image.height);\n};\n\nconst encodeImageToBlurhash = async imageUrl => {\n  const image = await loadImage(imageUrl);\n  const imageData = getImageData(image);\n  return encode(imageData.data, imageData.width, imageData.height, 4, 4);\n};\n```\n\n### `isBlurhashValid(blurhash: string) => { result: boolean; errorReason?: string }`\n\n```js\nimport { isBlurhashValid } from \"blurhash\";\n\nconst validRes = isBlurhashValid(\"LEHV6nWB2yk8pyo0adR*.7kCMdnj\");\n// { result: true }\n\nconst invalidRes = isBlurhashValid(\"???\");\n// { result: false, errorReason: \"The blurhash string must be at least 6 characters\" }\n```\n"
  },
  {
    "path": "TypeScript/demo/index.html",
    "content": "<!DOCTYPE html>\n<html>\n\n<head>\n    <title>Blurhash test file</title>\n    <style>\n        * {\n            box-sizing: border-box;\n        }\n\n        .wrapper {\n            display: flex;\n            align-items: flex-start;\n        }\n\n        .blurhashWrapper {\n            padding: 0 20px;\n        }\n\n        canvas {\n            display: block;\n            width: 632px;\n            height: 356px;\n            background: #ccc;\n        }\n\n        #blurhash {\n            margin-top: 20px;\n            font-size: 24px;\n            width: 632px;\n        }\n\n        label {\n            display: block;\n            padding: 10px 0;\n        }\n\n        label > span {\n            display: inline-block;\n            width: 100px;\n        }\n    </style>\n</head>\n\n<body>\n    <h1>BlurHash demo</h1>\n    <div class=\"wrapper\">\n        <div>\n            <h2>Encode</h2>\n            <canvas id=\"original\" width=\"100\" height=\"100\"></canvas>\n            <label>\n                <span>File:</span>\n                <input id=\"fileinput\" type=\"file\" accept=\"image/*\" />\n            </label>\n            <label>\n                <span>Components</span>\n                <input type=\"number\" id=\"x\" value=\"4\" min=\"1\" max=\"9\" />\n                ×\n                <input type=\"number\" id=\"y\" value=\"3\" min=\"1\" max=\"9\" />\n            </label>\n        </div>\n        <div class=\"blurhashWrapper\">\n            <h2>Blurhash</h2>\n            <input id=\"blurhash\" type=\"text\" value=\"\" />\n        </div>\n        <div>\n            <h2>Decode</h2>\n            <canvas id=\"canvas\" width=\"32\" height=\"32\"></canvas>\n        </div>\n    </div>\n    <script src=\"./demo.js\"></script>\n</body>\n\n</html>"
  },
  {
    "path": "TypeScript/package.json",
    "content": "{\n  \"name\": \"blurhash\",\n  \"version\": \"2.0.5\",\n  \"description\": \"Encoder and decoder for the Wolt BlurHash algorithm.\",\n  \"main\": \"dist/index.js\",\n  \"types\": \"dist/index.d.ts\",\n  \"module\": \"dist/esm/index.js\",\n  \"exports\": {\n    \"./package.json\": \"./package.json\",\n    \".\": {\n      \"browser\": {\n        \"import\":\"./dist/esm/index.js\",\n        \"require\": \"./dist/index.js\"\n      },\n      \"import\": \"./dist/index.mjs\",\n      \"module\": \"./dist/esm/index.js\",\n      \"node\": \"./dist/index.js\",\n      \"require\": \"./dist/index.js\",\n      \"types\": \"./dist/index.d.ts\",\n      \"default\": \"./dist/index.js\"\n    }\n  },\n  \"sideEffects\": false,\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/woltapp/blurhash/tree/master/TypeScript\"\n  },\n  \"homepage\": \"https://blurha.sh\",\n  \"files\": [\n    \"dist\"\n  ],\n  \"scripts\": {\n    \"prepublishOnly\": \"npm run build\",\n    \"build\": \"tsup\",\n    \"demo\": \"webpack-dev-server --mode development\",\n    \"prettier\": \"prettier src/**/*.ts\",\n    \"prettier-fix\": \"npm run prettier -- --write\",\n    \"start\": \"tsup --watch\"\n  },\n  \"keywords\": [\n    \"blurhash\",\n    \"blur\",\n    \"hash\",\n    \"image\"\n  ],\n  \"author\": \"omahlama\",\n  \"license\": \"MIT\",\n  \"devDependencies\": {\n    \"prettier\": \"2.7.1\",\n    \"ts-loader\": \"9.3.1\",\n    \"tsup\": \"^6.1.3\",\n    \"typescript\": \"4.7.4\",\n    \"webpack\": \"5.73.0\",\n    \"webpack-cli\": \"4.10.0\",\n    \"webpack-dev-server\": \"4.9.3\"\n  }\n}\n"
  },
  {
    "path": "TypeScript/src/base83.ts",
    "content": "const digitCharacters = [\n  \"0\",\n  \"1\",\n  \"2\",\n  \"3\",\n  \"4\",\n  \"5\",\n  \"6\",\n  \"7\",\n  \"8\",\n  \"9\",\n  \"A\",\n  \"B\",\n  \"C\",\n  \"D\",\n  \"E\",\n  \"F\",\n  \"G\",\n  \"H\",\n  \"I\",\n  \"J\",\n  \"K\",\n  \"L\",\n  \"M\",\n  \"N\",\n  \"O\",\n  \"P\",\n  \"Q\",\n  \"R\",\n  \"S\",\n  \"T\",\n  \"U\",\n  \"V\",\n  \"W\",\n  \"X\",\n  \"Y\",\n  \"Z\",\n  \"a\",\n  \"b\",\n  \"c\",\n  \"d\",\n  \"e\",\n  \"f\",\n  \"g\",\n  \"h\",\n  \"i\",\n  \"j\",\n  \"k\",\n  \"l\",\n  \"m\",\n  \"n\",\n  \"o\",\n  \"p\",\n  \"q\",\n  \"r\",\n  \"s\",\n  \"t\",\n  \"u\",\n  \"v\",\n  \"w\",\n  \"x\",\n  \"y\",\n  \"z\",\n  \"#\",\n  \"$\",\n  \"%\",\n  \"*\",\n  \"+\",\n  \",\",\n  \"-\",\n  \".\",\n  \":\",\n  \";\",\n  \"=\",\n  \"?\",\n  \"@\",\n  \"[\",\n  \"]\",\n  \"^\",\n  \"_\",\n  \"{\",\n  \"|\",\n  \"}\",\n  \"~\",\n];\n\nexport const decode83 = (str: String) => {\n  let value = 0;\n  for (let i = 0; i < str.length; i++) {\n    const c = str[i];\n    const digit = digitCharacters.indexOf(c);\n    value = value * 83 + digit;\n  }\n  return value;\n};\n\nexport const encode83 = (n: number, length: number): string => {\n  var result = \"\";\n  for (let i = 1; i <= length; i++) {\n    let digit = (Math.floor(n) / Math.pow(83, length - i)) % 83;\n    result += digitCharacters[Math.floor(digit)];\n  }\n  return result;\n};\n"
  },
  {
    "path": "TypeScript/src/decode.ts",
    "content": "import { decode83 } from \"./base83\";\nimport { sRGBToLinear, signPow, linearTosRGB } from \"./utils\";\nimport { ValidationError } from \"./error\";\n\n/**\n * Returns an error message if invalid or undefined if valid\n * @param blurhash\n */\nconst validateBlurhash = (blurhash: string) => {\n  if (!blurhash || blurhash.length < 6) {\n    throw new ValidationError(\n      \"The blurhash string must be at least 6 characters\"\n    );\n  }\n\n  const sizeFlag = decode83(blurhash[0]);\n  const numY = Math.floor(sizeFlag / 9) + 1;\n  const numX = (sizeFlag % 9) + 1;\n\n  if (blurhash.length !== 4 + 2 * numX * numY) {\n    throw new ValidationError(\n      `blurhash length mismatch: length is ${\n        blurhash.length\n      } but it should be ${4 + 2 * numX * numY}`\n    );\n  }\n};\n\nexport const isBlurhashValid = (\n  blurhash: string\n): { result: boolean; errorReason?: string } => {\n  try {\n    validateBlurhash(blurhash);\n  } catch (error) {\n    return { result: false, errorReason: error.message };\n  }\n\n  return { result: true };\n};\n\nconst decodeDC = (value: number) => {\n  const intR = value >> 16;\n  const intG = (value >> 8) & 255;\n  const intB = value & 255;\n  return [sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB)];\n};\n\nconst decodeAC = (value: number, maximumValue: number) => {\n  const quantR = Math.floor(value / (19 * 19));\n  const quantG = Math.floor(value / 19) % 19;\n  const quantB = value % 19;\n\n  const rgb = [\n    signPow((quantR - 9) / 9, 2.0) * maximumValue,\n    signPow((quantG - 9) / 9, 2.0) * maximumValue,\n    signPow((quantB - 9) / 9, 2.0) * maximumValue,\n  ];\n\n  return rgb;\n};\n\nconst decode = (\n  blurhash: string,\n  width: number,\n  height: number,\n  punch?: number\n) => {\n  validateBlurhash(blurhash);\n\n  punch = punch | 1;\n\n  const sizeFlag = decode83(blurhash[0]);\n  const numY = Math.floor(sizeFlag / 9) + 1;\n  const numX = (sizeFlag % 9) + 1;\n\n  const quantisedMaximumValue = decode83(blurhash[1]);\n  const maximumValue = (quantisedMaximumValue + 1) / 166;\n\n  const colors = new Array(numX * numY);\n\n  for (let i = 0; i < colors.length; i++) {\n    if (i === 0) {\n      const value = decode83(blurhash.substring(2, 6));\n      colors[i] = decodeDC(value);\n    } else {\n      const value = decode83(blurhash.substring(4 + i * 2, 6 + i * 2));\n      colors[i] = decodeAC(value, maximumValue * punch);\n    }\n  }\n\n  const bytesPerRow = width * 4;\n  const pixels = new Uint8ClampedArray(bytesPerRow * height);\n\n  for (let y = 0; y < height; y++) {\n    for (let x = 0; x < width; x++) {\n      let r = 0;\n      let g = 0;\n      let b = 0;\n\n      for (let j = 0; j < numY; j++) {\n        const basisY = Math.cos((Math.PI * y * j) / height);\n        for (let i = 0; i < numX; i++) {\n          const basis = Math.cos((Math.PI * x * i) / width) * basisY;\n          const color = colors[i + j * numX];\n          r += color[0] * basis;\n          g += color[1] * basis;\n          b += color[2] * basis;\n        }\n      }\n\n      let intR = linearTosRGB(r);\n      let intG = linearTosRGB(g);\n      let intB = linearTosRGB(b);\n\n      pixels[4 * x + 0 + y * bytesPerRow] = intR;\n      pixels[4 * x + 1 + y * bytesPerRow] = intG;\n      pixels[4 * x + 2 + y * bytesPerRow] = intB;\n      pixels[4 * x + 3 + y * bytesPerRow] = 255; // alpha\n    }\n  }\n  return pixels;\n};\n\nexport default decode;\n"
  },
  {
    "path": "TypeScript/src/demo.ts",
    "content": "import decode from \"./decode\";\nimport encode from \"./encode\";\n\nconst blurhashElement = document.getElementById(\"blurhash\") as HTMLInputElement;\nconst canvas = document.getElementById(\"canvas\") as HTMLCanvasElement;\nconst originalCanvas = document.getElementById(\"original\") as HTMLCanvasElement;\nconst fileInput = document.getElementById(\"fileinput\") as HTMLInputElement;\nconst componentXElement = document.getElementById(\"x\") as HTMLInputElement;\nconst componentYElement = document.getElementById(\"y\") as HTMLInputElement;\n\nfunction render() {\n  const blurhash = blurhashElement.value;\n  if (blurhash) {\n    const pixels = decode(blurhash, 32, 32);\n    if (pixels) {\n      const ctx = canvas.getContext(\"2d\");\n\n      const imageData = new ImageData(pixels, 32, 32);\n      ctx.putImageData(imageData, 0, 0);\n    }\n  }\n}\n\nfunction clamp(n: number) {\n  return Math.min(9, Math.max(1, n));\n}\n\nfunction doEncode() {\n  const file = fileInput.files[0];\n  const componentX = clamp(+componentXElement.value);\n  const componentY = clamp(+componentYElement.value);\n  if (file) {\n    const ctx = originalCanvas.getContext(\"2d\");\n    var img = new Image();\n    img.onload = function () {\n      ctx.drawImage(img, 0, 0, originalCanvas.width, originalCanvas.height);\n      URL.revokeObjectURL(img.src);\n\n      setTimeout(() => {\n        const imageData = ctx.getImageData(\n          0,\n          0,\n          originalCanvas.width,\n          originalCanvas.height\n        );\n        const blurhash = encode(\n          imageData.data,\n          imageData.width,\n          imageData.height,\n          componentX,\n          componentY\n        );\n        blurhashElement.value = blurhash;\n        render();\n      }, 0);\n    };\n    img.src = URL.createObjectURL(fileInput.files[0]);\n  }\n}\n\nblurhashElement.addEventListener(\"keyup\", render);\nfileInput.addEventListener(\"change\", doEncode);\ncomponentXElement.addEventListener(\"change\", doEncode);\ncomponentYElement.addEventListener(\"change\", doEncode);\n\nrender();\n"
  },
  {
    "path": "TypeScript/src/encode.ts",
    "content": "import { encode83 } from \"./base83\";\nimport { sRGBToLinear, signPow, linearTosRGB } from \"./utils\";\nimport { ValidationError } from \"./error\";\n\ntype NumberTriplet = [number, number, number];\n\nconst bytesPerPixel = 4;\n\nconst multiplyBasisFunction = (\n  pixels: Uint8ClampedArray,\n  width: number,\n  height: number,\n  basisFunction: (i: number, j: number) => number\n): NumberTriplet => {\n  let r = 0;\n  let g = 0;\n  let b = 0;\n  const bytesPerRow = width * bytesPerPixel;\n\n  for (let x = 0; x < width; x++) {\n    const bytesPerPixelX = bytesPerPixel * x;\n\n    for (let y = 0; y < height; y++) {\n      const basePixelIndex = bytesPerPixelX + y * bytesPerRow;\n      const basis = basisFunction(x, y);\n      r +=\n        basis * sRGBToLinear(pixels[basePixelIndex]);\n      g +=\n        basis * sRGBToLinear(pixels[basePixelIndex + 1]);\n      b +=\n        basis * sRGBToLinear(pixels[basePixelIndex + 2]);\n    }\n  }\n\n  let scale = 1 / (width * height);\n\n  return [r * scale, g * scale, b * scale];\n};\n\nconst encodeDC = (value: NumberTriplet): number => {\n  const roundedR = linearTosRGB(value[0]);\n  const roundedG = linearTosRGB(value[1]);\n  const roundedB = linearTosRGB(value[2]);\n  return (roundedR << 16) + (roundedG << 8) + roundedB;\n};\n\nconst encodeAC = (value: NumberTriplet, maximumValue: number): number => {\n  let quantR = Math.floor(\n    Math.max(\n      0,\n      Math.min(18, Math.floor(signPow(value[0] / maximumValue, 0.5) * 9 + 9.5))\n    )\n  );\n  let quantG = Math.floor(\n    Math.max(\n      0,\n      Math.min(18, Math.floor(signPow(value[1] / maximumValue, 0.5) * 9 + 9.5))\n    )\n  );\n  let quantB = Math.floor(\n    Math.max(\n      0,\n      Math.min(18, Math.floor(signPow(value[2] / maximumValue, 0.5) * 9 + 9.5))\n    )\n  );\n\n  return quantR * 19 * 19 + quantG * 19 + quantB;\n};\n\nconst encode = (\n  pixels: Uint8ClampedArray,\n  width: number,\n  height: number,\n  componentX: number,\n  componentY: number\n): string => {\n  if (componentX < 1 || componentX > 9 || componentY < 1 || componentY > 9) {\n    throw new ValidationError(\"BlurHash must have between 1 and 9 components\");\n  }\n  if (width * height * 4 !== pixels.length) {\n    throw new ValidationError(\"Width and height must match the pixels array\");\n  }\n\n  let factors: Array<[number, number, number]> = [];\n  for (let y = 0; y < componentY; y++) {\n    for (let x = 0; x < componentX; x++) {\n      const normalisation = x == 0 && y == 0 ? 1 : 2;\n      const factor = multiplyBasisFunction(\n        pixels,\n        width,\n        height,\n        (i: number, j: number) =>\n          normalisation *\n          Math.cos((Math.PI * x * i) / width) *\n          Math.cos((Math.PI * y * j) / height)\n      );\n      factors.push(factor);\n    }\n  }\n\n  const dc = factors[0];\n  const ac = factors.slice(1);\n\n  let hash = \"\";\n\n  let sizeFlag = componentX - 1 + (componentY - 1) * 9;\n  hash += encode83(sizeFlag, 1);\n\n  let maximumValue: number;\n  if (ac.length > 0) {\n    let actualMaximumValue = Math.max(...ac.map((val) => Math.max(...val)));\n    let quantisedMaximumValue = Math.floor(\n      Math.max(0, Math.min(82, Math.floor(actualMaximumValue * 166 - 0.5)))\n    );\n    maximumValue = (quantisedMaximumValue + 1) / 166;\n    hash += encode83(quantisedMaximumValue, 1);\n  } else {\n    maximumValue = 1;\n    hash += encode83(0, 1);\n  }\n\n  hash += encode83(encodeDC(dc), 4);\n\n  ac.forEach((factor) => {\n    hash += encode83(encodeAC(factor, maximumValue), 2);\n  });\n\n  return hash;\n};\n\nexport default encode;\n"
  },
  {
    "path": "TypeScript/src/error.ts",
    "content": "export class ValidationError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = \"ValidationError\";\n    this.message = message;\n  }\n}\n"
  },
  {
    "path": "TypeScript/src/index.ts",
    "content": "export { default as decode, isBlurhashValid } from \"./decode\";\nexport { default as encode } from \"./encode\";\nexport * from \"./error\";\n"
  },
  {
    "path": "TypeScript/src/utils.ts",
    "content": "export const sRGBToLinear = (value: number) => {\n  let v = value / 255;\n  if (v <= 0.04045) {\n    return v / 12.92;\n  } else {\n    return Math.pow((v + 0.055) / 1.055, 2.4);\n  }\n};\n\nexport const linearTosRGB = (value: number) => {\n  let v = Math.max(0, Math.min(1, value));\n  if (v <= 0.0031308) {\n    return Math.trunc(v * 12.92 * 255 + 0.5);\n  } else {\n    return Math.trunc((1.055 * Math.pow(v, 1 / 2.4) - 0.055) * 255 + 0.5);\n  }\n};\n\nexport const sign = (n: number) => (n < 0 ? -1 : 1);\n\nexport const signPow = (val: number, exp: number) =>\n  sign(val) * Math.pow(Math.abs(val), exp);\n"
  },
  {
    "path": "TypeScript/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"target\": \"es5\",\n    \"lib\": [\"es5\", \"dom\"],\n    \"declaration\": true,\n    \"outDir\": \"./dist/\",\n    \"sourceMap\": true,\n    \"noImplicitAny\": true\n  },\n  \"include\": [\"src/index.ts\"]\n}\n"
  },
  {
    "path": "TypeScript/tsup.config.ts",
    "content": "import { defineConfig } from \"tsup\";\n\nexport default defineConfig([\n  {\n    name: \"main\",\n    entry: [\"./src/index.ts\"],\n    outDir: \"./dist\",\n    format: [\"cjs\", \"esm\"],\n    legacyOutput: true,\n    sourcemap: true,\n    clean: true,\n    splitting: false,\n    dts: false,\n    minify: true,\n  },\n  {\n    name: \"esm\",\n    entry: [\"./src/index.ts\"],\n    outDir: \"./dist\",\n    format: [\"esm\"],\n    legacyOutput: false,\n    sourcemap: true,\n    clean: true,\n    splitting: false,\n    dts: false,\n    minify: true,\n  },\n  {\n    name: \"typedefs\",\n    entry: [\"./src/index.ts\"],\n    outDir: \"./dist\",\n    clean: false,\n    dts: {\n      only: true,\n    },\n  },\n]);\n"
  },
  {
    "path": "TypeScript/webpack.config.js",
    "content": "const path = require('path');\n\nmodule.exports = {\n  entry: './src/demo.ts',\n  devtool: 'inline-source-map',\n  module: {\n    rules: [\n      {\n        test: /\\.tsx?$/,\n        use: 'ts-loader',\n        exclude: /node_modules/\n      }\n    ]\n  },\n  resolve: {\n    extensions: [ '.tsx', '.ts', '.js' ]\n  },\n  output: {\n    filename: 'demo.js',\n    path: path.resolve(__dirname, 'dist')\n  },\n  devServer: {\n    static: path.join(__dirname, \"demo\"),\n    compress: true,\n    port: 9000\n  }\n};"
  },
  {
    "path": "Website/.babelrc",
    "content": "{\n  \"presets\": [\n    [\n      \"@babel/preset-env\",\n      {\n        \"targets\": \"> 0.25%, not dead\",\n        \"modules\": false\n      }\n    ]\n  ]\n}\n"
  },
  {
    "path": "Website/.prettierrc",
    "content": "{\n  \"printWidth\": 100,\n  \"overrides\": [\n    {\n      \"files\": [\"*.js\"],\n      \"options\": {\n        \"singleQuote\": true,\n        \"trailingComma\": \"all\"\n      }\n    },\n    {\n      \"files\": [\"webpack.config.js\"],\n      \"options\": {\n        \"trailingComma\": \"es5\"\n      }\n    },\n    {\n      \"files\": [\"*.css\", \"*.scss\"],\n      \"options\": {\n        \"parser\": \"scss\",\n        \"singleQuote\": true\n      }\n    },\n    {\n      \"files\": \"*.json\",\n      \"options\": {\n        \"parser\": \"json\"\n      }\n    }\n  ]\n}\n"
  },
  {
    "path": "Website/Readme.md",
    "content": "# blurha.sh\n\nWebsite for blurhash lives here.\n\n## Developing\n\n`npm start` runs the development server\n\n`npm deploy` builds the site, moves the contents into gh-pages branch and pushes it."
  },
  {
    "path": "Website/deploy.sh",
    "content": "#!/usr/bin/env bash\nset -o errexit #abort if any command fails\nme=$(basename \"$0\")\n\nhelp_message=\"\\\nUsage: $me [-c FILE] [<options>]\nDeploy generated files to a git branch.\n\nOptions:\n\n  -h, --help               Show this help information.\n  -v, --verbose            Increase verbosity. Useful for debugging.\n  -e, --allow-empty        Allow deployment of an empty directory.\n  -m, --message MESSAGE    Specify the message used when committing on the\n                           deploy branch.\n  -n, --no-hash            Don't append the source commit's hash to the deploy\n                           commit's message.\n  -c, --config-file PATH   Override default & environment variables' values\n                           with those in set in the file at 'PATH'. Must be the\n                           first option specified.\n\nVariables:\n\n  GIT_DEPLOY_DIR      Folder path containing the files to deploy.\n  GIT_DEPLOY_BRANCH   Commit deployable files to this branch.\n  GIT_DEPLOY_REPO     Push the deploy branch to this repository.\n\nThese variables have default values defined in the script. The defaults can be\noverridden by environment variables. Any environment variables are overridden\nby values set in a '.env' file (if it exists), and in turn by those set in a\nfile specified by the '--config-file' option.\"\n\nparse_args() {\n\t# Set args from a local environment file.\n\tif [ -e \".env\" ]; then\n\t\tsource .env\n\tfi\n\n\t# Set args from file specified on the command-line.\n\tif [[ $1 = \"-c\" || $1 = \"--config-file\" ]]; then\n\t\tsource \"$2\"\n\t\tshift 2\n\tfi\n\n\t# Parse arg flags\n\t# If something is exposed as an environment variable, set/overwrite it\n\t# here. Otherwise, set/overwrite the internal variable instead.\n\twhile : ; do\n\t\tif [[ $1 = \"-h\" || $1 = \"--help\" ]]; then\n\t\t\techo \"$help_message\"\n\t\t\treturn 0\n\t\telif [[ $1 = \"-v\" || $1 = \"--verbose\" ]]; then\n\t\t\tverbose=true\n\t\t\tshift\n\t\telif [[ $1 = \"-e\" || $1 = \"--allow-empty\" ]]; then\n\t\t\tallow_empty=true\n\t\t\tshift\n\t\telif [[ ( $1 = \"-m\" || $1 = \"--message\" ) && -n $2 ]]; then\n\t\t\tcommit_message=$2\n\t\t\tshift 2\n\t\telif [[ $1 = \"-n\" || $1 = \"--no-hash\" ]]; then\n\t\t\tGIT_DEPLOY_APPEND_HASH=false\n\t\t\tshift\n\t\telse\n\t\t\tbreak\n\t\tfi\n\tdone\n\n\t# Set internal option vars from the environment and arg flags. All internal\n\t# vars should be declared here, with sane defaults if applicable.\n\n\t# Source directory & target branch.\n\tdeploy_directory=${GIT_DEPLOY_DIR:-dist}\n\tdeploy_branch=${GIT_DEPLOY_BRANCH:-gh-pages}\n\n\t#if no user identity is already set in the current git environment, use this:\n\tdefault_username=${GIT_DEPLOY_USERNAME:-deploy.sh}\n\tdefault_email=${GIT_DEPLOY_EMAIL:-}\n\n\t#repository to deploy to. must be readable and writable.\n\trepo=${GIT_DEPLOY_REPO:-origin}\n\n\t#append commit hash to the end of message by default\n\tappend_hash=${GIT_DEPLOY_APPEND_HASH:-true}\n}\n\nmain() {\n\tparse_args \"$@\"\n\n\tenable_expanded_output\n\n\tif ! git diff --exit-code --quiet --cached; then\n\t\techo Aborting due to uncommitted changes in the index >&2\n\t\treturn 1\n\tfi\n\n\tcommit_title=`git log -n 1 --format=\"%s\" HEAD`\n\tcommit_hash=` git log -n 1 --format=\"%H\" HEAD`\n\t\n\t#default commit message uses last title if a custom one is not supplied\n\tif [[ -z $commit_message ]]; then\n\t\tcommit_message=\"publish: $commit_title\"\n\tfi\n\t\n\t#append hash to commit message unless no hash flag was found\n\tif [ $append_hash = true ]; then\n\t\tcommit_message=\"$commit_message\"$'\\n\\n'\"generated from commit $commit_hash\"\n\tfi\n\t\t\n\tprevious_branch=`git rev-parse --abbrev-ref HEAD`\n\n\tif [ ! -d \"$deploy_directory\" ]; then\n\t\techo \"Deploy directory '$deploy_directory' does not exist. Aborting.\" >&2\n\t\treturn 1\n\tfi\n\t\n\t# must use short form of flag in ls for compatibility with OS X and BSD\n\tif [[ -z `ls -A \"$deploy_directory\" 2> /dev/null` && -z $allow_empty ]]; then\n\t\techo \"Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag.\" >&2\n\t\treturn 1\n\tfi\n\n\tif git ls-remote --exit-code $repo \"refs/heads/$deploy_branch\" ; then\n\t\t# deploy_branch exists in $repo; make sure we have the latest version\n\t\t\n\t\tdisable_expanded_output\n\t\tgit fetch --force $repo $deploy_branch:$deploy_branch\n\t\tenable_expanded_output\n\tfi\n\n\t# check if deploy_branch exists locally\n\tif git show-ref --verify --quiet \"refs/heads/$deploy_branch\"\n\tthen incremental_deploy\n\telse initial_deploy\n\tfi\n\n\trestore_head\n}\n\ninitial_deploy() {\n\tgit --work-tree \"$deploy_directory\" checkout --orphan $deploy_branch\n\tgit --work-tree \"$deploy_directory\" add --all\n\tcommit+push\n}\n\nincremental_deploy() {\n\t#make deploy_branch the current branch\n\tgit symbolic-ref HEAD refs/heads/$deploy_branch\n\t#put the previously committed contents of deploy_branch into the index\n\tgit --work-tree \"$deploy_directory\" reset --mixed --quiet\n\tgit --work-tree \"$deploy_directory\" add --all\n\n\tset +o errexit\n\tdiff=$(git --work-tree \"$deploy_directory\" diff --exit-code --quiet HEAD --)$?\n\tset -o errexit\n\tcase $diff in\n\t\t0) echo No changes to files in $deploy_directory. Skipping commit.;;\n\t\t1) commit+push;;\n\t\t*)\n\t\t\techo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2\n\t\t\treturn $diff\n\t\t\t;;\n\tesac\n}\n\ncommit+push() {\n\tset_user_id\n\tgit --work-tree \"$deploy_directory\" commit -m \"$commit_message\"\n\n\tdisable_expanded_output\n\t#--quiet is important here to avoid outputting the repo URL, which may contain a secret token\n\tgit push --quiet $repo $deploy_branch\n\tenable_expanded_output\n}\n\n#echo expanded commands as they are executed (for debugging)\nenable_expanded_output() {\n\tif [ $verbose ]; then\n\t\tset -o xtrace\n\t\tset +o verbose\n\tfi\n}\n\n#this is used to avoid outputting the repo URL, which may contain a secret token\ndisable_expanded_output() {\n\tif [ $verbose ]; then\n\t\tset +o xtrace\n\t\tset -o verbose\n\tfi\n}\n\nset_user_id() {\n\tif [[ -z `git config user.name` ]]; then\n\t\tgit config user.name \"$default_username\"\n\tfi\n\tif [[ -z `git config user.email` ]]; then\n\t\tgit config user.email \"$default_email\"\n\tfi\n}\n\nrestore_head() {\n\tif [[ $previous_branch = \"HEAD\" ]]; then\n\t\t#we weren't on any branch before, so just set HEAD back to the commit it was on\n\t\tgit update-ref --no-deref HEAD $commit_hash $deploy_branch\n\telse\n\t\tgit symbolic-ref HEAD refs/heads/$previous_branch\n\tfi\n\t\n\tgit reset --mixed\n}\n\nfilter() {\n\tsed -e \"s|$repo|\\$repo|g\"\n}\n\nsanitize() {\n\t\"$@\" 2> >(filter 1>&2) | filter\n}\n\n[[ $1 = --source-only ]] || main \"$@\""
  },
  {
    "path": "Website/package.json",
    "content": "{\n  \"private\": true,\n  \"name\": \"website\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Website for BlurHash promo\",\n  \"main\": \"dist/index.js\",\n  \"scripts\": {\n    \"start\": \"webpack-dev-server --mode development\",\n    \"build\": \"webpack --mode production\",\n    \"clean\": \"rm -rf dist/*\",\n    \"deploy\": \"npm run clean && npm run build && echo 'blurha.sh' > dist/CNAME && ./deploy.sh\"\n  },\n  \"author\": {\n    \"name\": \"woltapp\",\n    \"url\": \"https://github.com/woltapp\"\n  },\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"@babel/cli\": \"^7.18.6\",\n    \"@babel/core\": \"^7.18.6\",\n    \"@babel/preset-env\": \"^7.18.6\",\n    \"babel-loader\": \"^8.2.5\",\n    \"css-loader\": \"^6.7.1\",\n    \"file-loader\": \"^6.2.0\",\n    \"html-webpack-plugin\": \"5.5.0\",\n    \"mini-css-extract-plugin\": \"2.6.1\",\n    \"node-sass\": \"7.0.3\",\n    \"prettier\": \"2.7.1\",\n    \"sass-loader\": \"13.0.2\",\n    \"style-loader\": \"3.3.1\",\n    \"webpack\": \"5.73.0\",\n    \"webpack-cli\": \"4.10.0\",\n    \"webpack-dev-server\": \"4.9.3\"\n  },\n  \"dependencies\": {\n    \"blurhash\": \"file:../TypeScript\",\n    \"@babel/runtime\": \"7.18.6\",\n    \"smoothscroll-polyfill\": \"0.4.4\",\n    \"velocity-animate\": \"1.5.2\"\n  }\n}\n"
  },
  {
    "path": "Website/src/constants.js",
    "content": "const imageHashes = [\n  'LEHV6njZ2ykUpyoKadR*.8kCMdnj',\n  'LHF5]+c[^6#M@-5b,1J5@[or[kA{',\n  'L6Pj0^xZ.A.S_Nt7t7R+*0o}DgQ-',\n  'LKO2?U%2Tw=_]~VeVZRi};RPxuwH',\n  'LPPGdFog?wt7?HofM|R+OGRjr;xu',\n];\n\nexport { imageHashes };\n"
  },
  {
    "path": "Website/src/index.ejs",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta\n      name=\"viewport\"\n      content=\"width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1, user-scalable=0, shrink-to-fit=no\"\n    />\n    <title><%= htmlWebpackPlugin.options.title %></title>\n    <meta property=\"og:title\" content=\"BlurHash\" />\n    <meta\n      property=\"og:description\"\n      content=\"BlurHash is a compact representation of a placeholder for an image.\"\n    />\n    <meta\n      property=\"og:image\"\n      content=\"https://blurha.sh/<%=require('../../Media/WhyBlurhash.png')%>\"\n    />\n    <meta property=\"og:url\" content=\"https://blurha.sh\" />\n    <meta property=\"og:type\" content=\"website\" />\n    <meta\n      name=\"twitter:title\"\n      content=\"BlurHash is a compact representation of a placeholder for an image.\"\n    />\n    <meta\n      name=\"twitter:image\"\n      content=\"https://blurha.sh/<%=require('../../Media/WhyBlurhash.png')%>\"\n    />\n    <meta name=\"twitter:card\" content=\"summary_large_image\" />\n    <meta dname=\"twitter:site\" content=\"@woltapp\" />\n  </head>\n  <body id=\"fullpage\">\n    <div class=\"hero section\">\n      <div class=\"imagesContainer\">\n        <div class=\"img1\">\n          <canvas width=\"32\" height=\"32\" class=\"image-canvas-bg\"></canvas>\n          <img src=\"<%=require('../assets/images/img1.jpg')%>\" class=\"image-bg\" />\n        </div>\n        <div class=\"img2\">\n          <canvas width=\"32\" height=\"32\" class=\"image-canvas-bg\"></canvas>\n          <img src=\"<%=require('../assets/images/img2.jpg')%>\" class=\"image-bg\" />\n        </div>\n        <div class=\"img3\">\n          <canvas width=\"32\" height=\"32\" class=\"image-canvas-bg\"></canvas>\n          <img src=\"<%=require('../assets/images/img3.jpg')%>\" class=\"image-bg\" />\n        </div>\n        <div class=\"img4\">\n          <canvas width=\"32\" height=\"32\" class=\"image-canvas-bg\"></canvas>\n          <img src=\"<%=require('../assets/images/img4.jpg')%>\" class=\"image-bg\" />\n        </div>\n        <div class=\"img5\">\n          <canvas width=\"32\" height=\"32\" class=\"image-canvas-bg\"></canvas>\n          <img src=\"<%=require('../assets/images/img5.jpg')%>\" class=\"image-bg\" />\n        </div>\n      </div>\n      <header class=\"header\">\n        <img class=\"logo\" src=\"<%=require('../assets/svg/wolt-logo.svg')%>\" />\n      </header>\n      <div class=\"content\">\n        <h1 class=\"title\">BlurHash</h1>\n        <p class=\"description\">\n          BlurHash is a compact representation of a placeholder for an image.\n        </p>\n        <button class=\"button\" id=\"get-started\">Get started</button>\n        <a\n          class=\"link\"\n          href=\"https://wolt.com/blog/hq/2019/07/01/how-we-came-to-create-a-new-image-placeholder-algorithm-blurhash/\"\n        >\n          More on our blog\n        </a>\n      </div>\n    </div>\n    <div class=\"section why-blurhash\">\n      <div class=\"content\">\n        <h2>Why BlurHash?</h2>\n        <h3>Why would you want this?</h3>\n        <p>\n          Does your designer cry every time you load their beautifully designed screen, and it is\n          full of empty boxes because all the images have not loaded yet? Does your database\n          engineer cry when you want to solve this by trying to cram little thumbnail images into\n          your data to show as placeholders?\n        </p>\n        <h3>BlurHash to the rescue!</h3>\n        <p>\n          Replace boring grey boxes with beautiful blurhash states and the designers will be happy.\n          Blurhash strings are short enough to be added as a field in a JSON object and to be stored\n          in a database. The implementations are small and easy to port to new languages, and the\n          end result is a smooth and interesting experience for your users.\n        </p>\n      </div>\n    </div>\n    <div class=\"section how-it-works\">\n      <h2>How does it work?</h2>\n      <p>\n        In short, BlurHash takes an image, and gives you a short string (only 20-30 characters!)\n        that represents the placeholder for this image. You do this on the backend of your service,\n        and store the string along with the image. When you send data to your client, you send both\n        the URL to the image, and the BlurHash string. Your client then takes the string, and\n        decodes it into an image that it shows while the real image is loading over the network. The\n        string is short enough that it comfortably fits into whatever data format you use. For\n        instance, it can easily be added as a field in a JSON object.\n      </p>\n      <div class=\"demo\">\n        <div class=\"part\">\n          <div class=\"predefined\">\n            <label>\n              <input type=\"radio\" value=\"0\" name=\"predefined\" checked />\n              <img src=\"<%=require('../assets/images/img1.jpg')%>\" />\n            </label>\n            <label>\n              <input type=\"radio\" value=\"1\" name=\"predefined\" />\n              <img src=\"<%=require('../assets/images/img2.jpg')%>\" />\n            </label>\n            <label>\n              <input type=\"radio\" value=\"2\" name=\"predefined\" />\n              <img src=\"<%=require('../assets/images/img3.jpg')%>\" />\n            </label>\n            <label>\n              <input type=\"radio\" value=\"3\" name=\"predefined\" />\n              <img src=\"<%=require('../assets/images/img4.jpg')%>\" />\n            </label>\n            <canvas id=\"original-canvas\"></canvas>\n          </div>\n          <p class=\"explain\">Pick image or upload your own</p>\n          <label for=\"file-upload\" class=\"button\"> Upload </label>\n          <input id=\"file-upload\" type=\"file\" accept=\"image/*\" />\n          <div class=\"dimension\">\n            Components\n            <div>\n              <input id=\"component-x\" type=\"text\" value=\"4\" />\n              x\n              <input id=\"component-y\" type=\"text\" value=\"3\" />\n            </div>\n          </div>\n        </div>\n        <div class=\"part\">\n          <div class=\"demo-blurhash\">\n            <span id=\"demo-blurhash\" contenteditable=\"true\"></span>\n          </div>\n          <p class=\"explain\">BlurHash string</p>\n          <p class=\"explain-small\">\n            The blurhash algorithm encodes your image into the short string above, ready to save in\n            a database\n          </p>\n        </div>\n        <div class=\"part\">\n          <canvas id=\"demo-canvas\" width=\"32\" height=\"32\"></canvas>\n          <p class=\"explain\">Result</p>\n          <p class=\"explain-small\">\n            The blurhash string is decoded into a small image that is rendered on to a canvas.\n          </p>\n        </div>\n      </div>\n    </div>\n    <div class=\"section get-started\">\n      <h2>Get started</h2>\n      <p>\n        The same exported data can be used on all platforms. Get the BlurHash library for your\n        platform of choice.\n      </p>\n      <a class=\"white-button\" href=\"https://github.com/woltapp/blurhash\"> More on GitHub </a>\n    </div>\n    <footer>\n      <a href=\"https://explore.wolt.com/contact\">Contact</a>\n      <a href=\"https://explore.wolt.com/accessibility-statement\">Accessibility Statement</a>\n      <a href=\"https://explore.wolt.com/terms\">User Terms of Service</a>\n      <a href=\"https://explore.wolt.com/privacy\">Privacy Statement</a>\n      <p>© Wolt 2014-2024</p>\n    </footer>\n  </body>\n</html>\n"
  },
  {
    "path": "Website/src/index.js",
    "content": "import './index.scss';\n\nimport Hero from './sections/hero';\nimport Demo from './sections/demo';\n\nHero();\nDemo();"
  },
  {
    "path": "Website/src/index.scss",
    "content": "@import 'styles/utils.scss';\n@import 'styles/resets.scss';\n@import 'styles/variables.scss';\n@import 'styles/base.scss';\n@import 'styles/averta.scss';\n\n@mixin img($top, $left) {\n  position: absolute;\n  top: top($top);\n  left: left($left);\n\n  & > .image-canvas-bg {\n    position: absolute;\n    z-index: -1;\n    top: 0;\n    width: 100%;\n    height: 100%;\n  }\n\n  & > .image-bg {\n    will-change: opacity;\n    opacity: 1;\n  }\n}\n\nh2 {\n  font-family: Helvetica;\n  font-weight: 400;\n  font-size: 60px;\n  line-height: 70px;\n\n  @media screen and (max-width: 600px) {\n    font-size: 40px;\n    line-height: 50px;\n  }\n}\n\n.button {\n  border-radius: 4px;\n  padding: 1rem;\n  min-width: 10rem;\n  color: #fff;\n  font-weight: 500;\n  background-color: $wolt-id-blue;\n\n  &:hover,\n  &:focus {\n    outline: none;\n    background-color: mix(#fff, $wolt-id-blue, 24);\n  }\n\n  &:active {\n    background-color: mix($dark-grey, $wolt-id-blue, 12);\n  }\n}\n\n.hero {\n  height: 100vh;\n\n  .header {\n    height: $header-height;\n    background-color: #fff;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n  }\n\n  .button {\n    margin-bottom: 2.5rem;\n  }\n\n  .logo {\n    width: 7.5rem;\n    height: 4.25rem;\n    z-index: 1;\n  }\n\n  .content {\n    z-index: 1;\n    height: 100%;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n    flex-direction: column;\n    opacity: 0;\n  }\n\n  .title {\n    font-family: AvertaStdPE-Semibold;\n    font-size: 6.6rem;\n    margin: 0;\n    margin-bottom: 2rem;\n\n    @media screen and (max-width: 600px) {\n      font-size: 4rem;\n    }\n  }\n\n  .description {\n    margin: 0 2rem 3.5rem;\n    font-size: 1.5rem;\n    max-width: 700px;\n    text-align: center;\n  }\n\n  .link {\n    position: relative;\n    font-weight: 500;\n    text-decoration: none;\n    line-height: 1.8;\n    &::after {\n      position: absolute;\n      bottom: 0;\n      left: 0;\n      width: 100%;\n      content: '';\n      border: 1px solid $dark-grey;\n      border-bottom: 0;\n    }\n  }\n\n  .title,\n  .description,\n  .link {\n    background-image: radial-gradient(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));\n  }\n\n  .imagesContainer {\n    position: absolute;\n    z-index: 0;\n    width: 100%;\n    height: 100%;\n    will-change: transform;\n  }\n\n  .img1 {\n    @include img(55, 919);\n  }\n  .img2 {\n    @include img(169, 216);\n  }\n  .img3 {\n    @include img(338, 1162);\n  }\n  .img4 {\n    @include img(482, 1038);\n  }\n  .img5 {\n    @include img(551, 235);\n  }\n}\n\n.animateImages {\n  animation: revealBlurhash 5s 2.5s infinite;\n}\n\n@keyframes revealBlurhash {\n  0% {\n    opacity: 1;\n  }\n\n  25%,\n  50% {\n    opacity: 0;\n  }\n\n  75%,\n  100% {\n    opacity: 1;\n  }\n}\n\n.section {\n  position: relative;\n  background: #fff;\n  display: flex;\n  flex-direction: column;\n}\n\n@keyframes cross-fade {\n  0% { opacity: 0 }\n  10% { opacity: 1 }\n  50% { opacity: 1 }\n  60% { opacity: 0 }\n}\n\n.why-blurhash {\n  position: relative;\n  padding-top: 24px;\n  padding-bottom: 50px;\n  padding-left: 10vw;\n  display: flex;\n  min-height: 800px;\n\n  &:before, &:after {\n    content: '';\n    height: 731px;\n    width: 365px;\n    position: absolute;\n    top: 75px;\n    right: 75%;\n    background-size: 100% 100%;\n  }\n\n  &:before {\n    background-image: url(../assets/images/Bad_screen@2x.png);\n  }\n\n  &:after {\n    background-image: url(../assets/images/Good_screen@2x.png);\n    opacity: 0;\n    animation: cross-fade 5s infinite;\n  }\n\n\n  @media screen and (min-width: 600px) {\n    padding-left: 30vw;\n\n    &:before, &:after {\n      right: 60%;\n    }\n  }\n\n  .content {\n    background: rgba(229, 238, 255, 0.37);\n    height: 100%;\n    flex: 1;\n    display: flex;\n    flex-direction: column;\n    align-items: flex-start;\n    justify-content: center;\n\n    font-size: 16px;\n    line-height: 22px;\n    padding: 0 24px 24px 20vw;\n\n    @media screen and (min-width: 600px) {\n      padding: 0 20vw 50px;\n    }\n\n    p {\n      max-width: 590px;\n    }\n  }\n\n  h3 {\n    font-size: 20px;\n    font-weight: 700;\n    letter-spacing: 0.34px;\n  }\n}\n\n.how-it-works {\n  text-align: center;\n\n  p {\n    font-family: Helvetica;\n    font-size: 28px;\n    letter-spacing: -0.5px;\n    max-width: 870px;\n    margin: 0 auto;\n\n    @media screen and (max-width: 600px) {\n      font-size: 20px;\n      padding: 0 24px;\n    }\n  }\n}\n\n.demo {\n  max-width: 1200px;\n  margin: 0 auto;\n  padding: 100px 10px 130px;\n  display: flex;\n  justify-content: stretch;\n\n  @media screen and (max-width: 600px) {\n    flex-direction: column;\n    padding: 24px;\n  }\n\n  .part {\n    position: relative;\n    flex: 1;\n    margin: 0 24px;\n\n    &:first-child {\n      margin-left: 0;\n    }\n    &:last-child {\n      margin-right: 0;\n\n      &:after {\n        content: unset;\n      }\n    }\n\n    @media screen and (max-width: 600px) {\n      margin: 24px 0;\n    }\n\n    &:after {\n      content: '';\n      background: url('../assets/images/arrow.svg');\n      width: 72px;\n      height: 25px;\n      position: absolute;\n      top: -32px;\n      right: -63px;\n\n      @media screen and (max-width: 600px) {\n        top: unset;\n        right: unset;\n        bottom: -45px;\n        left: calc(50% - 32px);\n        transform: rotate(90deg);\n        z-index: 1;\n      }\n    }\n  }\n\n  .explain {\n    margin: 24px 0;\n    font-size: 18px;\n    text-align: center;\n    line-height: 24px;\n  }\n\n  .explain-small {\n    font-size: 14px;\n    color: #838383;\n    letter-spacing: -0.15px;\n    text-align: center;\n    line-height: 18px;\n  }\n\n  .predefined {\n    position: relative;\n    display: flex;\n    justify-content: space-between;\n    flex-direction: row;\n    flex-wrap: wrap;\n    height: 200px;\n\n    label {\n      position: relative;\n      width: 45%;\n      height: 90px;\n      margin-bottom: 5%;\n      cursor: pointer;\n      background-size: cover;\n\n      input {\n        position: absolute;\n        top: 16px;\n        left: 16px;\n      }\n\n      &:nth-of-type(1) {\n        background-image: url(../assets/images/img1.jpg);\n      }\n      &:nth-of-type(2) {\n        background-image: url(../assets/images/img2.jpg);\n      }\n      &:nth-of-type(3) {\n        background-image: url(../assets/images/img3.jpg);\n      }\n      &:nth-of-type(4) {\n        background-image: url(../assets/images/img4.jpg);\n      }\n\n      > img {\n        display: none;\n      }\n    }\n\n    #original-canvas {\n      position: absolute;\n      top: 0;\n      left: 0;\n      width: 100%;\n      height: 100%;\n      pointer-events: none;\n      opacity: 0;\n      transition: opacity 0.2s ease-in-out;\n      background: #eee;\n\n      &.visible {\n        pointer-events: unset;\n        opacity: 1;\n        cursor: pointer;\n      }\n    }\n  }\n\n  #file-upload {\n    display: none;\n  }\n\n  .dimension {\n    margin-top: 24px;\n    font-size: 14px;\n    color: #868789;\n    letter-spacing: -0.15px;\n    text-align: center;\n    line-height: 20px;\n\n    > div {\n      margin-top: 12px;\n    }\n\n    input {\n      background: #ffffff;\n      border: 1px solid rgba(32, 33, 37, 0.12);\n      border-radius: 4px;\n      text-align: center;\n      width: 46px;\n      height: 40px;\n    }\n  }\n\n  .demo-blurhash {\n    position: relative;\n    box-shadow: 0 4px 20px rgba(32, 33, 37, 0.2);\n    height: 200px;\n    padding: 24px;\n    background: #ffffff;\n    border-radius: 2px;\n    font-size: 18px;\n    text-align: center;\n    line-height: 24px;\n    display: flex;\n    justify-content: center;\n    align-items: center;\n\n    &:focus-within {\n      box-shadow: 0 4px 20px rgba(32, 33, 37, 0.4);\n    }\n  }\n\n  #demo-blurhash {\n    color: $wolt-id-blue;\n    word-break: break-all;\n\n    &.error {\n      color: $error-color-id;\n    }\n  }\n\n  #demo-canvas {\n    height: 200px;\n    width: 100%;\n    background: #ddd;\n  }\n}\n\n.get-started {\n  background: url(../assets/images/get-started-bg.jpg);\n  max-width: 1180px;\n  height: 556px;\n  margin: 0 auto;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  text-align: center;\n\n  h2 {\n    margin: 0;\n  }\n\n  h2,\n  p {\n    color: #fff;\n  }\n\n  p {\n    font-size: 24px;\n    line-height: 32px;\n    padding: 0 20%;\n\n    @media screen and (max-width: 600px) {\n      padding: 0 24px;\n    }\n  }\n\n  .white-button {\n    background: #fff;\n    padding: 1rem 2rem;\n    color: $wolt-id-blue;\n    text-decoration: none;\n  }\n}\n\nfooter {\n  background-color: $wolt-black;\n  height: 80px;\n  width: 100%;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  gap: 24px;\n\n  a {\n    color: $offwhite;\n    text-decoration: none;\n  }\n\n  p {\n    color: $text-grey;\n  }\n}\n"
  },
  {
    "path": "Website/src/sections/demo.js",
    "content": "import { encode, decode } from 'blurhash';\n\nconst blurhashElement = document.getElementById('demo-blurhash');\nconst canvas = document.getElementById('demo-canvas');\nconst originalCanvas = document.getElementById('original-canvas');\nconst fileInput = document.getElementById('file-upload');\nconst componentXElement = document.getElementById('component-x');\nconst componentYElement = document.getElementById('component-y');\nconst predefined = document.querySelector('.predefined');\n\nfunction render() {\n  const blurhash = blurhashElement.textContent;\n  if (blurhash) {\n    const pixels = decode(blurhash, 32, 32);\n    if (pixels) {\n      blurhashElement.classList.remove('error');\n      const ctx = canvas.getContext('2d');\n\n      const imageData = new ImageData(pixels, 32, 32);\n      ctx.putImageData(imageData, 0, 0);\n    } else {\n      blurhashElement.classList.add('error');\n    }\n  }\n}\n\nfunction clamp(n) {\n  return isNaN(n) ? 1 : Math.min(9, Math.max(1, n));\n}\n\nfunction renderSelectedFile() {\n  const file = fileInput.files[0];\n  if (file) {\n    var img = new Image();\n    originalCanvas.classList.add('visible');\n    img.onload = function () {\n      renderImage(img);\n    };\n    img.src = URL.createObjectURL(fileInput.files[0]);\n  }\n}\n\nfunction renderImage(img) {\n  const ctx = originalCanvas.getContext('2d');\n\n  ctx.drawImage(img, 0, 0, originalCanvas.width, originalCanvas.height);\n  URL.revokeObjectURL(img.src);\n\n  setTimeout(renderBlurhash, 0);\n}\n\nfunction renderBlurhash() {\n  const ctx = originalCanvas.getContext('2d');\n  const componentX = clamp(+componentXElement.value);\n  const componentY = clamp(+componentYElement.value);\n\n  const imageData = ctx.getImageData(0, 0, originalCanvas.width, originalCanvas.height);\n  const blurhash = encode(\n    imageData.data,\n    imageData.width,\n    imageData.height,\n    componentX,\n    componentY,\n  );\n  blurhashElement.textContent = blurhash;\n  render();\n}\n\nfunction renderSelectedImage() {\n  console.log('renderSelectedImage');\n  const firstPredefinedImage = document.querySelector('.predefined input:checked + img');\n  originalCanvas.classList.remove('visible');\n  fileInput.value = '';\n  requestAnimationFrame(() => renderImage(firstPredefinedImage));\n}\n\nblurhashElement.addEventListener('change', render);\nblurhashElement.addEventListener('keyup', render);\nfileInput.addEventListener('change', renderSelectedFile);\ncomponentXElement.addEventListener('keyup', renderBlurhash);\ncomponentYElement.addEventListener('keyup', renderBlurhash);\npredefined.addEventListener('change', renderSelectedImage);\noriginalCanvas.addEventListener('click', renderSelectedImage);\n\nexport default function () {\n  renderSelectedImage();\n}\n"
  },
  {
    "path": "Website/src/sections/hero.js",
    "content": "import { imageHashes } from '../constants';\nimport { decode } from 'blurhash';\nimport Velocity from 'velocity-animate';\nimport smoothscroll from 'smoothscroll-polyfill';\n\n// kick off the polyfill!\nsmoothscroll.polyfill();\n\nfunction hero() {\n  const images = document.getElementsByClassName('image-bg');\n  const imageContainer = document.getElementsByClassName('imagesContainer');\n  const content = document.getElementsByClassName('content');\n\n  function render(canvas, blurhash) {\n    if (blurhash) {\n      const pixels = decode(blurhash, 32, 32);\n      if (pixels) {\n        const ctx = canvas.getContext('2d');\n\n        const imageData = new ImageData(pixels, 32, 32);\n        ctx.putImageData(imageData, 0, 0);\n      }\n    }\n  }\n  drawBlurHash();\n  function drawBlurHash() {\n    if (!document.readyState === 'complete') {\n      return;\n    }\n    init();\n    const canvases = document.getElementsByClassName('image-canvas-bg');\n\n    if (canvases && canvases.length) {\n      for (let i = 0; i < canvases.length; i++) {\n        render(canvases[i], imageHashes[i]);\n      }\n    }\n    startAnimation();\n  }\n\n  function init() {\n    Velocity({\n      elements: imageContainer,\n      properties: { translateY: '25%' },\n      options: {\n        duration: 0,\n      },\n    });\n    Velocity({\n      elements: content,\n      properties: { opacity: 0 },\n      options: {\n        duration: 0,\n      },\n    });\n  }\n\n  function startAnimation() {\n    for (let i = 0; i < images.length; i++) {\n      images[i].classList.add('animateImages');\n    }\n    Velocity({\n      elements: imageContainer,\n      properties: { translateY: '0%' },\n      options: {\n        duration: 750,\n        delay: 500,\n        easing: 'easeInOutCubic',\n      },\n    });\n    Velocity({\n      elements: content,\n      properties: { opacity: 1 },\n      options: {\n        duration: 250,\n        delay: 1000,\n        complete: startParallax,\n      },\n    });\n  }\n\n  const translateY = (amount) => `translate3d(0%, ${amount}px, 0)`;\n\n  function startParallax() {\n    window.addEventListener('scroll', scrollImages);\n  }\n\n  function scrollImages(e) {\n    const transform = window.pageYOffset * 0.5;\n    imageContainer[0].style.transform = translateY(transform);\n    imageContainer[0].style.webkitTransform = translateY(transform);\n  }\n\n  document.getElementById('get-started').addEventListener('click', () => {\n    document.querySelector('.why-blurhash').scrollIntoView({ behavior: 'smooth' });\n  });\n}\n\nexport default hero;\n"
  },
  {
    "path": "Website/src/styles/averta.scss",
    "content": "/**\n * @license\n * MyFonts Webfont Build ID 3433766, 2017-08-08T04:46:45-0400\n * \n * The fonts listed in this notice are subject to the End User License\n * Agreement(s) entered into by the website owner. All other parties are \n * explicitly restricted from using the Licensed Webfonts(s).\n * \n * You may obtain a valid license at the URLs below.\n * \n * Webfont: AvertaStdPE-Black by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/black-177285/\n * \n * Webfont: AvertaStdPE-BlackItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/black-ital-177285/\n * \n * Webfont: AvertaStdPE-Bold by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/bold-177285/\n * \n * Webfont: AvertaStdPE-Extrabold by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/exbold-177285/\n * \n * Webfont: AvertaStdPE-BoldItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/bold-ital-177285/\n * \n * Webfont: AvertaStdPE-ExtraboldItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/exbold-ital-177285/\n * \n * Webfont: AvertaStdPE-Extrathin by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/pe-exthin/\n * \n * Webfont: AvertaStdPE-ExtrathinItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/exthin-italic-177285/\n * \n * Webfont: AvertaStdPE-Light by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/light-177285/\n * \n * Webfont: AvertaStdPE-LightItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/light-ital-177285/\n * \n * Webfont: AvertaStdPE-Regular by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/regular-177285/\n * \n * Webfont: AvertaStdPE-RegularItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/italic-177285/\n * \n * Webfont: AvertaStdPE-Semibold by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/semibold-177285/\n * \n * Webfont: AvertaStdPE-SemiboldItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/semibold-ital-177285/\n * \n * Webfont: AvertaStdPE-Thin by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/thin-177285/\n * \n * Webfont: AvertaStdPE-ThinItalic by Intelligent Design\n * URL: https://www.myfonts.com/fonts/intelligent-foundry/averta-standard/thin-italic-177285/\n * \n * \n * License: https://www.myfonts.com/viewlicense?type=web&buildid=3433766\n * Licensed pageviews: 10,000\n * Webfonts copyright: Copyright (c) 2015 by Kostas Bartsokas. All rights reserved.\n * \n * © 2017 MyFonts Inc\n*/\n\n/* @import must be at top of file, otherwise CSS will not work */\n@import url('//hello.myfonts.net/count/346526');\n\n@font-face {\n  font-family: 'AvertaStdPE-Black';\n  src: url('../assets/fonts/averta/346526_0_0.eot');\n  src: url('../assets/fonts/averta/346526_0_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_0_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_0_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_0_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-BlackItalic';\n  src: url('../assets/fonts/averta/346526_1_0.eot');\n  src: url('../assets/fonts/averta/346526_1_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_1_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_1_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_1_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-Bold';\n  src: url('../assets/fonts/averta/346526_2_0.eot');\n  src: url('../assets/fonts/averta/346526_2_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_2_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_2_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_2_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-Extrabold';\n  src: url('../assets/fonts/averta/346526_3_0.eot');\n  src: url('../assets/fonts/averta/346526_3_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_3_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_3_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_3_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-BoldItalic';\n  src: url('../assets/fonts/averta/346526_4_0.eot');\n  src: url('../assets/fonts/averta/346526_4_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_4_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_4_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_4_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-ExtraboldItalic';\n  src: url('../assets/fonts/averta/346526_5_0.eot');\n  src: url('../assets/fonts/averta/346526_5_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_5_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_5_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_5_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-Extrathin';\n  src: url('../assets/fonts/averta/346526_6_0.eot');\n  src: url('../assets/fonts/averta/346526_6_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_6_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_6_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_6_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-ExtrathinItalic';\n  src: url('../assets/fonts/averta/346526_7_0.eot');\n  src: url('../assets/fonts/averta/346526_7_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_7_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_7_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_7_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-Light';\n  src: url('../assets/fonts/averta/346526_8_0.eot');\n  src: url('../assets/fonts/averta/346526_8_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_8_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_8_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_8_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-LightItalic';\n  src: url('../assets/fonts/averta/346526_9_0.eot');\n  src: url('../assets/fonts/averta/346526_9_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_9_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_9_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_9_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-Regular';\n  src: url('../assets/fonts/averta/346526_A_0.eot');\n  src: url('../assets/fonts/averta/346526_A_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_A_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_A_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_A_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-RegularItalic';\n  src: url('../assets/fonts/averta/346526_B_0.eot');\n  src: url('../assets/fonts/averta/346526_B_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_B_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_B_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_B_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-Semibold';\n  src: url('../assets/fonts/averta/346526_C_0.eot');\n  src: url('../assets/fonts/averta/346526_C_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_C_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_C_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_C_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-SemiboldItalic';\n  src: url('../assets/fonts/averta/346526_D_0.eot');\n  src: url('../assets/fonts/averta/346526_D_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_D_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_D_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_D_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-Thin';\n  src: url('../assets/fonts/averta/346526_E_0.eot');\n  src: url('../assets/fonts/averta/346526_E_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_E_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_E_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_E_0.ttf') format('truetype');\n}\n\n@font-face {\n  font-family: 'AvertaStdPE-ThinItalic';\n  src: url('../assets/fonts/averta/346526_F_0.eot');\n  src: url('../assets/fonts/averta/346526_F_0.eot?#iefix') format('embedded-opentype'),\n    url('../assets/fonts/averta/346526_F_0.woff2') format('woff2'),\n    url('../assets/fonts/averta/346526_F_0.woff') format('woff'),\n    url('../assets/fonts/averta/346526_F_0.ttf') format('truetype');\n}\n"
  },
  {
    "path": "Website/src/styles/base.scss",
    "content": "html {\n  height: 100%;\n  @include fluid-type(font-size, 20rem, 100rem, 0.8rem, 1rem);\n}\n\nbody {\n  width: 100%;\n  min-height: 100vh;\n  background: #fff;\n  min-width: 320px;\n  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n  -webkit-tap-highlight-color: transparent;\n}\n\nstrong,\nlabel,\ninput,\ntextarea,\ninput,\nbutton {\n  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n}\n::-webkit-input-placeholder,\n::-moz-placeholder,\n:-ms-input-placeholder,\ninput:-moz-placeholder {\n  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',\n    'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;\n  color: $text-grey-light;\n}\n\nbody,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\np,\na,\nli,\nstrong,\nlabel,\ninput,\ntextarea {\n  color: $dark-grey;\n  line-height: 1.4;\n  text-rendering: optimizeLegibility;\n}\n\nh1 {\n  font-size: 2rem;\n  font-weight: 700;\n}\nh2 {\n  font-size: 1.8rem;\n  font-weight: 700;\n}\nh3 {\n  font-size: 1.6rem;\n  font-weight: 700;\n}\nh4 {\n  font-size: 1.4rem;\n  font-weight: 700;\n}\nh5 {\n  font-size: 1.2rem;\n  font-weight: 700;\n}\nh6 {\n  font-size: 1rem;\n  font-weight: 700;\n}\n\nbody > svg {\n  display: none;\n}\n\np,\nlabel,\ntextarea,\ninput,\nlabel,\nselect,\nbutton,\ntextarea {\n  font-size: 1rem;\n}\n"
  },
  {
    "path": "Website/src/styles/resets.scss",
    "content": "/* ----------------------------------------------------------------------------------------------------\n\nSuper Form Reset\n\nA couple of things to watch out for:\n\n- IE8: If a text input doesn't have padding on all sides or none the text won't be centered.\n- The default border sizes on text inputs in all UAs seem to be slightly different. You're better off using custom borders.\n- You NEED to set the font-size and family on all form elements\n- Search inputs need to have their appearance reset and the box-sizing set to content-box to match other UAs\n- You can style the upload button in webkit using ::-webkit-file-upload-button\n- ::-webkit-file-upload-button selectors can't be used in the same selector as normal ones. FF and IE freak out.\n- IE: You don't need to fake inline-block with labels and form controls in IE. They function as inline-block.\n- By turning off ::-webkit-search-decoration, it removes the extra whitespace on the left on search inputs\n\n----------------------------------------------------------------------------------------------------*/\n\ninput,\nlabel,\nselect,\nbutton,\ntextarea {\n  margin: 0;\n  border: 0;\n  padding: 0;\n  display: inline-block;\n  vertical-align: middle;\n  white-space: normal;\n  background: none;\n  line-height: 1;\n\n  /* Browsers have different default form fonts */\n  font-size: 13px;\n  font-family: Arial;\n}\n\n/* Remove the stupid outer glow in Webkit */\ninput:focus {\n  outline: 0;\n}\n\n/* Box Sizing Reset\n-----------------------------------------------*/\n\n/* All of our custom controls should be what we expect them to be */\ninput,\ntextarea {\n  -webkit-box-sizing: content-box;\n  -moz-box-sizing: content-box;\n  box-sizing: content-box;\n}\n\n/* These elements are usually rendered a certain way by the browser */\nbutton,\ninput[type='reset'],\ninput[type='button'],\ninput[type='submit'],\ninput[type='checkbox'],\ninput[type='radio'],\nselect {\n  -webkit-box-sizing: border-box;\n  -moz-box-sizing: border-box;\n  box-sizing: border-box;\n}\n\n/* Text Inputs\n-----------------------------------------------*/\n\ninput[type='date'],\ninput[type='datetime'],\ninput[type='datetime-local'],\ninput[type='email'],\ninput[type='month'],\ninput[type='number'],\ninput[type='password'],\ninput[type='range'],\ninput[type='search'],\ninput[type='tel'],\ninput[type='text'],\ninput[type='time'],\ninput[type='url'],\ninput[type='week'] {\n}\n\n/* Button Controls\n-----------------------------------------------*/\n\ninput[type='checkbox'],\ninput[type='radio'] {\n  width: 13px;\n  height: 13px;\n}\n\n/* File Uploads\n-----------------------------------------------*/\n\ninput[type='file'] {\n}\n\n/* Search Input\n-----------------------------------------------*/\n\n/* Make webkit render the search input like a normal text field */\ninput[type='search'] {\n  -webkit-appearance: textfield;\n  -webkit-box-sizing: content-box;\n}\n\n/* Turn off the recent search for webkit. It adds about 15px padding on the left */\n::-webkit-search-decoration {\n  display: none;\n}\n\n/* Buttons\n-----------------------------------------------*/\n\nbutton,\ninput[type='reset'],\ninput[type='button'],\ninput[type='submit'] {\n  /* Fix IE7 display bug */\n  overflow: visible;\n  width: auto;\n}\n\n/* IE8 and FF freak out if this rule is within another selector */\n::-webkit-file-upload-button {\n  padding: 0;\n  border: 0;\n  background: none;\n}\n\n/* Textarea\n-----------------------------------------------*/\n\ntextarea {\n  /* Move the label to the top */\n  vertical-align: top;\n\n  /* Turn off scroll bars in IE unless needed */\n  overflow: auto;\n}\n\n/* Selects\n-----------------------------------------------*/\n\nselect {\n}\n\nselect[multiple] {\n  /* Move the label to the top */\n  vertical-align: top;\n}\n\n/* selected Foundation resets */\n/* copied from node_modules/foundation-sites/scss/_global.scss */\n\nhtml {\n  box-sizing: border-box;\n}\n\n// Set box-sizing globally to handle padding and border widths\n*,\n*::before,\n*::after {\n  box-sizing: inherit;\n}\n\n// Default body styles\nbody {\n  margin: 0;\n  padding: 0;\n\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n\nimg {\n  // Get rid of gap under images by making them display: inline-block; by default\n  display: inline-block;\n  vertical-align: middle;\n\n  // Grid defaults to get images and embeds to work properly\n  max-width: 100%;\n  height: auto;\n  -ms-interpolation-mode: bicubic;\n}\n"
  },
  {
    "path": "Website/src/styles/utils.scss",
    "content": "@mixin fluid-type($properties, $min-vw, $max-vw, $min-value, $max-value) {\n  & {\n    @each $property in $properties {\n      #{$property}: $min-value;\n    }\n\n    @media screen and (min-width: $min-vw) {\n      @each $property in $properties {\n        #{$property}: calc(\n          #{$min-value} +\n            #{strip-unit($max-value - $min-value)} *\n            (100vw - #{$min-vw}) /\n            #{strip-unit($max-vw - $min-vw)}\n        );\n      }\n    }\n\n    @media screen and (min-width: $max-vw) {\n      @each $property in $properties {\n        #{$property}: $max-value;\n      }\n    }\n  }\n}\n\n@function strip-unit($value) {\n  @return $value / ($value * 0 + 1);\n}\n\n@function top($px) {\n  @return $px / 768 * 100%;\n}\n\n@function left($px) {\n  @return $px / 1440 * 100%;\n}\n"
  },
  {
    "path": "Website/src/styles/variables.scss",
    "content": "@function rem($pixels, $context: 16px) {\n  $pixels: strip-units($pixels);\n  $context: strip-units($context);\n  @return ($pixels / $context) * 1rem;\n}\n\n$wolt-id-blue: #0019ff;\n$error-color-id: #ff1900;\n$header-height: 70px;\n// Brand\n$wolt-blue: #0065aa;\n$wolt-blue-light: #4a90e2;\n$wolt-blue-lighter: rgba(74, 144, 226, 0.5);\n$wolt-blue-gradient: linear-gradient(-180deg, #0077c8 0%, #0065aa 100%);\n$wolt-black: #141414;\n\n// Text\n$offwhite: #eff1f3;\n$offwhite-light: #f7f8f9;\n$dark-grey: #202125;\n$text-color: #404040;\n$text-grey: #838383;\n$text-grey-light: #acacac;\n"
  },
  {
    "path": "Website/webpack.config.js",
    "content": "const path = require('path');\nconst webpack = require('webpack');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst MiniCssExtractPlugin = require('mini-css-extract-plugin');\n\n// Is the current build a development build\nconst env = process.env.NODE_ENV;\n\nconst IS_DEV = !env ? true : env;\nconst dirNode = 'node_modules';\nconst dirApp = path.join(__dirname, 'src');\nconst dirAssets = path.join(__dirname, 'assets');\n\n/**\n * Webpack Configuration\n */\nmodule.exports = {\n  entry: {\n    blurhash: path.join(dirApp, 'index'),\n  },\n  resolve: {\n    modules: [dirNode, dirApp, dirAssets],\n  },\n  output: {\n    filename: '[name].[hash].js',\n  },\n  devtool: IS_DEV ? 'cheap-module-source-map' : 'source-map',\n  plugins: [\n    new MiniCssExtractPlugin({\n      filename: '[name].[hash].css',\n    }),\n    new webpack.DefinePlugin({\n      IS_DEV: IS_DEV,\n    }),\n    new webpack.HotModuleReplacementPlugin(),\n    new HtmlWebpackPlugin({\n      template: path.join(dirApp, 'index.ejs'),\n      title: 'BlurHash',\n    }),\n  ],\n  module: {\n    rules: [\n      // BABEL\n      {\n        test: /\\.js$/,\n        loader: 'babel-loader',\n        exclude: /(node_modules)/,\n        options: {\n          compact: true,\n        },\n      },\n\n      // CSS / SASS\n      {\n        test: /\\.scss/,\n        use: [\n          IS_DEV && MiniCssExtractPlugin.loader,\n          {\n            loader: 'css-loader',\n            options: {\n              sourceMap: IS_DEV,\n            },\n          },\n          {\n            loader: 'sass-loader',\n            options: {\n              sourceMap: IS_DEV,\n              sassOptions: {\n                includePaths: [dirAssets],\n              },\n            },\n          },\n        ],\n      },\n      // IMAGES\n      {\n        test: /\\.(jpe?g|png|gif|svg)$/,\n        type: 'asset/resource',\n      },\n\n      // FONTS\n      {\n        test: /\\.(eot|otf|woff2?|ttf)[\\?]?.*$/, // eslint-disable-line\n        type: 'asset/resource',\n      },\n    ],\n  },\n  devServer: {\n    host: '0.0.0.0',\n    historyApiFallback: true,\n    hot: true,\n  },\n};\n"
  }
]