Compare commits

...

No commits in common. "master" and "gh-pages" have entirely different histories.

204 changed files with 789 additions and 27943 deletions

25
.gitignore vendored
View File

@ -1,25 +0,0 @@
## OS X specific
.DS_Store
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
C/blurhash
Ruby/.*
Ruby/Makefile
Python/build/
*.bundle
*.so
*.o
*.pyc
# Website
Website/node_modules/
Website/dist/

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "Python"]
path = Python
url = https://github.com/creditornot/blurhash-python.git

View File

@ -1,66 +0,0 @@
# BlurHash Algorithm
## Summary
BlurHash applies a simple [DCT transform](https://en.wikipedia.org/wiki/Discrete_cosine_transform) to the image data,
keeping only the first few components, and then encodes these components using a base 83 encoding, with a JSON,
HTML and shell-safe character set. The DC component, which represents the average colour of the image, is stored exactly
as an sRGB value, for easy use without impleneting the full algorithm. The AC components are encoded lossily.
## Reference implementation
[Simplified Swift decoder implemenation.](Swift/BlurHashDecode.swift)
[Simplified Swift encoder implemenation.](Swift/BlurHashEncode.swift)
## Structure
Here follows an example of a BlurHash string, with the different parts labelled:
Example: LlMF%n00%#MwS|WCWEM{R*bbWBbH
Legend: 12333344....................
1. **Number of components, 1 digit.**
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`.
2. **Maximum AC component value, 1 digit.**
All AC components are scaled by this value. It represents a floating-point value of `(max + 1) / 166`.
3. **Average colour. 4 digits.**
The average colour of the image in sRGB space, encoded as a 24-bit RGB value, with R in the most signficant position. This value can
be used directly if you only want the average colour rather than the full DCT-encoded image.
4. **AC components, 2 digits each, `nx * ny - 1` components in total.**
The AC components of the DCT transform, ordred by increasing X first, then Y. They are encoded as three values for `R`, `G` and `B`,
each between 0 and 18. They are combined together as `R * 19^2 + G * 19 + B`, for a total range of 0 to 6859.
Each value represents a floating-point value between -1 and 1. 0-8 represent negative values, 9 represents zero, and 10-18
represent positive values. Positive values are encoded as `((X - 9) / 9) ^ 2`, while negative
values are encoded as `-((9 - X) / 9 ) ^ 2`. `^` represents exponentiation. This value is then multiplied by the maximum AC
component value, field 2 above.
## Base 83
A custom base 83 encoding is used. Values are encoded individually, using 1 to 4 digits, and concatenated together. Multiple-digit
values are encoded in big-endian order, with the most signficant digit first.
The character used set is `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~`.
## Discrete Cosine Transform
To decode a single pixel of output, you loop over the DCT components and calculate a weighted sum of cosine functions. In
pseudocode, for a normalised pixel position `x`, `y`, with each coordinate ranging from 0 to 1, and components `Cij` ,
you calculate the following for each of R, G and B:
foreach j in 0 ... ny - 1
foreach i in 0 ... nx - 1
value = value + Cij * cos(x * i * pi) * cos(y * j * pi)
The `C00` component is the DC component, while the others are the AC components. The DC component must first be converted
from sRGB to linear RGB space. AC components are already linear.
Once the R, G and B values have been calculated, the must be converted from linear to your output colourspace, usually sRGB.

View File

@ -1,8 +0,0 @@
PROGRAM=blurhash
$(PROGRAM): blurhash_stb.c encode.c encode.h stb_image.h
$(CC) -o $@ blurhash_stb.c encode.c -lm
.PHONY: clean
clean:
rm -f $(PROGRAM)

View File

@ -1,34 +0,0 @@
# BlurHash encoder in portable C
This code implements an encoder for the BlurHash algorithm in C. It can be used to integrate into other language
using an FFI interface. Currently the Python integration uses this code.
## Usage as a library
Include the `encode.c` and `encode.h` files in your project. They have no external dependencies.
A single file function is defined:
const char *blurHashForPixels(int xComponents, int yComponents, int width, int height, uint8_t *rgb, size_t bytesPerRow) {
This function returns a string containing the BlurHash. This memory is managed by the function, and you should not free it.
It will be overwritten on the next call into the function, so be careful!
* `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.
* `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.
* `width` - The width in pixels of the supplied image.
* `height` - The height in pixels of the supplied image.
* `rgb` - A pointer to the pixel data. This is supplied in RGB order, with 3 bytes per pixels.
* `bytesPerRow` - The number of bytes per row of the RGB pixel data.
## Usage as a command-line tool
You can also build a command-line version to test the encoder. However, note that it uses `stb_image` to load images,
which is not really security-hardened, so it is **not** recommended to use this version in production on untrusted data!
Use one of the integrations instead, which use more robust image loading libraries.
Nevertheless, if you want to try it out quickly, simply run:
$ make
$ ./blurhash 4 3 ../Swift/BlurHashTest/pic1.png
LaJHjmVu8_~po#smR+a~xaoLWCRj

View File

@ -1,44 +0,0 @@
#include "encode.h"
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <stdio.h>
const char *blurHashForFile(int xComponents, int yComponents,const char *filename);
int main(int argc, const char **argv) {
if(argc != 4) {
fprintf(stderr, "Usage: %s x_components y_components imagefile\n", argv[0]);
return 1;
}
int xComponents = atoi(argv[1]);
int yComponents = atoi(argv[2]);
if(xComponents < 1 || xComponents > 8 || yComponents < 1 || yComponents > 8) {
fprintf(stderr, "Component counts must be between 1 and 8.\n");
return 1;
}
const char *hash = blurHashForFile(xComponents, yComponents, argv[3]);
if(!hash) {
fprintf(stderr, "Failed to load image file \"%s\".\n", argv[3]);
return 1;
}
printf("%s\n", hash);
return 0;
}
const char *blurHashForFile(int xComponents, int yComponents,const char *filename) {
int width, height, channels;
unsigned char *data = stbi_load(filename, &width, &height, &channels, 3);
if(!data) return NULL;
const char *hash = blurHashForPixels(xComponents, yComponents, width, height, data, width * 3);
stbi_image_free(data);
return hash;
}

View File

@ -1,137 +0,0 @@
#include "encode.h"
#include <string.h>
#include <math.h>
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static float *multiplyBasisFunction(int xComponent, int yComponent, int width, int height, uint8_t *rgb, size_t bytesPerRow);
static char *encode_int(int value, int length, char *destination);
static int linearTosRGB(float value);
static float sRGBToLinear(int value);
static int encodeDC(float r, float g, float b);
static int encodeAC(float r, float g, float b, float maximumValue);
static float signPow(float value, float exp);
const char *blurHashForPixels(int xComponents, int yComponents, int width, int height, uint8_t *rgb, size_t bytesPerRow) {
static char buffer[2 + 4 + (9 * 9 - 1) * 2 + 1];
if(xComponents < 1 || xComponents > 9) return NULL;
if(yComponents < 1 || yComponents > 9) return NULL;
float factors[yComponents][xComponents][3];
memset(factors, 0, sizeof(factors));
for(int y = 0; y < yComponents; y++) {
for(int x = 0; x < xComponents; x++) {
float *factor = multiplyBasisFunction(x, y, width, height, rgb, bytesPerRow);
factors[y][x][0] = factor[0];
factors[y][x][1] = factor[1];
factors[y][x][2] = factor[2];
}
}
float *dc = factors[0][0];
float *ac = dc + 3;
int acCount = xComponents * yComponents - 1;
char *ptr = buffer;
int sizeFlag = (xComponents - 1) + (yComponents - 1) * 9;
ptr = encode_int(sizeFlag, 1, ptr);
float maximumValue;
if(acCount > 0) {
float actualMaximumValue = 0;
for(int i = 0; i < acCount * 3; i++) {
actualMaximumValue = fmaxf(fabsf(ac[i]), actualMaximumValue);
}
int quantisedMaximumValue = fmaxf(0, fminf(82, floorf(actualMaximumValue * 166 - 0.5)));
maximumValue = ((float)quantisedMaximumValue + 1) / 166;
ptr = encode_int(quantisedMaximumValue, 1, ptr);
} else {
maximumValue = 1;
ptr = encode_int(0, 1, ptr);
}
ptr = encode_int(encodeDC(dc[0], dc[1], dc[2]), 4, ptr);
for(int i = 0; i < acCount; i++) {
ptr = encode_int(encodeAC(ac[i * 3 + 0], ac[i * 3 + 1], ac[i * 3 + 2], maximumValue), 2, ptr);
}
*ptr = 0;
return buffer;
}
static float *multiplyBasisFunction(int xComponent, int yComponent, int width, int height, uint8_t *rgb, size_t bytesPerRow) {
float r = 0, g = 0, b = 0;
float normalisation = (xComponent == 0 && yComponent == 0) ? 1 : 2;
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
float basis = cosf(M_PI * xComponent * x / width) * cosf(M_PI * yComponent * y / height);
r += basis * sRGBToLinear(rgb[3 * x + 0 + y * bytesPerRow]);
g += basis * sRGBToLinear(rgb[3 * x + 1 + y * bytesPerRow]);
b += basis * sRGBToLinear(rgb[3 * x + 2 + y * bytesPerRow]);
}
}
float scale = normalisation / (width * height);
static float result[3];
result[0] = r * scale;
result[1] = g * scale;
result[2] = b * scale;
return result;
}
static int linearTosRGB(float value) {
float v = fmaxf(0, fminf(1, value));
if(v <= 0.0031308) return v * 12.92 * 255 + 0.5;
else return (1.055 * powf(v, 1 / 2.4) - 0.055) * 255 + 0.5;
}
static float sRGBToLinear(int value) {
float v = (float)value / 255;
if(v <= 0.04045) return v / 12.92;
else return powf((v + 0.055) / 1.055, 2.4);
}
static int encodeDC(float r, float g, float b) {
int roundedR = linearTosRGB(r);
int roundedG = linearTosRGB(g);
int roundedB = linearTosRGB(b);
return (roundedR << 16) + (roundedG << 8) + roundedB;
}
static int encodeAC(float r, float g, float b, float maximumValue) {
int quantR = fmaxf(0, fminf(18, floorf(signPow(r / maximumValue, 0.5) * 9 + 9.5)));
int quantG = fmaxf(0, fminf(18, floorf(signPow(g / maximumValue, 0.5) * 9 + 9.5)));
int quantB = fmaxf(0, fminf(18, floorf(signPow(b / maximumValue, 0.5) * 9 + 9.5)));
return quantR * 19 * 19 + quantG * 19 + quantB;
}
static float signPow(float value, float exp) {
return copysignf(powf(fabsf(value), exp), value);
}
static char characters[83]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~";
static char *encode_int(int value, int length, char *destination) {
int divisor = 1;
for(int i = 0; i < length - 1; i++) divisor *= 83;
for(int i = 0; i < length; i++) {
int digit = (value / divisor) % 83;
divisor /= 83;
*destination++ = characters[digit];
}
return destination;
}

View File

@ -1,9 +0,0 @@
#ifndef __BLURHASH_ENCODE_H__
#define __BLURHASH_ENCODE_H__
#include <stdint.h>
#include <stdlib.h>
const char *blurHashForPixels(int xComponents, int yComponents, int width, int height, uint8_t *rgb, size_t bytesPerRow);
#endif

File diff suppressed because it is too large Load Diff

1
CNAME Normal file
View File

@ -0,0 +1 @@
blurha.sh

View File

@ -1,74 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at dag.agren@wolt.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

40
Kotlin/.gitignore vendored
View File

@ -1,40 +0,0 @@
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
.idea/.workspace
# http://stackoverflow.com/questions/16736856/what-should-be-in-my-gitignore-for-an-android-studio-project
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
.idea
**/*.iml
*.hprof
**/*.project

View File

@ -1,3 +0,0 @@
# BlurHash in Kotlin, for Android

View File

@ -1,29 +0,0 @@
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -1,29 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.wolt.blurhash"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(path: ':lib')
implementation 'androidx.appcompat:appcompat:1.1.0'
}

View File

@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wolt.blurhashapp">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.wolt.blurhashapp.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -1,24 +0,0 @@
package com.wolt.blurhashapp
import android.os.Bundle
import android.view.View
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.wolt.blurhashkt.BlurHashDecoder
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val etInput: EditText = findViewById(R.id.etInput)
val ivResult: ImageView = findViewById(R.id.ivResult)
findViewById<View>(R.id.tvDecode).setOnClickListener {
val bitmap = BlurHashDecoder.decode(etInput.text.toString(), 20, 12)
ivResult.setImageBitmap(bitmap)
}
}
}

View File

@ -1,34 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
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"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0"/>
<item
android:color="#00000000"
android:offset="1.0"/>
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
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"
android:strokeColor="#00000000"
android:strokeWidth="1"/>
</vector>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#ff009de0"/>
<corners android:radius="8dp"/>
</shape>

View File

@ -1,171 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z"/>
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF"
android:strokeWidth="0.8"/>
</vector>

View File

@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="24dp">
<EditText
android:id="@+id/etInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:hint="@string/hint_blurhash"
android:inputType="text"
android:singleLine="true"
android:text="LEHV6nWB2yk8pyo0adR*.7kCMdnj"
android:textColor="@color/colorAccent" />
<TextView
android:id="@+id/tvDecode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="12dp"
android:background="@color/colorPrimary"
android:elevation="8dp"
android:paddingStart="12dp"
android:paddingTop="8dp"
android:paddingEnd="12dp"
android:paddingBottom="8dp"
android:text="@string/title_button_decode"
android:textColor="@color/colorAccent"
android:textSize="16sp" />
<ImageView
android:id="@+id/ivResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:adjustViewBounds="true" />
</LinearLayout>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#29b6f6</color>
<color name="colorPrimaryDark">#0086c3</color>
<color name="colorAccent">#444444</color>
</resources>

View File

@ -1,5 +0,0 @@
<resources>
<string name="app_name">BlurHash</string>
<string name="hint_blurhash">BlurHash string</string>
<string name="title_button_decode">Decode!</string>
</resources>

View File

@ -1,9 +0,0 @@
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>

View File

@ -1,15 +0,0 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

Binary file not shown.

View File

@ -1,6 +0,0 @@
#Mon Jul 01 10:02:38 EEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

172
Kotlin/gradlew vendored
View File

@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
Kotlin/gradlew.bat vendored
View File

@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -1,30 +0,0 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

View File

@ -1,21 +0,0 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@ -1 +0,0 @@
<manifest package="com.wolt.blurhashkt" />

View File

@ -1,122 +0,0 @@
package com.wolt.blurhashkt
import android.graphics.Bitmap
import android.graphics.Color
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.withSign
object BlurHashDecoder {
fun decode(blurHash: String?, width: Int, height: Int, punch: Float = 1f): Bitmap? {
if (blurHash == null || blurHash.length < 6) {
return null
}
val numCompEnc = decode83(blurHash, 0, 1)
val numCompX = (numCompEnc % 9) + 1
val numCompY = (numCompEnc / 9) + 1
if (blurHash.length != 4 + 2 * numCompX * numCompY) {
return null
}
val maxAcEnc = decode83(blurHash, 1, 2)
val maxAc = (maxAcEnc + 1) / 166f
val colors = Array(numCompX * numCompY) { i ->
if (i == 0) {
val colorEnc = decode83(blurHash, 2, 6)
decodeDc(colorEnc)
} else {
val from = 4 + i * 2
val colorEnc = decode83(blurHash, from, from + 2)
decodeAc(colorEnc, maxAc * punch)
}
}
return composeBitmap(width, height, numCompX, numCompY, colors)
}
private fun decode83(str: String, from: Int = 0, to: Int = str.length): Int {
var result = 0
for (i in from until to) {
val index = charMap[str[i]] ?: -1
if (index != -1) {
result = result * 83 + index
}
}
return result
}
private fun decodeDc(colorEnc: Int): FloatArray {
val r = colorEnc shr 16
val g = (colorEnc shr 8) and 255
val b = colorEnc and 255
return floatArrayOf(srgbToLinear(r), srgbToLinear(g), srgbToLinear(b))
}
private fun srgbToLinear(colorEnc: Int): Float {
val v = colorEnc / 255f
return if (v <= 0.04045f) {
(v / 12.92f)
} else {
((v + 0.055f) / 1.055f).pow(2.4f)
}
}
private fun decodeAc(value: Int, maxAc: Float): FloatArray {
val r = value / (19 * 19)
val g = (value / 19) % 19
val b = value % 19
return floatArrayOf(
signedPow2((r - 9) / 9.0f) * maxAc,
signedPow2((g - 9) / 9.0f) * maxAc,
signedPow2((b - 9) / 9.0f) * maxAc
)
}
private fun signedPow2(value: Float) = value.pow(2f).withSign(value)
private fun composeBitmap(
width: Int, height: Int,
numCompX: Int, numCompY: Int,
colors: Array<FloatArray>
): Bitmap {
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
for (y in 0 until height) {
for (x in 0 until width) {
var r = 0f
var g = 0f
var b = 0f
for (j in 0 until numCompY) {
for (i in 0 until numCompX) {
val basis = (cos(PI * x * i / width) * cos(PI * y * j / height)).toFloat()
val color = colors[j * numCompX + i]
r += color[0] * basis
g += color[1] * basis
b += color[2] * basis
}
}
bitmap.setPixel(x, y, Color.rgb(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b)))
}
}
return bitmap
}
private fun linearToSrgb(value: Float): Int {
val v = value.coerceIn(0f, 1f)
return if (v <= 0.0031308f) {
(v * 12.92f * 255f + 0.5f).toInt()
} else {
((1.055f * v.pow(1 / 2.4f) - 0.055f) * 255 + 0.5f).toInt()
}
}
private val charMap = listOf(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '#', '$', '%', '*', '+', ',',
'-', '.', ':', ';', '=', '?', '@', '[', ']', '^', '_', '{', '|', '}', '~'
)
.mapIndexed { i, c -> c to i }
.toMap()
}

View File

@ -1 +0,0 @@
include ':demo', ':lib'

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 436 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 398 KiB

1
Python

@ -1 +0,0 @@
Subproject commit 7469c813ea646ac022ca2879de76cc6e453237a1

179
Readme.md
View File

@ -1,179 +0,0 @@
# [BlurHash](http://blurha.sh)
BlurHash is a compact representation of a placeholder for an image.
## Why would you want this?
Does your designer cry every time you load their beautifully designed screen, and it is full of empty boxes because all the
images have not loaded yet? Does your database engineer cry when you want to solve this by trying to cram little thumbnail
images into your data to show as placeholders?
BlurHash will solve your problems! How? Like this:
<img src="Media/WhyBlurHash.png" width="600">
You can also see nice examples and try it out yourself at [blurha.sh](http://blurha.sh/)!
## How does it work?
In short, BlurHash takes an image, and gives you a short string (only 20-30 characters!) that represents the placeholder for this
image. You do this on the backend of your service, and store the string along with the image. When you send data to your
client, you send both the URL to the image, and the BlurHash string. Your client then takes the string, and decodes it into an
image that it shows while the real image is loading over the network. The string is short enough that it comfortably fits into
whatever data format you use. For instance, it can easily be added as a field in a JSON object.
In summary:
<img src="Media/HowItWorks1.jpg" width="250">&nbsp;&nbsp;&nbsp;<img src="Media/HowItWorks2.jpg" width="250">
Want to know all the gory technical details? Read the [algorithm description](Algorithm.md).
Implementing the algorithm is actually quite easy! Implementations are short and easily ported to your favourite language or
platform.
## Implementations
So far, we have created these implementations:
* [C](C) - An encoder implemenation in portable C code.
* [Swift](Swift) - Encoder and decoder implementations, and a larger library offering advanced features.
There is also an example app to play around with the algorithm.
* [Kotlin](Kotlin) - A decoder implementation for Android.
* [TypeScript](TypeScript) - Encoder and decoder implementations, and an example page to test.
* [Python](https://github.com/woltapp/blurhash-python) - Integration of the C encoder code into Python.
These cover our use cases, but could probably use polishing, extending and improving. There are also these third party implementations that we know of:
* [Pure Python](https://github.com/halcy/blurhash-python) - Implementation of both the encoder and decoder in pure Python.
* [One version in Go](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjJ9ueT9pXjAhXRw6YKHfrGBNcQFjAAegQIABAB&url=https%3A%2F%2Fgithub.com%2Fbbrks%2Fgo-blurhash&usg=AOvVaw2alZSHvT7HbublYbpNn9fY), and [another version in Go](https://github.com/buckket/go-blurhash).
* [PHP](https://github.com/kornrunner/php-blurhash) - Encoder and decoder implementations in pure PHP.
* [Java](https://github.com/hsch/blurhash-java) - Encoder implementation in Java.
* [Clojure](https://github.com/siili-core/blurhash) - Encoder and decoder implementations in Clojure.
* [Nim](https://github.com/SolitudeSF/blurhash) - Encoder and decoder implementation in pure Nim.
* [Rust and WebAssembly](https://github.com/fpapado/blurhash-rust-wasm) - Encoder and decoder implementations in Rust. Distributed as both native Rust and WebAssembly packages.
Perhaps you'd like to help extend this list? Which brings us to...
## Contributing
We'd love contributions! The algorithm is [very simple](Algorithm.md) - less than two hundred lines of code - and can easily be
ported to your platform of choice. And having support for more platforms would be wonderful! So, Java decoder? Golang encoder?
Haskell? Rust? We want them all!
We will also try to tag any issues on our [issue tracker](https://github.com/woltapp/blurhash/issues) that we'd love help with, so
if you just want to dip in, go have a look.
You 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.
If you do want to contribute to this project, we have a [code of conduct](CodeOfConduct.md).
## Users
Who uses BlurHash? Here are some projects we know about:
* [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.
* [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.
## Good Questions
### How fast is encoding? Decoding?
These implementations are not very optimised. Running them on very large images can be a bit slow. The performance of
the encoder and decoder are about the same for the same input or output size, so decoding very large placeholders, especially
on your UI thread, can also be a bit slow.
However! 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,
so you should scale your images down before running BlurHash on them. If you are creating thumbnails, run BlurHash on those
instead of the full images.
Similarly, when displaying the placeholders, very small images work very well when scaled up. We usually decode placeholders
that 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.
### How do I pick the number of X and Y components?
It depends a bit on taste. The more components you pick, the more information is retained in the placeholder, but the longer
the BlurHash string will be. Also, it doesn't always look good with too many components. We usually go with 4 by 3, which
seems to strike a nice balance.
However, you should adjust the number of components depending on the aspect ratio of your images. For instance, very wide
images should have more X components and fewer Y components.
The Swift example project contains a test app where you can play around with the parameters and see the results.
### What is the `punch` parameter in some of these implementations?
It is a parameter that adjusts the contrast on the decoded image. 1 means normal, smaller values will make the effect more subtle,
and larger values will make it stronger. This is basically a design parameter, which lets you adjust the look.
Technically, what it does is scale the AC components up or down.
### Is this only useful as an image loading placeholder?
Well, that is what it was designed for originally, but it turns out to be useful for a few other things:
* Masking images without having to use expensive blurs - [Mastodon](http://github.com/tootsuite/mastodon) uses it for this.
* 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.
* 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.
### Why base 83?
First, 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.
Secondly, 83 * 83 is very close to, and a little more than, 19 * 19 * 19, making it ideal for encoding three AC components in two
characters.
### What about using the full Unicode character set to get a more efficient encoding?
We haven't looked into how much overehead UTF-8 encoding would introduce versus base 83 in single-byte characters, but
the encoding and decoding would probably be a lot more complicated, so in the spirit of minimalism BlurHash uses the simpler
option. It might also be awkward to copy-paste, depending on OS capabilities.
If 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.
### What about other basis representations than DCT?
This is something we'd *love* to try. The DCT looks quite ugly when you increase the number of components, probably because
the shape of the basis functions becomes too visible. Using a different basis with more aesthetically pleasing shape might be
a big win.
However, we have not managed come up with one. Some experimenting with a [Fourier-Bessel base](https://en.wikipedia.org/wiki/FourierBessel_series),
targeted at images that are going to be cropped into circles has been done, but without much success. Here again we'd love
to see what you can come up with!
## Authors
* [Dag Ågren](https://github.com/DagAgren) - Original algorithm design, Swift and C implementations
* [Mykhailo Shchurov](https://github.com/shchurov) - Kotlin decoder implementation
* [Hang Duy Khiem](https://github.com/hangduykhiem) - Android demo app
* [Olli Mahlamäki](https://github.com/omahlama) - TypeScript decoder and encoder implementations
* [Atte Lautanala](https://github.com/lautat) - Python integration
* [Lorenz Diener](https://github.com/halcy) - Pure Python implementation
* [Boris Momčilović](https://github.com/kornrunner) - Pure PHP implementation
* [Hendrik Schnepel](https://github.com/hsch) - Java encoder implementation
* [Tuomo Virolainen](https://github.com/tvirolai) - Clojure implementation
* [Fotis Papadogeorgopoulos](https://github.com/fpapado) - Rust and WebAssembly implementation
* _Your name here?_
## License
All of these implemenations are licensed under the MIT license:
Copyright (c) 2018 Wolt Enterprises
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,957 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
1B0A250F1EC5E90C00F25F08 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0A250E1EC5E90C00F25F08 /* AppDelegate.swift */; };
1B0A25111EC5E90C00F25F08 /* SimpleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B0A25101EC5E90C00F25F08 /* SimpleViewController.swift */; };
1B0A25141EC5E90C00F25F08 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25121EC5E90C00F25F08 /* Main.storyboard */; };
1B0A25161EC5E90C00F25F08 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25151EC5E90C00F25F08 /* Assets.xcassets */; };
1B0A25191EC5E90C00F25F08 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25171EC5E90C00F25F08 /* LaunchScreen.storyboard */; };
1B0A251E1EC5EA0500F25F08 /* BlurHashKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */; };
1B0A251F1EC5EA0500F25F08 /* BlurHashKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1B0A25291EC5EAB000F25F08 /* pic1.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25241EC5EAB000F25F08 /* pic1.png */; };
1B0A252A1EC5EAB000F25F08 /* pic2.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25251EC5EAB000F25F08 /* pic2.png */; };
1B0A252B1EC5EAB000F25F08 /* pic3.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25261EC5EAB000F25F08 /* pic3.png */; };
1B0A252C1EC5EAB000F25F08 /* pic4.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25271EC5EAB000F25F08 /* pic4.png */; };
1B0A252D1EC5EAB000F25F08 /* pic5.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B0A25281EC5EAB000F25F08 /* pic5.png */; };
1B19DF602015E72C00D8FCD7 /* pic6.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B19DF5F2015E72B00D8FCD7 /* pic6.png */; };
1B2BA1CA1F0E5EE3006057C1 /* encode.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B2BA1C81F0E5EE3006057C1 /* encode.c */; };
1B2BA1CB1F0E5EEA006057C1 /* blurhash_stb.c in Sources */ = {isa = PBXBuildFile; fileRef = 1B2BA1C41F0E5ED6006057C1 /* blurhash_stb.c */; };
1B6C71FD2272453D000D3BB1 /* BlurHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */; };
1B6C71FE2272453D000D3BB1 /* FromString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60741FF40AF200E42DD7 /* FromString.swift */; };
1B6C71FF2272453D000D3BB1 /* ToString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60721FF40AEA00E42DD7 /* ToString.swift */; };
1B6C72002272453D000D3BB1 /* FromUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */; };
1B6C72012272453D000D3BB1 /* ToUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */; };
1B6C72022272453D000D3BB1 /* Generation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7F20098E2F00A17481 /* Generation.swift */; };
1B6C72032272453D000D3BB1 /* TupleMaths.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7D20098E1500A17481 /* TupleMaths.swift */; };
1B6C72042272453D000D3BB1 /* ColourSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */; };
1B6C72052272453D000D3BB1 /* StringCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */; };
1B6C72062272453D000D3BB1 /* ColourProbes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BDE56D02011EC5F00569DCB /* ColourProbes.swift */; };
1B83DED122D88D1500CAA12F /* EscapeSequences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B83DED022D88D1500CAA12F /* EscapeSequences.swift */; };
1B83DED222D88D1500CAA12F /* EscapeSequences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B83DED022D88D1500CAA12F /* EscapeSequences.swift */; };
1BAA606D1FF40A0800E42DD7 /* BlurHashEncode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B49CD261EC47243006F8E7D /* BlurHashEncode.swift */; };
1BAA606E1FF40A0B00E42DD7 /* BlurHashDecode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1B49CD281EC4724C006F8E7D /* BlurHashDecode.swift */; };
1BAA60711FF40A2F00E42DD7 /* BlurHash.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */; };
1BAA60731FF40AEA00E42DD7 /* ToString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60721FF40AEA00E42DD7 /* ToString.swift */; };
1BAA60751FF40AF200E42DD7 /* FromString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60741FF40AF200E42DD7 /* FromString.swift */; };
1BAA60771FF40C4C00E42DD7 /* ToUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */; };
1BAA60791FF40C5800E42DD7 /* FromUIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */; };
1BAA607B1FF40D8900E42DD7 /* StringCoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */; };
1BAA607D1FF422AE00E42DD7 /* ColourSpace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */; };
1BC34D7A2005818D00A17481 /* AdvancedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D792005818D00A17481 /* AdvancedViewController.swift */; };
1BC34D7C200988ED00A17481 /* GeneratedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7B200988ED00A17481 /* GeneratedViewController.swift */; };
1BC34D7E20098E1500A17481 /* TupleMaths.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7D20098E1500A17481 /* TupleMaths.swift */; };
1BC34D8020098E2F00A17481 /* Generation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BC34D7F20098E2F00A17481 /* Generation.swift */; };
1BDE56D12011EC5F00569DCB /* ColourProbes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BDE56D02011EC5F00569DCB /* ColourProbes.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
1B0A25201EC5EA0500F25F08 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 1B49CD121EC4721A006F8E7D /* Project object */;
proxyType = 1;
remoteGlobalIDString = 1B49CD1A1EC4721A006F8E7D;
remoteInfo = BlurHash;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
1B0A25221EC5EA0500F25F08 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
1B0A251F1EC5EA0500F25F08 /* BlurHashKit.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
1B2BA1BB1F0E5EC5006057C1 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
1B6C71F42272451E000D3BB1 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1B0A250C1EC5E90C00F25F08 /* BlurHashTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BlurHashTest.app; sourceTree = BUILT_PRODUCTS_DIR; };
1B0A250E1EC5E90C00F25F08 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1B0A25101EC5E90C00F25F08 /* SimpleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleViewController.swift; sourceTree = "<group>"; };
1B0A25131EC5E90C00F25F08 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
1B0A25151EC5E90C00F25F08 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
1B0A25181EC5E90C00F25F08 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
1B0A251A1EC5E90C00F25F08 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1B0A25241EC5EAB000F25F08 /* pic1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic1.png; sourceTree = "<group>"; };
1B0A25251EC5EAB000F25F08 /* pic2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic2.png; sourceTree = "<group>"; };
1B0A25261EC5EAB000F25F08 /* pic3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic3.png; sourceTree = "<group>"; };
1B0A25271EC5EAB000F25F08 /* pic4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic4.png; sourceTree = "<group>"; };
1B0A25281EC5EAB000F25F08 /* pic5.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic5.png; sourceTree = "<group>"; };
1B19DF5F2015E72B00D8FCD7 /* pic6.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic6.png; sourceTree = "<group>"; };
1B1B249320C13E9700D8EF03 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
1B1B249420C13E9700D8EF03 /* dev-requirements.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = "dev-requirements.txt"; sourceTree = "<group>"; };
1B1B249620C13E9700D8EF03 /* pic2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic2.png; sourceTree = "<group>"; };
1B1B249720C13E9700D8EF03 /* pic2_bw.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pic2_bw.png; sourceTree = "<group>"; };
1B1B249820C13E9700D8EF03 /* test_encode.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = test_encode.py; sourceTree = "<group>"; };
1B1B249920C13E9700D8EF03 /* MANIFEST.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = MANIFEST.in; sourceTree = "<group>"; };
1B1B249A20C13E9700D8EF03 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
1B1B249B20C13E9700D8EF03 /* setup.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = setup.py; sourceTree = "<group>"; };
1B1B249D20C13E9700D8EF03 /* tox.ini */ = {isa = PBXFileReference; lastKnownFileType = text; path = tox.ini; sourceTree = "<group>"; };
1B1B249E20C13E9700D8EF03 /* setup.cfg */ = {isa = PBXFileReference; lastKnownFileType = text; path = setup.cfg; sourceTree = "<group>"; };
1B1B24FF20C13E9700D8EF03 /* config.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = config.yml; sourceTree = "<group>"; };
1B1B250220C13E9700D8EF03 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
1B1B250320C13E9700D8EF03 /* encode.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = encode.c; sourceTree = "<group>"; };
1B1B250420C13E9700D8EF03 /* build_blurhash.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = build_blurhash.py; sourceTree = "<group>"; };
1B1B250520C13E9700D8EF03 /* encode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = encode.h; sourceTree = "<group>"; };
1B1B250620C1491900D8EF03 /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = "<group>"; };
1B2BA1BD1F0E5EC5006057C1 /* blurhash */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = blurhash; sourceTree = BUILT_PRODUCTS_DIR; };
1B2BA1C41F0E5ED6006057C1 /* blurhash_stb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blurhash_stb.c; sourceTree = "<group>"; };
1B2BA1C81F0E5EE3006057C1 /* encode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = encode.c; sourceTree = "<group>"; };
1B2BA1C91F0E5EE3006057C1 /* encode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = encode.h; sourceTree = "<group>"; };
1B2BA1CC1F0E692F006057C1 /* stb_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_image.h; sourceTree = "<group>"; };
1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BlurHashKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
1B49CD1F1EC4721A006F8E7D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
1B49CD261EC47243006F8E7D /* BlurHashEncode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurHashEncode.swift; sourceTree = "<group>"; };
1B49CD281EC4724C006F8E7D /* BlurHashDecode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = "<group>"; };
1B6C71F122724500000D3BB1 /* 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>"; };
1B6C71F62272451E000D3BB1 /* libBlurHashKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBlurHashKit.a; sourceTree = BUILT_PRODUCTS_DIR; };
1B83DED022D88D1500CAA12F /* EscapeSequences.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EscapeSequences.swift; sourceTree = "<group>"; };
1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurHash.swift; sourceTree = "<group>"; };
1BAA60721FF40AEA00E42DD7 /* ToString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToString.swift; sourceTree = "<group>"; };
1BAA60741FF40AF200E42DD7 /* FromString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FromString.swift; sourceTree = "<group>"; };
1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToUIImage.swift; sourceTree = "<group>"; };
1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FromUIImage.swift; sourceTree = "<group>"; };
1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringCoding.swift; sourceTree = "<group>"; };
1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColourSpace.swift; sourceTree = "<group>"; };
1BC34D792005818D00A17481 /* AdvancedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdvancedViewController.swift; sourceTree = "<group>"; };
1BC34D7B200988ED00A17481 /* GeneratedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedViewController.swift; sourceTree = "<group>"; };
1BC34D7D20098E1500A17481 /* TupleMaths.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TupleMaths.swift; sourceTree = "<group>"; };
1BC34D7F20098E2F00A17481 /* Generation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Generation.swift; sourceTree = "<group>"; };
1BDE56D02011EC5F00569DCB /* ColourProbes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColourProbes.swift; sourceTree = "<group>"; };
1BEFFFA720BEE66400187F3F /* index.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; };
1BEFFFB520BEE66400187F3F /* webpack.config.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = webpack.config.js; sourceTree = "<group>"; };
1BEFFFB720BEE66400187F3F /* package.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = package.json; sourceTree = "<group>"; };
1BEFFFB820BEE66400187F3F /* tsconfig.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = tsconfig.json; sourceTree = "<group>"; };
1BEFFFBA20BEE66400187F3F /* decode.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = decode.ts; sourceTree = "<group>"; };
1BEFFFBB20BEE66400187F3F /* demo.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = demo.ts; sourceTree = "<group>"; };
1BEFFFBC20BEE66400187F3F /* utils.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = utils.ts; sourceTree = "<group>"; };
1BEFFFBD20BEE66400187F3F /* index.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = index.ts; sourceTree = "<group>"; };
1BEFFFBE20BEE66400187F3F /* base83.ts */ = {isa = PBXFileReference; explicitFileType = sourcecode.javascript; path = base83.ts; sourceTree = "<group>"; };
1BEFFFBF20BFDC1600187F3F /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
1BEFFFC120BFE05600187F3F /* BlurHashDecoder.kt */ = {isa = PBXFileReference; lastKnownFileType = text; path = BlurHashDecoder.kt; sourceTree = "<group>"; };
1BEFFFC220BFE33E00187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = "<group>"; };
1BEFFFC320BFE34800187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = Readme.md; path = ../Readme.md; sourceTree = "<group>"; };
1BEFFFC420BFE35300187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = "<group>"; };
1BEFFFC520BFE35D00187F3F /* Readme.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Readme.md; sourceTree = "<group>"; };
1BEFFFC620BFF7B100187F3F /* Algorithm.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = Algorithm.md; path = ../Algorithm.md; sourceTree = "<group>"; };
1BEFFFC720BFF7B100187F3F /* CodeOfConduct.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = CodeOfConduct.md; path = ../CodeOfConduct.md; sourceTree = "<group>"; };
1BEFFFC820C000DE00187F3F /* License.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = License.txt; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
1B0A25091EC5E90C00F25F08 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1B0A251E1EC5EA0500F25F08 /* BlurHashKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1B2BA1BA1F0E5EC5006057C1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
1B49CD171EC4721A006F8E7D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
1B6C71F32272451E000D3BB1 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
1B0A250D1EC5E90C00F25F08 /* BlurHashTest */ = {
isa = PBXGroup;
children = (
1B0A25231EC5EAA300F25F08 /* Images */,
1B0A250E1EC5E90C00F25F08 /* AppDelegate.swift */,
1B0A25101EC5E90C00F25F08 /* SimpleViewController.swift */,
1BC34D792005818D00A17481 /* AdvancedViewController.swift */,
1BC34D7B200988ED00A17481 /* GeneratedViewController.swift */,
1B0A25121EC5E90C00F25F08 /* Main.storyboard */,
1B0A25151EC5E90C00F25F08 /* Assets.xcassets */,
1B0A25171EC5E90C00F25F08 /* LaunchScreen.storyboard */,
1B0A251A1EC5E90C00F25F08 /* Info.plist */,
);
path = BlurHashTest;
sourceTree = "<group>";
};
1B0A25231EC5EAA300F25F08 /* Images */ = {
isa = PBXGroup;
children = (
1B0A25241EC5EAB000F25F08 /* pic1.png */,
1B0A25251EC5EAB000F25F08 /* pic2.png */,
1B0A25261EC5EAB000F25F08 /* pic3.png */,
1B0A25271EC5EAB000F25F08 /* pic4.png */,
1B0A25281EC5EAB000F25F08 /* pic5.png */,
1B19DF5F2015E72B00D8FCD7 /* pic6.png */,
);
name = Images;
sourceTree = "<group>";
};
1B1B249220C13E9700D8EF03 /* Python */ = {
isa = PBXGroup;
children = (
1B1B250020C13E9700D8EF03 /* src */,
1B1B249520C13E9700D8EF03 /* tests */,
1B1B24FE20C13E9700D8EF03 /* .circleci */,
1B1B249420C13E9700D8EF03 /* dev-requirements.txt */,
1B1B249320C13E9700D8EF03 /* LICENSE */,
1B1B249920C13E9700D8EF03 /* MANIFEST.in */,
1B1B249A20C13E9700D8EF03 /* README.md */,
1B1B249E20C13E9700D8EF03 /* setup.cfg */,
1B1B249B20C13E9700D8EF03 /* setup.py */,
1B1B249D20C13E9700D8EF03 /* tox.ini */,
);
name = Python;
path = ../Python;
sourceTree = "<group>";
};
1B1B249520C13E9700D8EF03 /* tests */ = {
isa = PBXGroup;
children = (
1B1B249620C13E9700D8EF03 /* pic2.png */,
1B1B249720C13E9700D8EF03 /* pic2_bw.png */,
1B1B249820C13E9700D8EF03 /* test_encode.py */,
);
path = tests;
sourceTree = "<group>";
};
1B1B24FE20C13E9700D8EF03 /* .circleci */ = {
isa = PBXGroup;
children = (
1B1B24FF20C13E9700D8EF03 /* config.yml */,
);
path = .circleci;
sourceTree = "<group>";
};
1B1B250020C13E9700D8EF03 /* src */ = {
isa = PBXGroup;
children = (
1B1B250120C13E9700D8EF03 /* blurhash */,
1B1B250420C13E9700D8EF03 /* build_blurhash.py */,
1B1B250320C13E9700D8EF03 /* encode.c */,
1B1B250520C13E9700D8EF03 /* encode.h */,
);
path = src;
sourceTree = "<group>";
};
1B1B250120C13E9700D8EF03 /* blurhash */ = {
isa = PBXGroup;
children = (
1B1B250220C13E9700D8EF03 /* __init__.py */,
);
path = blurhash;
sourceTree = "<group>";
};
1B2BA1B81F0E5E91006057C1 /* C */ = {
isa = PBXGroup;
children = (
1B2BA1C41F0E5ED6006057C1 /* blurhash_stb.c */,
1B2BA1C81F0E5EE3006057C1 /* encode.c */,
1B2BA1C91F0E5EE3006057C1 /* encode.h */,
1B2BA1CC1F0E692F006057C1 /* stb_image.h */,
1BEFFFBF20BFDC1600187F3F /* Makefile */,
1B1B250620C1491900D8EF03 /* Readme.md */,
);
name = C;
path = ../C;
sourceTree = "<group>";
};
1B49CD111EC4721A006F8E7D = {
isa = PBXGroup;
children = (
1B49CD1D1EC4721A006F8E7D /* Swift */,
1B2BA1B81F0E5E91006057C1 /* C */,
1BEFFFC020BFE05600187F3F /* Kotlin */,
1BEFFFA420BEE66400187F3F /* TypeScript */,
1B1B249220C13E9700D8EF03 /* Python */,
1BEFFFC620BFF7B100187F3F /* Algorithm.md */,
1BEFFFC720BFF7B100187F3F /* CodeOfConduct.md */,
1BEFFFC820C000DE00187F3F /* License.txt */,
1BEFFFC320BFE34800187F3F /* Readme.md */,
1B49CD1C1EC4721A006F8E7D /* Products */,
1B6C71F122724500000D3BB1 /* BlurHashKit copy-Info.plist */,
);
sourceTree = "<group>";
};
1B49CD1C1EC4721A006F8E7D /* Products */ = {
isa = PBXGroup;
children = (
1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */,
1B0A250C1EC5E90C00F25F08 /* BlurHashTest.app */,
1B2BA1BD1F0E5EC5006057C1 /* blurhash */,
1B6C71F62272451E000D3BB1 /* libBlurHashKit.a */,
);
name = Products;
sourceTree = "<group>";
};
1B49CD1D1EC4721A006F8E7D /* Swift */ = {
isa = PBXGroup;
children = (
1B0A250D1EC5E90C00F25F08 /* BlurHashTest */,
1BAA606F1FF40A1E00E42DD7 /* BlurHashKit */,
1B49CD261EC47243006F8E7D /* BlurHashEncode.swift */,
1B49CD281EC4724C006F8E7D /* BlurHashDecode.swift */,
1BEFFFC420BFE35300187F3F /* Readme.md */,
);
name = Swift;
sourceTree = "<group>";
};
1BAA606F1FF40A1E00E42DD7 /* BlurHashKit */ = {
isa = PBXGroup;
children = (
1BAA60701FF40A2F00E42DD7 /* BlurHash.swift */,
1B83DED022D88D1500CAA12F /* EscapeSequences.swift */,
1BAA60741FF40AF200E42DD7 /* FromString.swift */,
1BAA60721FF40AEA00E42DD7 /* ToString.swift */,
1BAA60781FF40C5800E42DD7 /* FromUIImage.swift */,
1BAA60761FF40C4C00E42DD7 /* ToUIImage.swift */,
1BC34D7F20098E2F00A17481 /* Generation.swift */,
1BC34D7D20098E1500A17481 /* TupleMaths.swift */,
1BAA607C1FF422AE00E42DD7 /* ColourSpace.swift */,
1BAA607A1FF40D8900E42DD7 /* StringCoding.swift */,
1BDE56D02011EC5F00569DCB /* ColourProbes.swift */,
1B49CD1F1EC4721A006F8E7D /* Info.plist */,
);
path = BlurHashKit;
sourceTree = "<group>";
};
1BEFFFA420BEE66400187F3F /* TypeScript */ = {
isa = PBXGroup;
children = (
1BEFFFA620BEE66400187F3F /* demo */,
1BEFFFB920BEE66400187F3F /* src */,
1BEFFFB520BEE66400187F3F /* webpack.config.js */,
1BEFFFB720BEE66400187F3F /* package.json */,
1BEFFFB820BEE66400187F3F /* tsconfig.json */,
1BEFFFC520BFE35D00187F3F /* Readme.md */,
);
name = TypeScript;
path = ../TypeScript;
sourceTree = "<group>";
};
1BEFFFA620BEE66400187F3F /* demo */ = {
isa = PBXGroup;
children = (
1BEFFFA720BEE66400187F3F /* index.html */,
);
path = demo;
sourceTree = "<group>";
};
1BEFFFB920BEE66400187F3F /* src */ = {
isa = PBXGroup;
children = (
1BEFFFBA20BEE66400187F3F /* decode.ts */,
1BEFFFBB20BEE66400187F3F /* demo.ts */,
1BEFFFBC20BEE66400187F3F /* utils.ts */,
1BEFFFBD20BEE66400187F3F /* index.ts */,
1BEFFFBE20BEE66400187F3F /* base83.ts */,
);
path = src;
sourceTree = "<group>";
};
1BEFFFC020BFE05600187F3F /* Kotlin */ = {
isa = PBXGroup;
children = (
1BEFFFC120BFE05600187F3F /* BlurHashDecoder.kt */,
1BEFFFC220BFE33E00187F3F /* Readme.md */,
);
name = Kotlin;
path = ../Kotlin;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
1B49CD181EC4721A006F8E7D /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
1B0A250B1EC5E90C00F25F08 /* BlurHashTest */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1B0A251D1EC5E90C00F25F08 /* Build configuration list for PBXNativeTarget "BlurHashTest" */;
buildPhases = (
1B0A25081EC5E90C00F25F08 /* Sources */,
1B0A25091EC5E90C00F25F08 /* Frameworks */,
1B0A250A1EC5E90C00F25F08 /* Resources */,
1B0A25221EC5EA0500F25F08 /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
1B0A25211EC5EA0500F25F08 /* PBXTargetDependency */,
);
name = BlurHashTest;
productName = BlurHashTest;
productReference = 1B0A250C1EC5E90C00F25F08 /* BlurHashTest.app */;
productType = "com.apple.product-type.application";
};
1B2BA1BC1F0E5EC5006057C1 /* blurhash */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1B2BA1C11F0E5EC6006057C1 /* Build configuration list for PBXNativeTarget "blurhash" */;
buildPhases = (
1B2BA1B91F0E5EC5006057C1 /* Sources */,
1B2BA1BA1F0E5EC5006057C1 /* Frameworks */,
1B2BA1BB1F0E5EC5006057C1 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = blurhash;
productName = blurhash;
productReference = 1B2BA1BD1F0E5EC5006057C1 /* blurhash */;
productType = "com.apple.product-type.tool";
};
1B49CD1A1EC4721A006F8E7D /* BlurHashKit */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1B49CD231EC4721A006F8E7D /* Build configuration list for PBXNativeTarget "BlurHashKit" */;
buildPhases = (
1B49CD161EC4721A006F8E7D /* Sources */,
1B49CD171EC4721A006F8E7D /* Frameworks */,
1B49CD181EC4721A006F8E7D /* Headers */,
1B49CD191EC4721A006F8E7D /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = BlurHashKit;
productName = Blurhash;
productReference = 1B49CD1B1EC4721A006F8E7D /* BlurHashKit.framework */;
productType = "com.apple.product-type.framework";
};
1B6C71F52272451E000D3BB1 /* libBlurHashKit */ = {
isa = PBXNativeTarget;
buildConfigurationList = 1B6C71FA2272451E000D3BB1 /* Build configuration list for PBXNativeTarget "libBlurHashKit" */;
buildPhases = (
1B6C71F22272451E000D3BB1 /* Sources */,
1B6C71F32272451E000D3BB1 /* Frameworks */,
1B6C71F42272451E000D3BB1 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = libBlurHashKit;
productName = libBlurHash;
productReference = 1B6C71F62272451E000D3BB1 /* libBlurHashKit.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
1B49CD121EC4721A006F8E7D /* Project object */ = {
isa = PBXProject;
attributes = {
DefaultBuildSystemTypeForWorkspace = Latest;
LastSwiftUpdateCheck = 1020;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Dag Ågren";
TargetAttributes = {
1B0A250B1EC5E90C00F25F08 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 6GE6LAAR8V;
LastSwiftMigration = 0920;
ProvisioningStyle = Automatic;
};
1B2BA1BC1F0E5EC5006057C1 = {
CreatedOnToolsVersion = 8.3.3;
DevelopmentTeam = 6GE6LAAR8V;
ProvisioningStyle = Automatic;
};
1B49CD1A1EC4721A006F8E7D = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 6GE6LAAR8V;
LastSwiftMigration = 0920;
ProvisioningStyle = Automatic;
};
1B6C71F52272451E000D3BB1 = {
CreatedOnToolsVersion = 10.2;
DevelopmentTeam = M9KXCWYWYR;
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = 1B49CD151EC4721A006F8E7D /* Build configuration list for PBXProject "BlurHash" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
mainGroup = 1B49CD111EC4721A006F8E7D;
productRefGroup = 1B49CD1C1EC4721A006F8E7D /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
1B49CD1A1EC4721A006F8E7D /* BlurHashKit */,
1B6C71F52272451E000D3BB1 /* libBlurHashKit */,
1B0A250B1EC5E90C00F25F08 /* BlurHashTest */,
1B2BA1BC1F0E5EC5006057C1 /* blurhash */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
1B0A250A1EC5E90C00F25F08 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1B0A25291EC5EAB000F25F08 /* pic1.png in Resources */,
1B0A252A1EC5EAB000F25F08 /* pic2.png in Resources */,
1B0A252B1EC5EAB000F25F08 /* pic3.png in Resources */,
1B0A252C1EC5EAB000F25F08 /* pic4.png in Resources */,
1B19DF602015E72C00D8FCD7 /* pic6.png in Resources */,
1B0A252D1EC5EAB000F25F08 /* pic5.png in Resources */,
1B0A25191EC5E90C00F25F08 /* LaunchScreen.storyboard in Resources */,
1B0A25161EC5E90C00F25F08 /* Assets.xcassets in Resources */,
1B0A25141EC5E90C00F25F08 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1B49CD191EC4721A006F8E7D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
1B0A25081EC5E90C00F25F08 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1BAA606E1FF40A0B00E42DD7 /* BlurHashDecode.swift in Sources */,
1BC34D7A2005818D00A17481 /* AdvancedViewController.swift in Sources */,
1B0A25111EC5E90C00F25F08 /* SimpleViewController.swift in Sources */,
1BAA606D1FF40A0800E42DD7 /* BlurHashEncode.swift in Sources */,
1BC34D7C200988ED00A17481 /* GeneratedViewController.swift in Sources */,
1B0A250F1EC5E90C00F25F08 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1B2BA1B91F0E5EC5006057C1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1B2BA1CB1F0E5EEA006057C1 /* blurhash_stb.c in Sources */,
1B2BA1CA1F0E5EE3006057C1 /* encode.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1B49CD161EC4721A006F8E7D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1BAA60711FF40A2F00E42DD7 /* BlurHash.swift in Sources */,
1BAA607D1FF422AE00E42DD7 /* ColourSpace.swift in Sources */,
1BC34D7E20098E1500A17481 /* TupleMaths.swift in Sources */,
1BAA60751FF40AF200E42DD7 /* FromString.swift in Sources */,
1BAA607B1FF40D8900E42DD7 /* StringCoding.swift in Sources */,
1BAA60771FF40C4C00E42DD7 /* ToUIImage.swift in Sources */,
1B83DED122D88D1500CAA12F /* EscapeSequences.swift in Sources */,
1BAA60731FF40AEA00E42DD7 /* ToString.swift in Sources */,
1BC34D8020098E2F00A17481 /* Generation.swift in Sources */,
1BDE56D12011EC5F00569DCB /* ColourProbes.swift in Sources */,
1BAA60791FF40C5800E42DD7 /* FromUIImage.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1B6C71F22272451E000D3BB1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1B6C71FE2272453D000D3BB1 /* FromString.swift in Sources */,
1B6C72022272453D000D3BB1 /* Generation.swift in Sources */,
1B6C72032272453D000D3BB1 /* TupleMaths.swift in Sources */,
1B6C72002272453D000D3BB1 /* FromUIImage.swift in Sources */,
1B6C72042272453D000D3BB1 /* ColourSpace.swift in Sources */,
1B6C72052272453D000D3BB1 /* StringCoding.swift in Sources */,
1B83DED222D88D1500CAA12F /* EscapeSequences.swift in Sources */,
1B6C71FF2272453D000D3BB1 /* ToString.swift in Sources */,
1B6C71FD2272453D000D3BB1 /* BlurHash.swift in Sources */,
1B6C72062272453D000D3BB1 /* ColourProbes.swift in Sources */,
1B6C72012272453D000D3BB1 /* ToUIImage.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
1B0A25211EC5EA0500F25F08 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 1B49CD1A1EC4721A006F8E7D /* BlurHashKit */;
targetProxy = 1B0A25201EC5EA0500F25F08 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin PBXVariantGroup section */
1B0A25121EC5E90C00F25F08 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
1B0A25131EC5E90C00F25F08 /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
1B0A25171EC5E90C00F25F08 /* LaunchScreen.storyboard */ = {
isa = PBXVariantGroup;
children = (
1B0A25181EC5E90C00F25F08 /* Base */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
1B0A251B1EC5E90C00F25F08 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 6GE6LAAR8V;
INFOPLIST_FILE = BlurHashTest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashTest;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
1B0A251C1EC5E90C00F25F08 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 6GE6LAAR8V;
INFOPLIST_FILE = BlurHashTest/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashTest;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
};
name = Release;
};
1B2BA1C21F0E5EC6006057C1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "-";
DEVELOPMENT_TEAM = 6GE6LAAR8V;
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
name = Debug;
};
1B2BA1C31F0E5EC6006057C1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "-";
DEVELOPMENT_TEAM = 6GE6LAAR8V;
MACOSX_DEPLOYMENT_TARGET = 10.12;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
name = Release;
};
1B49CD211EC4721A006F8E7D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
1B49CD221EC4721A006F8E7D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
1B49CD241EC4721A006F8E7D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 6GE6LAAR8V;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = BlurHashKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
};
name = Debug;
};
1B49CD251EC4721A006F8E7D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 6GE6LAAR8V;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = BlurHashKit/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.wolt.BlurHashKit;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
};
name = Release;
};
1B6C71FB2272451E000D3BB1 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = M9KXCWYWYR;
GCC_C_LANGUAGE_STANDARD = gnu11;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = BlurHashKit;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
1B6C71FC2272451E000D3BB1 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = M9KXCWYWYR;
GCC_C_LANGUAGE_STANDARD = gnu11;
MTL_FAST_MATH = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = BlurHashKit;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
1B0A251D1EC5E90C00F25F08 /* Build configuration list for PBXNativeTarget "BlurHashTest" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1B0A251B1EC5E90C00F25F08 /* Debug */,
1B0A251C1EC5E90C00F25F08 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1B2BA1C11F0E5EC6006057C1 /* Build configuration list for PBXNativeTarget "blurhash" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1B2BA1C21F0E5EC6006057C1 /* Debug */,
1B2BA1C31F0E5EC6006057C1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1B49CD151EC4721A006F8E7D /* Build configuration list for PBXProject "BlurHash" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1B49CD211EC4721A006F8E7D /* Debug */,
1B49CD221EC4721A006F8E7D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1B49CD231EC4721A006F8E7D /* Build configuration list for PBXNativeTarget "BlurHashKit" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1B49CD241EC4721A006F8E7D /* Debug */,
1B49CD251EC4721A006F8E7D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
1B6C71FA2272451E000D3BB1 /* Build configuration list for PBXNativeTarget "libBlurHashKit" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1B6C71FB2272451E000D3BB1 /* Debug */,
1B6C71FC2272451E000D3BB1 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 1B49CD121EC4721A006F8E7D /* Project object */;
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Blurhash.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,28 +0,0 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "8D94AD06B7E57997939C2DBED75F327A184CF7B8",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"8D94AD06B7E57997939C2DBED75F327A184CF7B8" : 9223372036854775807
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "78AF9E08-7F50-4648-8F5B-F7536E5EB55E",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"8D94AD06B7E57997939C2DBED75F327A184CF7B8" : "BlurHash\/"
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "BlurHash",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "BlurHash.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/creditornot\/BlurHash.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8D94AD06B7E57997939C2DBED75F327A184CF7B8"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/creditornot\/BlurHash.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8D94AD06B7E57997939C2DBED75F327A184CF7B8"
}
]
}

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -1,146 +0,0 @@
import UIKit
extension UIImage {
public convenience init?(blurHash: String, size: CGSize, punch: Float = 1) {
guard blurHash.count >= 6 else { return nil }
let sizeFlag = String(blurHash[0]).decode83()
let numY = (sizeFlag / 9) + 1
let numX = (sizeFlag % 9) + 1
let quantisedMaximumValue = String(blurHash[1]).decode83()
let maximumValue = Float(quantisedMaximumValue + 1) / 166
guard blurHash.count == 4 + 2 * numX * numY else { return nil }
let colours: [(Float, Float, Float)] = (0 ..< numX * numY).map { i in
if i == 0 {
let value = String(blurHash[2 ..< 6]).decode83()
return decodeDC(value)
} else {
let value = String(blurHash[4 + i * 2 ..< 4 + i * 2 + 2]).decode83()
return decodeAC(value, maximumValue: maximumValue * punch)
}
}
let width = Int(size.width)
let height = Int(size.height)
let bytesPerRow = width * 3
guard let data = CFDataCreateMutable(kCFAllocatorDefault, bytesPerRow * height) else { return nil }
CFDataSetLength(data, bytesPerRow * height)
guard let pixels = CFDataGetMutableBytePtr(data) else { return nil }
for y in 0 ..< height {
for x in 0 ..< width {
var r: Float = 0
var g: Float = 0
var b: Float = 0
for j in 0 ..< numY {
for i in 0 ..< numX {
let basis = cos(Float.pi * Float(x) * Float(i) / Float(width)) * cos(Float.pi * Float(y) * Float(j) / Float(height))
let colour = colours[i + j * numX]
r += colour.0 * basis
g += colour.1 * basis
b += colour.2 * basis
}
}
let intR = UInt8(linearTosRGB(r))
let intG = UInt8(linearTosRGB(g))
let intB = UInt8(linearTosRGB(b))
pixels[3 * x + 0 + y * bytesPerRow] = intR
pixels[3 * x + 1 + y * bytesPerRow] = intG
pixels[3 * x + 2 + y * bytesPerRow] = intB
}
}
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue)
guard let provider = CGDataProvider(data: data) else { return nil }
guard let cgImage = CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 24, bytesPerRow: bytesPerRow,
space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: bitmapInfo, provider: provider, decode: nil, shouldInterpolate: true, intent: .defaultIntent) else { return nil }
self.init(cgImage: cgImage)
}
}
private func decodeDC(_ value: Int) -> (Float, Float, Float) {
let intR = value >> 16
let intG = (value >> 8) & 255
let intB = value & 255
return (sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB))
}
private func decodeAC(_ value: Int, maximumValue: Float) -> (Float, Float, Float) {
let quantR = value / (19 * 19)
let quantG = (value / 19) % 19
let quantB = value % 19
let rgb = (
signPow((Float(quantR) - 9) / 9, 2) * maximumValue,
signPow((Float(quantG) - 9) / 9, 2) * maximumValue,
signPow((Float(quantB) - 9) / 9, 2) * maximumValue
)
return rgb
}
private func signPow(_ value: Float, _ exp: Float) -> Float {
return copysign(pow(abs(value), exp), value)
}
private func linearTosRGB(_ value: Float) -> Int {
let v = max(0, min(1, value))
if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }
else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }
}
private func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {
let v = Float(Int64(value)) / 255
if v <= 0.04045 { return v / 12.92 }
else { return pow((v + 0.055) / 1.055, 2.4) }
}
private let encodeCharacters: [String] = {
return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~".map { String($0) }
}()
private let decodeCharacters: [String: Int] = {
var dict: [String: Int] = [:]
for (index, character) in encodeCharacters.enumerated() {
dict[character] = index
}
return dict
}()
extension String {
func decode83() -> Int {
var value: Int = 0
for character in self {
if let digit = decodeCharacters[String(character)] {
value = value * 83 + digit
}
}
return value
}
}
private extension String {
subscript (offset: Int) -> Character {
return self[index(startIndex, offsetBy: offset)]
}
subscript (bounds: CountableClosedRange<Int>) -> Substring {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
return self[start...end]
}
subscript (bounds: CountableRange<Int>) -> Substring {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
return self[start..<end]
}
}

View File

@ -1,128 +0,0 @@
import UIKit
extension UIImage {
public func blurHash(numberOfComponents components: (Int, Int)) -> String? {
guard components.0 >= 1, components.0 <= 9,
components.1 >= 1, components.1 <= 9,
cgImage?.colorSpace?.numberOfComponents == 3,
cgImage?.bitsPerPixel == 24 || cgImage?.bitsPerPixel == 32 else { return nil }
guard let cgImage = cgImage,
let dataProvider = cgImage.dataProvider,
let data = dataProvider.data,
let pixels = CFDataGetBytePtr(data) else { return nil }
let width = cgImage.width
let height = cgImage.height
let bytesPerRow = cgImage.bytesPerRow
var factors: [(Float, Float, Float)] = []
for y in 0 ..< components.1 {
for x in 0 ..< components.0 {
let normalisation: Float = (x == 0 && y == 0) ? 1 : 2
let factor = multiplyBasisFunction(pixels: pixels, width: width, height: height, bytesPerRow: bytesPerRow, bytesPerPixel: cgImage.bitsPerPixel / 8, pixelOffset: 0) {
normalisation * cos(Float.pi * Float(x) * $0 / Float(width)) * cos(Float.pi * Float(y) * $1 / Float(height))
}
factors.append(factor)
}
}
let dc = factors.first!
let ac = factors.dropFirst()
var hash = ""
let sizeFlag = (components.0 - 1) + (components.1 - 1) * 9
hash += sizeFlag.encode83(length: 1)
let maximumValue: Float
if ac.count > 0 {
let actualMaximumValue = ac.map({ max(abs($0.0), abs($0.1), abs($0.2)) }).max()!
let quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5))))
maximumValue = Float(quantisedMaximumValue + 1) / 166
hash += quantisedMaximumValue.encode83(length: 1)
} else {
maximumValue = 1
hash += 0.encode83(length: 1)
}
hash += encodeDC(dc).encode83(length: 4)
for factor in ac {
hash += encodeAC(factor, maximumValue: maximumValue).encode83(length: 2)
}
return hash
}
private func multiplyBasisFunction(pixels: UnsafePointer<UInt8>, width: Int, height: Int, bytesPerRow: Int, bytesPerPixel: Int, pixelOffset: Int, basisFunction: (Float, Float) -> Float) -> (Float, Float, Float) {
var r: Float = 0
var g: Float = 0
var b: Float = 0
let buffer = UnsafeBufferPointer(start: pixels, count: height * bytesPerRow)
for x in 0 ..< width {
for y in 0 ..< height {
let basis = basisFunction(Float(x), Float(y))
r += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 0 + y * bytesPerRow])
g += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 1 + y * bytesPerRow])
b += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 2 + y * bytesPerRow])
}
}
let scale = 1 / Float(width * height)
return (r * scale, g * scale, b * scale)
}
}
private func encodeDC(_ value: (Float, Float, Float)) -> Int {
let roundedR = linearTosRGB(value.0)
let roundedG = linearTosRGB(value.1)
let roundedB = linearTosRGB(value.2)
return (roundedR << 16) + (roundedG << 8) + roundedB
}
private func encodeAC(_ value: (Float, Float, Float), maximumValue: Float) -> Int {
let quantR = Int(max(0, min(18, floor(signPow(value.0 / maximumValue, 0.5) * 9 + 9.5))))
let quantG = Int(max(0, min(18, floor(signPow(value.1 / maximumValue, 0.5) * 9 + 9.5))))
let quantB = Int(max(0, min(18, floor(signPow(value.2 / maximumValue, 0.5) * 9 + 9.5))))
return quantR * 19 * 19 + quantG * 19 + quantB
}
private func signPow(_ value: Float, _ exp: Float) -> Float {
return copysign(pow(abs(value), exp), value)
}
private func linearTosRGB(_ value: Float) -> Int {
let v = max(0, min(1, value))
if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }
else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }
}
private func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {
let v = Float(Int64(value)) / 255
if v <= 0.04045 { return v / 12.92 }
else { return pow((v + 0.055) / 1.055, 2.4) }
}
private let encodeCharacters: [String] = {
return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~".map { String($0) }
}()
extension BinaryInteger {
func encode83(length: Int) -> String {
var result = ""
for i in 1 ... length {
let digit = (Int(self) / pow(83, length - i)) % 83
result += encodeCharacters[Int(digit)]
}
return result
}
}
private func pow(_ base: Int, _ exponent: Int) -> Int {
return (0 ..< exponent).reduce(1) { value, _ in value * base }
}

View File

@ -1,46 +0,0 @@
import Foundation
public struct BlurHash {
public let components: [[(Float, Float, Float)]]
public var numberOfHorizontalComponents: Int { return components.first!.count }
public var numberOfVerticalComponents: Int { return components.count }
public func punch(_ factor: Float) -> BlurHash {
return BlurHash(components: components.enumerated().map { (y, xComponents) in
return xComponents.enumerated().map { (x, component) in
if x == 0 && y == 0 {
return component
} else {
return (component.0 * factor, component.1 * factor, component.2 * factor)
}
}
})
}
}
public func +(lhs: BlurHash, rhs: BlurHash) throws -> BlurHash {
return BlurHash(components: paddedZip(lhs.components, rhs.components, [], []).map {
paddedZip($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) }
})
}
public func -(lhs: BlurHash, rhs: BlurHash) throws -> BlurHash {
return BlurHash(components: paddedZip(lhs.components, rhs.components, [], []).map {
paddedZip($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) }
})
}
private func paddedZip<Collection1, Collection2>(_ collection1: Collection1, _ collection2: Collection2, _ padding1: Collection1.Element, _ padding2: Collection2.Element) -> Zip2Sequence<[Collection1.Element], [Collection2.Element]> where Collection1: Collection, Collection2: Collection {
if collection1.count < collection2.count {
let padded = collection1 + Array(repeating: padding1, count: collection2.count - collection1.count)
return zip(padded, Array(collection2))
} else if collection2.count < collection1.count {
let padded = collection2 + Array(repeating: padding2, count: collection1.count - collection2.count)
return zip(Array(collection1), padded)
} else {
return zip(Array(collection1), Array(collection2))
}
}

View File

@ -1,79 +0,0 @@
import Foundation
extension BlurHash {
public func linearRgb(atX: Float) -> (Float, Float, Float) {
return components[0].enumerated().reduce((0, 0, 0)) { (sum, xEnumerated) in
let (x, component) = xEnumerated
return sum + component * cos(Float.pi * Float(x) * atX)
}
}
public func linearRgb(atY: Float) -> (Float, Float, Float) {
return components.enumerated().reduce((0, 0, 0)) { (sum, yEnumerated) in
let (y, xComponents) = yEnumerated
return sum + xComponents[0] * cos(Float.pi * Float(y) * atY)
}
}
public func linearRgb(at position: (Float, Float)) -> (Float, Float, Float) {
return components.enumerated().reduce((0, 0, 0)) { (sum, yEnumerated) in
let (y, xComponents) = yEnumerated
return xComponents.enumerated().reduce(sum) { (sum, xEnumerated) in
let (x, component) = xEnumerated
return sum + component * cos(Float.pi * Float(x) * position.0) * cos(Float.pi * Float(y) * position.1)
}
}
}
public func linearRgb(from upperLeft: (Float, Float), to lowerRight: (Float, Float)) -> (Float, Float, Float) {
return components.enumerated().reduce((0, 0, 0)) { (sum, yEnumerated) in
let (y, xComponents) = yEnumerated
return xComponents.enumerated().reduce(sum) { (sum, xEnumerated) in
let (x, component) = xEnumerated
let horizontalAverage: Float = x == 0 ? 1 : (sin(Float.pi * Float(x) * lowerRight.0) - sin(Float.pi * Float(x) * upperLeft.0)) / (Float(x) * Float.pi * (lowerRight.0 - upperLeft.0))
let veritcalAverage: Float = y == 0 ? 1 : (sin(Float.pi * Float(y) * lowerRight.1) - sin(Float.pi * Float(y) * upperLeft.1)) / (Float(y) * Float.pi * (lowerRight.1 - upperLeft.1))
return sum + component * horizontalAverage * veritcalAverage
}
}
}
public func linearRgb(at upperLeft: (Float, Float), size: (Float, Float)) -> (Float, Float, Float) {
return linearRgb(from: upperLeft, to: (upperLeft.0 + size.0, upperLeft.1 + size.1))
}
public var averageLinearRgb: (Float, Float, Float) {
return components[0][0]
}
public var leftEdgeLinearRgb: (Float, Float, Float) { return linearRgb(atX: 0) }
public var rightEdgeLinearRgb: (Float, Float, Float) { return linearRgb(atX: 1) }
public var topEdgeLinearRgb: (Float, Float, Float) { return linearRgb(atY: 0) }
public var bottomEdgeLinearRgb: (Float, Float, Float) { return linearRgb(atY: 1) }
public var topLeftCornerLinearRgb: (Float, Float, Float) { return linearRgb(at: (0, 0)) }
public var topRightCornerLinearRgb: (Float, Float, Float) { return linearRgb(at: (1, 0)) }
public var bottomLeftCornerLinearRgb: (Float, Float, Float) { return linearRgb(at: (0, 1)) }
public var bottomRightCornerLinearRgb: (Float, Float, Float) { return linearRgb(at: (1, 1)) }
}
extension BlurHash {
public func isDark(linearRgb rgb: (Float, Float, Float)) -> Bool {
return rgb.0 * 0.299 + rgb.1 * 0.587 + rgb.2 * 0.114 < 0.5
}
public var isDark: Bool { return isDark(linearRgb: averageLinearRgb) }
public func isDark(atX x: Float) -> Bool { return isDark(linearRgb: linearRgb(atX: x)) }
public func isDark(atY y: Float) -> Bool { return isDark(linearRgb: linearRgb(atY: y)) }
public func isDark(at position: (Float, Float)) -> Bool { return isDark(linearRgb: linearRgb(at: position)) }
public func isDark(from upperLeft: (Float, Float), to lowerRight: (Float, Float)) -> Bool { return isDark(linearRgb: linearRgb(from: upperLeft, to: lowerRight)) }
public func isDark(at upperLeft: (Float, Float), size: (Float, Float)) -> Bool { return isDark(linearRgb: linearRgb(at: upperLeft, size: size)) }
public var isLeftEdgeDark: Bool { return isDark(atX: 0) }
public var isRightEdgeDark: Bool { return isDark(atX: 1) }
public var isTopEdgeDark: Bool { return isDark(atY: 0) }
public var isBottomEdgeDark: Bool { return isDark(atY: 1) }
public var isTopLeftCornerDark: Bool { return isDark(at: (0, 0)) }
public var isTopRightCornerDark: Bool { return isDark(at: (1, 0)) }
public var isBottomLeftCornerDark: Bool { return isDark(at: (0, 1)) }
public var isBottomRightCornerDark: Bool { return isDark(at: (1, 1)) }
}

View File

@ -1,17 +0,0 @@
import Foundation
func signPow(_ value: Float, _ exp: Float) -> Float {
return copysign(pow(abs(value), exp), value)
}
func linearTosRGB(_ value: Float) -> Int {
let v = max(0, min(1, value))
if v <= 0.0031308 { return Int(v * 12.92 * 255 + 0.5) }
else { return Int((1.055 * pow(v, 1 / 2.4) - 0.055) * 255 + 0.5) }
}
func sRGBToLinear<Type: BinaryInteger>(_ value: Type) -> Float {
let v = Float(Int64(value)) / 255
if v <= 0.04045 { return v / 12.92 }
else { return pow((v + 0.055) / 1.055, 2.4) }
}

View File

@ -1,36 +0,0 @@
import Foundation
extension BlurHash {
var twoByThreeEscapeSequence: String {
let areas: [(from: (Float, Float), to: (Float, Float))] = [
(from: (0, 0), to: (0.333, 0.5)),
(from: (0, 0.5), to: (0.333, 1.0)),
(from: (0.333, 0), to: (0.666, 0.5)),
(from: (0.333, 0.5), to: (0.666, 1.0)),
(from: (0.666, 0), to: (1.0, 0.5)),
(from: (0.666, 0.5), to: (1.0, 1.0)),
]
let rgb: [(Float, Float, Float)] = areas.map { area in
linearRgb(from: area.from, to: area.to)
}
let maxRgb: (Float, Float, Float) = rgb.reduce((-Float.infinity, -Float.infinity, -Float.infinity), max)
let minRgb: (Float, Float, Float) = rgb.reduce((Float.infinity, Float.infinity, Float.infinity), min)
let positiveScale: (Float, Float, Float) = ((1, 1, 1) - averageLinearRgb) / (maxRgb - averageLinearRgb)
let negativeScale: (Float, Float, Float) = averageLinearRgb / (averageLinearRgb - minRgb)
let scale: (Float, Float, Float) = min(positiveScale, negativeScale)
let scaledRgb: [(Float, Float, Float)] = rgb.map { rgb in
return (rgb - averageLinearRgb) * scale + averageLinearRgb
}
let c = scaledRgb.map { rgb in
return (linearTosRGB(rgb.0) / 51) * 36 + (linearTosRGB(rgb.1) / 51) * 6 + (linearTosRGB(rgb.2) / 51) + 16
}
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"
}
}

View File

@ -1,68 +0,0 @@
import Foundation
public extension BlurHash {
init?(string: String) {
guard string.count >= 6 else { return nil }
let sizeFlag = String(string[0]).decode83()
let numY = (sizeFlag / 9) + 1
let numX = (sizeFlag % 9) + 1
let quantisedMaximumValue = String(string[1]).decode83()
let maximumValue = Float(quantisedMaximumValue + 1) / 166
guard string.count == 4 + 2 * numX * numY else { return nil }
self.components = (0 ..< numY).map { y in
return (0 ..< numX).map { x in
if x == 0 && y == 0 {
let value = String(string[2 ..< 6]).decode83()
return BlurHash.decodeDC(value)
} else {
let i = x + y * numX
let value = String(string[4 + i * 2 ..< 4 + i * 2 + 2]).decode83()
return BlurHash.decodeAC(value, maximumValue: maximumValue)
}
}
}
}
private static func decodeDC(_ value: Int) -> (Float, Float, Float) {
let intR = value >> 16
let intG = (value >> 8) & 255
let intB = value & 255
return (sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB))
}
private static func decodeAC(_ value: Int, maximumValue: Float) -> (Float, Float, Float) {
let quantR = value / (19 * 19)
let quantG = (value / 19) % 19
let quantB = value % 19
let rgb = (
signPow((Float(quantR) - 9) / 9, 2) * maximumValue,
signPow((Float(quantG) - 9) / 9, 2) * maximumValue,
signPow((Float(quantB) - 9) / 9, 2) * maximumValue
)
return rgb
}
}
private extension String {
subscript (offset: Int) -> Character {
return self[index(startIndex, offsetBy: offset)]
}
subscript (bounds: CountableClosedRange<Int>) -> Substring {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
return self[start...end]
}
subscript (bounds: CountableRange<Int>) -> Substring {
let start = index(startIndex, offsetBy: bounds.lowerBound)
let end = index(startIndex, offsetBy: bounds.upperBound)
return self[start..<end]
}
}

View File

@ -1,55 +0,0 @@
import UIKit
public extension BlurHash {
init?(image: UIImage, numberOfComponents components: (Int, Int)) {
guard components.0 >= 1, components.0 <= 9,
components.1 >= 1, components.1 <= 9 else {
fatalError("Number of components bust be between 1 and 9 inclusive on each axis")
}
guard let cgImage = image.cgImage,
let dataProvider = cgImage.dataProvider,
let data = dataProvider.data,
let pixels = CFDataGetBytePtr(data),
cgImage.colorSpace?.numberOfComponents == 3,
cgImage.bitsPerPixel == 24 || cgImage.bitsPerPixel == 32 else {
assertionFailure("Invalid image format")
return nil
}
let width = cgImage.width
let height = cgImage.height
let bytesPerRow = cgImage.bytesPerRow
self.components = (0 ..< components.1).map { y in
return (0 ..< components.0).map { x in
let normalisation: Float = (x == 0 && y == 0) ? 1 : 2
return BlurHash.multiplyBasisFunction(pixels: pixels, width: width, height: height, bytesPerRow: bytesPerRow, bytesPerPixel: cgImage.bitsPerPixel / 8, pixelOffset: 0) {
normalisation * cos(Float.pi * Float(x) * $0 / Float(width)) * cos(Float.pi * Float(y) * $1 / Float(height))
}
}
}
}
static private func multiplyBasisFunction(pixels: UnsafePointer<UInt8>, width: Int, height: Int, bytesPerRow: Int, bytesPerPixel: Int, pixelOffset: Int, basisFunction: (Float, Float) -> Float) -> (Float, Float, Float) {
var r: Float = 0
var g: Float = 0
var b: Float = 0
let buffer = UnsafeBufferPointer(start: pixels, count: height * bytesPerRow)
for x in 0 ..< width {
for y in 0 ..< height {
let basis = basisFunction(Float(x), Float(y))
r += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 0 + y * bytesPerRow])
g += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 1 + y * bytesPerRow])
b += basis * sRGBToLinear(buffer[bytesPerPixel * x + pixelOffset + 2 + y * bytesPerRow])
}
}
let scale = 1 / Float(width * height)
return (r * scale, g * scale, b * scale)
}
}

View File

@ -1,43 +0,0 @@
import UIKit
extension BlurHash {
public init(horizontalGradientFrom leftColour: UIColor, to rightColour: UIColor) {
let average = (leftColour.linear + rightColour.linear) / 2
let difference = (leftColour.linear - rightColour.linear) / 2
self.components = [[average, difference]]
}
public init(verticalGradientFrom leftColour: UIColor, to rightColour: UIColor) {
let average = (leftColour.linear + rightColour.linear) / 2
let difference = (leftColour.linear - rightColour.linear) / 2
self.components = [[average], [difference]]
}
public init(blendingTopLeft topLeftColour: UIColor, topRight topRightColour: UIColor, bottomLeft bottomLeftColour: UIColor, bottomRight bottomRightColour: UIColor) {
let average = (topLeftColour.linear + topRightColour.linear + bottomLeftColour.linear + bottomRightColour.linear) / 4
let horizontalDifference = (topLeftColour.linear - topRightColour.linear + bottomLeftColour.linear - bottomRightColour.linear) / 4
let verticalDifference = (topLeftColour.linear + topRightColour.linear - bottomLeftColour.linear - bottomRightColour.linear) / 4
let diagonalDifference = (topLeftColour.linear - topRightColour.linear - bottomLeftColour.linear + bottomRightColour.linear) / 4
self.components = [[average, horizontalDifference], [verticalDifference, diagonalDifference]]
}
}
extension UIColor {
var linear: (Float, Float, Float) {
guard let c = cgColor.converted(to: CGColorSpace(name: CGColorSpace.sRGB)!, intent: .defaultIntent, options: nil)?.components else { return (0, 0, 0) }
switch c.count {
case 1, 2: return (sRGBToLinear(c[0]), sRGBToLinear(c[0]), sRGBToLinear(c[0]))
case 3, 4: return (sRGBToLinear(c[0]), sRGBToLinear(c[1]), sRGBToLinear(c[2]))
default: return (0, 0, 0)
}
}
}
func sRGBToLinear(_ value: CGFloat) -> Float {
let v = Float(value)
if v <= 0.04045 { return v / 12.92 }
else { return pow((v + 0.055) / 1.055, 2.4) }
}

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -1,40 +0,0 @@
import Foundation
private let encodeCharacters: [String] = {
return "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~".map { String($0) }
}()
private let decodeCharacters: [String: Int] = {
var dict: [String: Int] = [:]
for (index, character) in encodeCharacters.enumerated() {
dict[character] = index
}
return dict
}()
extension BinaryInteger {
func encode83(length: Int) -> String {
var result = ""
for i in 1 ... length {
let digit = (Int(self) / pow(83, length - i)) % 83
result += encodeCharacters[Int(digit)]
}
return result
}
}
extension String {
func decode83() -> Int {
var value: Int = 0
for character in self {
if let digit = decodeCharacters[String(character)] {
value = value * 83 + digit
}
}
return value
}
}
private func pow(_ base: Int, _ exponent: Int) -> Int {
return (0 ..< exponent).reduce(1) { value, _ in value * base }
}

View File

@ -1,48 +0,0 @@
import Foundation
public extension BlurHash {
var string: String {
let flatComponents = components.reduce([]) { $0 + $1 }
let dc = flatComponents.first!
let ac = flatComponents.dropFirst()
var hash = ""
let sizeFlag = (numberOfHorizontalComponents - 1) + (numberOfVerticalComponents - 1) * 9
hash += sizeFlag.encode83(length: 1)
let maximumValue: Float
if ac.count > 0 {
let actualMaximumValue = ac.map({ max(abs($0.0), abs($0.1), abs($0.2)) }).max()!
let quantisedMaximumValue = Int(max(0, min(82, floor(actualMaximumValue * 166 - 0.5))))
maximumValue = Float(quantisedMaximumValue + 1) / 166
hash += quantisedMaximumValue.encode83(length: 1)
} else {
maximumValue = 1
hash += 0.encode83(length: 1)
}
hash += encodeDC(dc).encode83(length: 4)
for factor in ac {
hash += encodeAC(factor, maximumValue: maximumValue).encode83(length: 2)
}
return hash
}
private func encodeDC(_ value: (Float, Float, Float)) -> Int {
let roundedR = linearTosRGB(value.0)
let roundedG = linearTosRGB(value.1)
let roundedB = linearTosRGB(value.2)
return (roundedR << 16) + (roundedG << 8) + roundedB
}
private func encodeAC(_ value: (Float, Float, Float), maximumValue: Float) -> Int {
let quantR = Int(max(0, min(18, floor(signPow(value.0 / maximumValue, 0.5) * 9 + 9.5))))
let quantG = Int(max(0, min(18, floor(signPow(value.1 / maximumValue, 0.5) * 9 + 9.5))))
let quantB = Int(max(0, min(18, floor(signPow(value.2 / maximumValue, 0.5) * 9 + 9.5))))
return quantR * 19 * 19 + quantG * 19 + quantB
}
}

View File

@ -1,81 +0,0 @@
import UIKit
extension BlurHash {
public func cgImage(size: CGSize) -> CGImage? {
let width = Int(size.width)
let height = Int(size.height)
let bytesPerRow = width * 3
guard let data = CFDataCreateMutable(kCFAllocatorDefault, bytesPerRow * height) else { return nil }
CFDataSetLength(data, bytesPerRow * height)
guard let pixels = CFDataGetMutableBytePtr(data) else { return nil }
for y in 0 ..< height {
for x in 0 ..< width {
var c: (Float, Float, Float) = (0, 0, 0)
for j in 0 ..< numberOfVerticalComponents {
for i in 0 ..< numberOfHorizontalComponents {
let basis = cos(Float.pi * Float(x) * Float(i) / Float(width)) * cos(Float.pi * Float(y) * Float(j) / Float(height))
let component = components[j][i]
c += component * basis
}
}
let intR = UInt8(linearTosRGB(c.0))
let intG = UInt8(linearTosRGB(c.1))
let intB = UInt8(linearTosRGB(c.2))
pixels[3 * x + 0 + y * bytesPerRow] = intR
pixels[3 * x + 1 + y * bytesPerRow] = intG
pixels[3 * x + 2 + y * bytesPerRow] = intB
}
}
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue)
guard let provider = CGDataProvider(data: data) else { return nil }
guard let cgImage = CGImage(width: width, height: height, bitsPerComponent: 8, bitsPerPixel: 24, bytesPerRow: bytesPerRow,
space: CGColorSpaceCreateDeviceRGB(), bitmapInfo: bitmapInfo, provider: provider, decode: nil, shouldInterpolate: true, intent: .defaultIntent) else { return nil }
return cgImage
}
public func cgImage(numberOfPixels: Int = 1024, originalSize size: CGSize) -> CGImage? {
let width: CGFloat
let height: CGFloat
if size.width > size.height {
width = floor(sqrt(CGFloat(numberOfPixels) * size.width / size.height) + 0.5)
height = floor(CGFloat(numberOfPixels) / width + 0.5)
} else {
height = floor(sqrt(CGFloat(numberOfPixels) * size.height / size.width) + 0.5)
width = floor(CGFloat(numberOfPixels) / height + 0.5)
}
return cgImage(size: CGSize(width: width, height: height))
}
public func image(size: CGSize) -> UIImage? {
guard let cgImage = cgImage(size: size) else { return nil }
return UIImage(cgImage: cgImage)
}
public func image(numberOfPixels: Int = 1024, originalSize size: CGSize) -> UIImage? {
guard let cgImage = cgImage(numberOfPixels: numberOfPixels, originalSize: size) else { return nil }
return UIImage(cgImage: cgImage)
}
}
@objc extension UIImage {
public convenience init?(blurHash string: String, size: CGSize, punch: Float = 1) {
guard let blurHash = BlurHash(string: string),
let cgImage = blurHash.punch(punch).cgImage(size: size) else { return nil }
self.init(cgImage: cgImage)
}
public convenience init?(blurHash string: String, numberOfPixels: Int = 1024, originalSize size: CGSize, punch: Float = 1) {
guard let blurHash = BlurHash(string: string),
let cgImage = blurHash.punch(punch).cgImage(numberOfPixels: numberOfPixels, originalSize: size) else { return nil }
self.init(cgImage: cgImage)
}
}

View File

@ -1,53 +0,0 @@
import Foundation
func +(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {
return (lhs.0 + rhs.0, lhs.1 + rhs.1, lhs.2 + rhs.2)
}
func -(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {
return (lhs.0 - rhs.0, lhs.1 - rhs.1, lhs.2 - rhs.2)
}
func *(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {
return (lhs.0 * rhs.0, lhs.1 * rhs.1, lhs.2 * rhs.2)
}
func *(lhs: (Float, Float, Float), rhs: Float) -> (Float, Float, Float) {
return (lhs.0 * rhs, lhs.1 * rhs, lhs.2 * rhs)
}
func *(lhs: Float, rhs: (Float, Float, Float)) -> (Float, Float, Float) {
return (lhs * rhs.0, lhs * rhs.1, lhs * rhs.2)
}
func /(lhs: (Float, Float, Float), rhs: (Float, Float, Float)) -> (Float, Float, Float) {
return (lhs.0 / rhs.0, lhs.1 / rhs.1, lhs.2 / rhs.2)
}
func /(lhs: (Float, Float, Float), rhs: Float) -> (Float, Float, Float) {
return (lhs.0 / rhs, lhs.1 / rhs, lhs.2 / rhs)
}
func +=(lhs: inout (Float, Float, Float), rhs: (Float, Float, Float)) {
lhs = lhs + rhs
}
func -=(lhs: inout (Float, Float, Float), rhs: (Float, Float, Float)) {
lhs = lhs - rhs
}
func *=(lhs: inout (Float, Float, Float), rhs: Float) {
lhs = lhs * rhs
}
func /=(lhs: inout (Float, Float, Float), rhs: Float) {
lhs = lhs / rhs
}
func min(_ a: (Float, Float, Float), _ b: (Float, Float, Float)) -> (Float, Float, Float) {
return (min(a.0, b.0), min(a.1, b.1), min(a.2, b.2))
}
func max(_ a: (Float, Float, Float), _ b: (Float, Float, Float)) -> (Float, Float, Float) {
return (max(a.0, b.0), max(a.1, b.1), max(a.2, b.2))
}

View File

@ -1,117 +0,0 @@
import UIKit
import BlurHashKit
class AdvancedViewController: UIViewController {
@IBOutlet weak var originalImageView: UIImageView?
@IBOutlet weak var uncompressedBlurImageView: UIImageView?
@IBOutlet weak var hashLabel: UILabel?
@IBOutlet weak var compressedBlurImageView: UIImageView?
@IBOutlet weak var darknessBlurImageView: UIImageView?
@IBOutlet weak var topLeftCornerLabel: UILabel?
@IBOutlet weak var topEdgeLabel: UILabel?
@IBOutlet weak var topRightCornerLabel: UILabel?
@IBOutlet weak var leftEdgeLabel: UILabel?
@IBOutlet weak var centreLabel: UILabel?
@IBOutlet weak var rightEdgeLabel: UILabel?
@IBOutlet weak var bottomLeftCornerLabel: UILabel?
@IBOutlet weak var bottomEdgeLabel: UILabel?
@IBOutlet weak var bottomRightCornerLabel: UILabel?
@IBOutlet weak var xComponentsLabel: UILabel?
@IBOutlet weak var yComponentsLabel: UILabel?
let images: [UIImage] = [
UIImage(named: "pic2.png")!,
UIImage(named: "pic1.png")!,
UIImage(named: "pic3.png")!,
UIImage(named: "pic6.png")!,
UIImage(named: "pic4.png")!,
UIImage(named: "pic5.png")!,
]
var imageIndex: Int = 0
var xComponents: Int = 4
var yComponents: Int = 3
override func viewDidLoad() {
super.viewDidLoad()
update()
}
@IBAction func imageTapped() {
imageIndex = (imageIndex + 1) % images.count
update()
}
@IBAction func xPlusTapped() {
if xComponents < 9 {
xComponents += 1
update()
}
}
@IBAction func xMinusTapped() {
if xComponents > 1 {
xComponents -= 1
update()
}
}
@IBAction func yPlusTapped() {
if yComponents < 9 {
yComponents += 1
update()
}
}
@IBAction func yMinusTapped() {
if yComponents > 1 {
yComponents -= 1
update()
}
}
func update() {
let image = images[imageIndex]
originalImageView?.image = image
let blurHash = BlurHash(image: images[imageIndex], numberOfComponents: (xComponents, yComponents))!
uncompressedBlurImageView?.image = blurHash.image(numberOfPixels: 1024, originalSize: image.size)
hashLabel?.text = blurHash.string
let decodedBlurHash = BlurHash(string: blurHash.string)!
compressedBlurImageView?.image = decodedBlurHash.image(numberOfPixels: 1024, originalSize: image.size)
darknessBlurImageView?.image = decodedBlurHash.image(numberOfPixels: 1024, originalSize: image.size)
setDarkness(label: topLeftCornerLabel, isDark: decodedBlurHash.isTopLeftCornerDark, light: "", dark: "")
setDarkness(label: topEdgeLabel, isDark: decodedBlurHash.isTopEdgeDark, light: "------Light------", dark: "------Dark------")
setDarkness(label: topRightCornerLabel, isDark: decodedBlurHash.isTopRightCornerDark, light: "", dark: "")
setDarkness(label: leftEdgeLabel, isDark: decodedBlurHash.isLeftEdgeDark, light: "|\n|\nLight\n|\n|", dark: "|\n|\nDark\n|\n|")
setDarkness(label: centreLabel, isDark: decodedBlurHash.isDark, light: "Light", dark: "Dark")
setDarkness(label: rightEdgeLabel, isDark: decodedBlurHash.isRightEdgeDark, light: "|\n|\nLight\n|\n|", dark: "|\n|\nDark\n|\n|")
setDarkness(label: bottomLeftCornerLabel, isDark: decodedBlurHash.isBottomLeftCornerDark, light: "", dark: "")
setDarkness(label: bottomEdgeLabel, isDark: decodedBlurHash.isBottomEdgeDark, light: "------Light------", dark: "------Dark------")
setDarkness(label: bottomRightCornerLabel, isDark: decodedBlurHash.isBottomRightCornerDark, light: "", dark: "")
xComponentsLabel?.text = String(xComponents)
yComponentsLabel?.text = String(yComponents)
}
func setDarkness(label: UILabel?, isDark: Bool, light: String, dark: String) {
if isDark {
label?.textColor = .white
label?.text = dark
} else {
label?.textColor = .black
label?.text = light
}
}
}

View File

@ -1,12 +0,0 @@
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
return true
}
}

View File

@ -1,98 +0,0 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11106"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

View File

@ -1,986 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="Courier.ttc">
<string>Courier</string>
</array>
</customFonts>
<scenes>
<!--Advanced-->
<scene sceneID="aAy-aP-fMy">
<objects>
<viewController id="GoA-CQ-Oko" customClass="AdvancedViewController" customModule="BlurHashTest" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="RAf-iQ-3dY"/>
<viewControllerLayoutGuide type="bottom" id="Pfy-5l-wbH"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="fAH-Mr-gHV">
<rect key="frame" x="0.0" y="0.0" width="375" height="1000"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aHD-uZ-0hI">
<rect key="frame" x="0.0" y="0.0" width="375" height="890"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="bKs-dk-VVG">
<rect key="frame" x="0.0" y="0.0" width="375" height="692"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nkq-Mg-0Wb">
<rect key="frame" x="0.0" y="0.0" width="375" height="129"/>
<subviews>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="128" translatesAutoresizingMaskIntoConstraints="NO" id="jbW-pm-Cg6">
<rect key="frame" x="67.5" y="0.0" width="240" height="129"/>
<gestureRecognizers/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="jbW-pm-Cg6" secondAttribute="bottom" id="RYV-59-qwc"/>
<constraint firstItem="jbW-pm-Cg6" firstAttribute="top" secondItem="nkq-Mg-0Wb" secondAttribute="top" id="c9F-TY-uXD"/>
<constraint firstItem="jbW-pm-Cg6" firstAttribute="centerX" secondItem="nkq-Mg-0Wb" secondAttribute="centerX" id="koS-jd-wdS"/>
</constraints>
</view>
<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">
<rect key="frame" x="0.0" y="129" width="375" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="1mZ-Zg-TtV"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YL9-oY-UoD">
<rect key="frame" x="0.0" y="177" width="375" height="129"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="128" translatesAutoresizingMaskIntoConstraints="NO" id="oPc-dA-gI3">
<rect key="frame" x="67.5" y="0.0" width="240" height="129"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="oPc-dA-gI3" firstAttribute="centerX" secondItem="YL9-oY-UoD" secondAttribute="centerX" id="IgK-K5-keA"/>
<constraint firstItem="oPc-dA-gI3" firstAttribute="top" secondItem="YL9-oY-UoD" secondAttribute="top" id="Qdb-Tg-I23"/>
<constraint firstAttribute="bottom" secondItem="oPc-dA-gI3" secondAttribute="bottom" id="rF5-9n-uMY"/>
</constraints>
</view>
<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">
<rect key="frame" x="0.0" y="306" width="375" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="gnc-RN-bd3"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zj1-m7-k55">
<rect key="frame" x="0.0" y="354" width="375" height="16"/>
<subviews>
<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">
<rect key="frame" x="16" y="0.0" width="343" height="16"/>
<fontDescription key="fontDescription" name="Courier" family="Courier" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="APC-rp-edX" secondAttribute="bottom" id="51S-aL-tb0"/>
<constraint firstAttribute="trailing" secondItem="APC-rp-edX" secondAttribute="trailing" constant="16" id="Hba-H7-Skh"/>
<constraint firstItem="APC-rp-edX" firstAttribute="leading" secondItem="zj1-m7-k55" secondAttribute="leading" constant="16" id="hwA-N8-Db1"/>
<constraint firstItem="APC-rp-edX" firstAttribute="top" secondItem="zj1-m7-k55" secondAttribute="top" id="kUD-4j-Ik3"/>
</constraints>
</view>
<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">
<rect key="frame" x="0.0" y="370" width="375" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="Iyh-Uc-8SK"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kkk-a2-0ke">
<rect key="frame" x="0.0" y="418" width="375" height="129"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="128" translatesAutoresizingMaskIntoConstraints="NO" id="wVZ-tm-8wt">
<rect key="frame" x="67.5" y="0.0" width="240" height="129"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="wVZ-tm-8wt" secondAttribute="bottom" id="4kq-pb-fVP"/>
<constraint firstItem="wVZ-tm-8wt" firstAttribute="top" secondItem="kkk-a2-0ke" secondAttribute="top" id="5dv-VQ-Xrw"/>
<constraint firstItem="wVZ-tm-8wt" firstAttribute="centerX" secondItem="kkk-a2-0ke" secondAttribute="centerX" id="gqq-M2-see"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TkK-nz-dPp">
<rect key="frame" x="0.0" y="547" width="375" height="145"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="128" translatesAutoresizingMaskIntoConstraints="NO" id="AIg-aT-T27">
<rect key="frame" x="67.5" y="16" width="240" height="129"/>
</imageView>
<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">
<rect key="frame" x="71.5" y="20" width="13" height="29"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="168" y="20" width="39" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="290.5" y="20" width="13" height="29"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="149.5" y="59" width="76" height="43"/>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="36"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="294" y="70.5" width="9.5" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="71.5" y="112" width="13" height="29"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="168" y="120.5" width="39" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="290.5" y="112" width="13" height="29"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<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">
<rect key="frame" x="71.5" y="70" width="9.5" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Lxh-2a-bSu" firstAttribute="bottom" secondItem="AIg-aT-T27" secondAttribute="bottom" constant="-4" id="2a7-ym-egB"/>
<constraint firstItem="Ivf-jp-J0F" firstAttribute="centerX" secondItem="AIg-aT-T27" secondAttribute="centerX" id="6d4-fs-VN3"/>
<constraint firstItem="Hyz-JK-uvv" firstAttribute="centerY" secondItem="AIg-aT-T27" secondAttribute="centerY" id="6oe-4p-vbH"/>
<constraint firstItem="AIg-aT-T27" firstAttribute="centerX" secondItem="TkK-nz-dPp" secondAttribute="centerX" id="Ayg-GV-m1p"/>
<constraint firstItem="Y1h-NI-DD4" firstAttribute="centerX" secondItem="AIg-aT-T27" secondAttribute="centerX" id="BrA-QK-N3Y"/>
<constraint firstItem="Lxh-2a-bSu" firstAttribute="trailing" secondItem="AIg-aT-T27" secondAttribute="trailing" constant="-4" id="DlN-ub-REN"/>
<constraint firstItem="g5m-pZ-G50" firstAttribute="top" secondItem="AIg-aT-T27" secondAttribute="top" constant="4" id="Fsq-Gh-GHs"/>
<constraint firstItem="AIg-aT-T27" firstAttribute="top" secondItem="TkK-nz-dPp" secondAttribute="top" constant="16" id="H93-y6-jZC"/>
<constraint firstItem="Ivf-jp-J0F" firstAttribute="top" secondItem="AIg-aT-T27" secondAttribute="top" constant="4" id="HME-KE-TEj"/>
<constraint firstItem="752-5V-jQ8" firstAttribute="bottom" secondItem="AIg-aT-T27" secondAttribute="bottom" constant="-4" id="Tlf-EL-gQB"/>
<constraint firstItem="Hyz-JK-uvv" firstAttribute="leading" secondItem="AIg-aT-T27" secondAttribute="leading" constant="4" id="WqR-7p-X2q"/>
<constraint firstItem="Y1h-NI-DD4" firstAttribute="centerY" secondItem="AIg-aT-T27" secondAttribute="centerY" id="XTf-le-JVg"/>
<constraint firstItem="QbV-sR-2CC" firstAttribute="leading" secondItem="AIg-aT-T27" secondAttribute="leading" constant="4" id="ccx-W9-tWJ"/>
<constraint firstItem="g5m-pZ-G50" firstAttribute="trailing" secondItem="AIg-aT-T27" secondAttribute="trailing" constant="-4" id="cia-Yt-Vg4"/>
<constraint firstItem="XNZ-ZV-PDL" firstAttribute="bottom" secondItem="AIg-aT-T27" secondAttribute="bottom" constant="-4" id="drB-h2-OWB"/>
<constraint firstItem="QbV-sR-2CC" firstAttribute="top" secondItem="AIg-aT-T27" secondAttribute="top" constant="4" id="gxS-1R-Uo9"/>
<constraint firstItem="752-5V-jQ8" firstAttribute="centerX" secondItem="AIg-aT-T27" secondAttribute="centerX" id="iov-xV-TCy"/>
<constraint firstItem="rwg-7e-Nii" firstAttribute="centerY" secondItem="AIg-aT-T27" secondAttribute="centerY" id="mkO-VW-55t"/>
<constraint firstItem="XNZ-ZV-PDL" firstAttribute="leading" secondItem="AIg-aT-T27" secondAttribute="leading" constant="4" id="sSW-sf-a7n"/>
<constraint firstItem="rwg-7e-Nii" firstAttribute="trailing" secondItem="AIg-aT-T27" secondAttribute="trailing" constant="-4" id="tZI-o8-W7e"/>
<constraint firstAttribute="bottom" secondItem="AIg-aT-T27" secondAttribute="bottom" id="zpL-eF-oFD"/>
</constraints>
</view>
</subviews>
<gestureRecognizers/>
<constraints>
<constraint firstItem="AIg-aT-T27" firstAttribute="height" secondItem="wVZ-tm-8wt" secondAttribute="height" id="CuJ-Al-plZ"/>
<constraint firstItem="oPc-dA-gI3" firstAttribute="height" secondItem="jbW-pm-Cg6" secondAttribute="height" id="Hau-lk-Q0e"/>
<constraint firstItem="jbW-pm-Cg6" firstAttribute="height" secondItem="wVZ-tm-8wt" secondAttribute="height" id="Z6u-D5-24l"/>
<constraint firstItem="wVZ-tm-8wt" firstAttribute="width" secondItem="jbW-pm-Cg6" secondAttribute="width" id="cbL-D5-7RY"/>
<constraint firstItem="AIg-aT-T27" firstAttribute="width" secondItem="wVZ-tm-8wt" secondAttribute="width" id="hyt-gJ-oJ4"/>
<constraint firstItem="oPc-dA-gI3" firstAttribute="width" secondItem="jbW-pm-Cg6" secondAttribute="width" id="qzN-lh-p8Y"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="auZ-KF-fNX" appends="YES" id="9pp-sP-0id"/>
</connections>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="bKs-dk-VVG" secondAttribute="trailing" id="DFw-Rh-Alp"/>
<constraint firstItem="bKs-dk-VVG" firstAttribute="width" secondItem="aHD-uZ-0hI" secondAttribute="width" id="bJq-QF-sJi"/>
<constraint firstItem="bKs-dk-VVG" firstAttribute="leading" secondItem="aHD-uZ-0hI" secondAttribute="leading" id="iYn-Zx-rpg"/>
<constraint firstItem="bKs-dk-VVG" firstAttribute="top" secondItem="aHD-uZ-0hI" secondAttribute="top" id="l7b-RK-ayz"/>
<constraint firstAttribute="bottom" secondItem="bKs-dk-VVG" secondAttribute="bottom" id="vKw-mX-8Ta"/>
</constraints>
</scrollView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="k8L-yh-Uc9">
<rect key="frame" x="0.0" y="890" width="375" height="61"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="t9s-30-kSA">
<rect key="frame" x="92" y="8" width="45" height="45"/>
<constraints>
<constraint firstAttribute="width" constant="45" id="2Qd-SN-JZG"/>
<constraint firstAttribute="height" constant="45" id="oJq-j6-j6D"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="+"/>
<connections>
<action selector="xPlusTapped" destination="GoA-CQ-Oko" eventType="touchUpInside" id="CQb-RI-hPa"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dcv-3g-vPH">
<rect key="frame" x="8" y="6" width="48" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="06k-fn-X6r"/>
<constraint firstAttribute="height" constant="48" id="s9s-VF-ac5"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="-"/>
<connections>
<action selector="xMinusTapped" destination="GoA-CQ-Oko" eventType="touchUpInside" id="N05-Gv-FL5"/>
</connections>
</button>
<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">
<rect key="frame" x="64" y="16" width="20" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="InF-nv-eHU"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="spt-ih-YyW">
<rect key="frame" x="322" y="8" width="45" height="45"/>
<constraints>
<constraint firstAttribute="width" constant="45" id="Glg-Nm-gax"/>
<constraint firstAttribute="height" constant="45" id="NfN-i3-zZd"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="+"/>
<connections>
<action selector="yPlusTapped" destination="GoA-CQ-Oko" eventType="touchUpInside" id="ZSc-o4-g8c"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="4FP-Tx-TxJ">
<rect key="frame" x="238" y="6" width="48" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="Tds-KD-4FW"/>
<constraint firstAttribute="height" constant="48" id="tk6-6o-D7K"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="-"/>
<connections>
<action selector="yMinusTapped" destination="GoA-CQ-Oko" eventType="touchUpInside" id="KTx-Hq-JVL"/>
</connections>
</button>
<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">
<rect key="frame" x="294" y="16" width="20" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="4ZW-PT-QlK"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="UVT-7V-jBv" firstAttribute="top" secondItem="k8L-yh-Uc9" secondAttribute="top" constant="16" id="1Rg-vC-ASB"/>
<constraint firstItem="dcv-3g-vPH" firstAttribute="leading" secondItem="k8L-yh-Uc9" secondAttribute="leadingMargin" id="5Cn-HL-FpK"/>
<constraint firstAttribute="bottom" secondItem="UVT-7V-jBv" secondAttribute="bottom" constant="16" id="9gx-1x-RTG"/>
<constraint firstItem="UVT-7V-jBv" firstAttribute="baseline" secondItem="t9s-30-kSA" secondAttribute="baseline" id="D2P-r2-SNs"/>
<constraint firstItem="spt-ih-YyW" firstAttribute="trailing" secondItem="k8L-yh-Uc9" secondAttribute="trailingMargin" id="KEc-3P-PWQ"/>
<constraint firstItem="nFP-Bd-1kw" firstAttribute="baseline" secondItem="spt-ih-YyW" secondAttribute="baseline" id="Kpf-pr-0qa"/>
<constraint firstItem="UVT-7V-jBv" firstAttribute="leading" secondItem="dcv-3g-vPH" secondAttribute="trailing" constant="8" id="Qxq-mr-rns"/>
<constraint firstItem="spt-ih-YyW" firstAttribute="leading" secondItem="nFP-Bd-1kw" secondAttribute="trailing" constant="8" id="Ucw-KI-kcT"/>
<constraint firstItem="UVT-7V-jBv" firstAttribute="baseline" secondItem="dcv-3g-vPH" secondAttribute="baseline" id="cs7-9b-peH"/>
<constraint firstItem="nFP-Bd-1kw" firstAttribute="leading" secondItem="4FP-Tx-TxJ" secondAttribute="trailing" constant="8" id="dXX-jV-D7H"/>
<constraint firstItem="t9s-30-kSA" firstAttribute="leading" secondItem="UVT-7V-jBv" secondAttribute="trailing" constant="8" id="gCn-aY-cY4"/>
<constraint firstItem="nFP-Bd-1kw" firstAttribute="baseline" secondItem="UVT-7V-jBv" secondAttribute="baseline" id="sZI-yf-P0b"/>
<constraint firstItem="nFP-Bd-1kw" firstAttribute="baseline" secondItem="4FP-Tx-TxJ" secondAttribute="baseline" id="ytX-t2-NXt"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Pfy-5l-wbH" firstAttribute="top" secondItem="k8L-yh-Uc9" secondAttribute="bottom" id="BO1-vQ-LLV"/>
<constraint firstItem="aHD-uZ-0hI" firstAttribute="top" secondItem="fAH-Mr-gHV" secondAttribute="top" id="N3K-aO-MAg"/>
<constraint firstAttribute="trailing" secondItem="k8L-yh-Uc9" secondAttribute="trailing" id="R4w-xg-Ydq"/>
<constraint firstAttribute="trailing" secondItem="aHD-uZ-0hI" secondAttribute="trailing" id="TmE-g2-rHx"/>
<constraint firstItem="k8L-yh-Uc9" firstAttribute="top" secondItem="aHD-uZ-0hI" secondAttribute="bottom" id="i3H-zp-gMO"/>
<constraint firstItem="k8L-yh-Uc9" firstAttribute="leading" secondItem="fAH-Mr-gHV" secondAttribute="leading" id="tBt-id-pd2"/>
<constraint firstItem="aHD-uZ-0hI" firstAttribute="leading" secondItem="fAH-Mr-gHV" secondAttribute="leading" id="yjB-e0-YGl"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Advanced" id="hpi-sc-HlI"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="375" height="1000"/>
<connections>
<outlet property="bottomEdgeLabel" destination="752-5V-jQ8" id="bOC-GZ-QUG"/>
<outlet property="bottomLeftCornerLabel" destination="XNZ-ZV-PDL" id="6uA-8X-myp"/>
<outlet property="bottomRightCornerLabel" destination="Lxh-2a-bSu" id="PIk-6X-6lV"/>
<outlet property="centreLabel" destination="Y1h-NI-DD4" id="SDD-x8-aSv"/>
<outlet property="compressedBlurImageView" destination="wVZ-tm-8wt" id="efz-1Q-rJD"/>
<outlet property="darknessBlurImageView" destination="AIg-aT-T27" id="m4q-Gt-XEp"/>
<outlet property="hashLabel" destination="APC-rp-edX" id="dVo-oy-OH0"/>
<outlet property="leftEdgeLabel" destination="Hyz-JK-uvv" id="2wM-Nl-5wq"/>
<outlet property="originalImageView" destination="jbW-pm-Cg6" id="DkX-lD-2Us"/>
<outlet property="rightEdgeLabel" destination="rwg-7e-Nii" id="2Ra-3k-1RU"/>
<outlet property="topEdgeLabel" destination="Ivf-jp-J0F" id="V9P-yS-GZS"/>
<outlet property="topLeftCornerLabel" destination="QbV-sR-2CC" id="u7w-vL-IG4"/>
<outlet property="topRightCornerLabel" destination="g5m-pZ-G50" id="8RW-PD-joC"/>
<outlet property="uncompressedBlurImageView" destination="oPc-dA-gI3" id="k8K-yT-oIV"/>
<outlet property="xComponentsLabel" destination="UVT-7V-jBv" id="nvT-md-JYP"/>
<outlet property="yComponentsLabel" destination="nFP-Bd-1kw" id="4GY-Rs-xGV"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Vrs-Em-liA" userLabel="First Responder" sceneMemberID="firstResponder"/>
<tapGestureRecognizer id="auZ-KF-fNX">
<connections>
<action selector="imageTapped" destination="GoA-CQ-Oko" id="Qlx-2D-Ar2"/>
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="198" y="148"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="8sD-Lj-Une">
<objects>
<tabBarController id="ow8-qa-tQW" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="1We-ew-nhn">
<rect key="frame" x="0.0" y="0.0" width="375" height="49"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tabBar>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="viewControllers" id="MSD-JF-mP5"/>
<segue destination="GoA-CQ-Oko" kind="relationship" relationship="viewControllers" id="JRu-eR-uaB"/>
<segue destination="ieU-Ur-ANQ" kind="relationship" relationship="viewControllers" id="gtC-0c-rsm"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Nxb-Ud-Oy0" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-754" y="148"/>
</scene>
<!--Simple-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="SimpleViewController" customModule="BlurHashTest" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="OWy-rO-KNt"/>
<viewControllerLayoutGuide type="bottom" id="wEW-By-gXh"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zAY-rl-FzJ">
<rect key="frame" x="0.0" y="0.0" width="375" height="483"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="DfD-2w-NCY">
<rect key="frame" x="0.0" y="0.0" width="375" height="368"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cao-yg-vDf">
<rect key="frame" x="0.0" y="0.0" width="375" height="128"/>
<subviews>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="128" translatesAutoresizingMaskIntoConstraints="NO" id="P5Q-KT-MGh">
<rect key="frame" x="67.5" y="0.0" width="240" height="128"/>
<gestureRecognizers/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="P5Q-KT-MGh" firstAttribute="centerX" secondItem="Cao-yg-vDf" secondAttribute="centerX" id="1fy-d7-6wF"/>
<constraint firstAttribute="bottom" secondItem="P5Q-KT-MGh" secondAttribute="bottom" id="1m7-aS-CqU"/>
<constraint firstItem="P5Q-KT-MGh" firstAttribute="top" secondItem="Cao-yg-vDf" secondAttribute="top" id="Deo-JE-3nV"/>
</constraints>
</view>
<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">
<rect key="frame" x="0.0" y="128" width="375" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="xcV-Hk-lgg"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xRg-WY-LeQ">
<rect key="frame" x="0.0" y="176" width="375" height="16"/>
<subviews>
<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">
<rect key="frame" x="16" y="0.0" width="343" height="16"/>
<fontDescription key="fontDescription" name="Courier" family="Courier" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="tub-3a-hqA" firstAttribute="leading" secondItem="xRg-WY-LeQ" secondAttribute="leading" constant="16" id="1p2-gM-4fX"/>
<constraint firstItem="tub-3a-hqA" firstAttribute="top" secondItem="xRg-WY-LeQ" secondAttribute="top" id="ab1-kR-1tG"/>
<constraint firstAttribute="bottom" secondItem="tub-3a-hqA" secondAttribute="bottom" id="b7z-cX-mhj"/>
<constraint firstAttribute="trailing" secondItem="tub-3a-hqA" secondAttribute="trailing" constant="16" id="dJb-W1-1VB"/>
</constraints>
</view>
<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">
<rect key="frame" x="0.0" y="192" width="375" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="Oj6-ab-Qb1"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZbH-UL-Efd">
<rect key="frame" x="0.0" y="240" width="375" height="128"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" placeholderIntrinsicWidth="240" placeholderIntrinsicHeight="128" translatesAutoresizingMaskIntoConstraints="NO" id="aqc-Px-Q6o">
<rect key="frame" x="67.5" y="0.0" width="240" height="128"/>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="aqc-Px-Q6o" secondAttribute="bottom" id="TxC-s2-bYz"/>
<constraint firstItem="aqc-Px-Q6o" firstAttribute="centerX" secondItem="ZbH-UL-Efd" secondAttribute="centerX" id="Wcz-k7-Dpi"/>
<constraint firstItem="aqc-Px-Q6o" firstAttribute="top" secondItem="ZbH-UL-Efd" secondAttribute="top" id="z7N-4x-hCq"/>
</constraints>
</view>
</subviews>
<gestureRecognizers/>
<constraints>
<constraint firstItem="aqc-Px-Q6o" firstAttribute="width" secondItem="P5Q-KT-MGh" secondAttribute="width" id="Cx8-nh-UlJ"/>
<constraint firstItem="P5Q-KT-MGh" firstAttribute="height" secondItem="aqc-Px-Q6o" secondAttribute="height" id="efH-Av-RDb"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="M6f-Nq-Frc" appends="YES" id="3We-rQ-3Ug"/>
</connections>
</stackView>
</subviews>
<constraints>
<constraint firstItem="DfD-2w-NCY" firstAttribute="top" secondItem="zAY-rl-FzJ" secondAttribute="top" id="m5p-qy-9nQ"/>
<constraint firstAttribute="bottom" secondItem="DfD-2w-NCY" secondAttribute="bottom" id="nuF-Sc-n62"/>
<constraint firstItem="DfD-2w-NCY" firstAttribute="leading" secondItem="zAY-rl-FzJ" secondAttribute="leading" id="qRl-mV-Z6G"/>
<constraint firstAttribute="trailing" secondItem="DfD-2w-NCY" secondAttribute="trailing" id="ugG-N0-s52"/>
</constraints>
</scrollView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kkc-sL-6Tw">
<rect key="frame" x="0.0" y="482.5" width="375" height="135.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wvv-YL-UbN">
<rect key="frame" x="131.5" y="76.5" width="1" height="48"/>
<color key="backgroundColor" white="0.80000000000000004" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="LmL-Ir-p41"/>
<constraint firstAttribute="width" constant="1" id="MV8-Uo-wCe"/>
</constraints>
</view>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="3" translatesAutoresizingMaskIntoConstraints="NO" id="mow-gN-Jql">
<rect key="frame" x="6" y="85.5" width="363" height="31"/>
<connections>
<action selector="sliderChangedWithSlider:" destination="BYZ-38-t0r" eventType="valueChanged" id="184-6n-FUZ"/>
</connections>
</slider>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dPp-EI-EPd">
<rect key="frame" x="92" y="8" width="45" height="45"/>
<constraints>
<constraint firstAttribute="height" constant="45" id="nfE-Ll-WyX"/>
<constraint firstAttribute="width" constant="45" id="wOR-j8-4DX"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="+"/>
<connections>
<action selector="xPlusTapped" destination="BYZ-38-t0r" eventType="touchUpInside" id="CKI-0w-rXD"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pom-Zb-FA3">
<rect key="frame" x="8" y="6" width="48" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="48" id="H9Z-XH-SmP"/>
<constraint firstAttribute="height" constant="48" id="Hwe-ps-XCP"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="-"/>
<connections>
<action selector="xMinusTapped" destination="BYZ-38-t0r" eventType="touchUpInside" id="Bob-w5-jEc"/>
</connections>
</button>
<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">
<rect key="frame" x="64" y="16" width="20" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="uut-UM-ggc"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FBw-7N-Tqf">
<rect key="frame" x="322" y="7.5" width="45" height="45"/>
<constraints>
<constraint firstAttribute="height" constant="45" id="Iu5-fu-LZz"/>
<constraint firstAttribute="width" constant="45" id="cPQ-7l-vlO"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="+"/>
<connections>
<action selector="yPlusTapped" destination="BYZ-38-t0r" eventType="touchUpInside" id="KWL-2p-PkF"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="n4J-R9-MNF">
<rect key="frame" x="238" y="6.5" width="48" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="Gdx-xs-RnS"/>
<constraint firstAttribute="width" constant="48" id="i3f-l7-X41"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="27"/>
<state key="normal" title="-"/>
<connections>
<action selector="yMinusTapped" destination="BYZ-38-t0r" eventType="touchUpInside" id="BbN-cf-MYR"/>
</connections>
</button>
<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">
<rect key="frame" x="294" y="16" width="20" height="29"/>
<constraints>
<constraint firstAttribute="width" constant="20" id="Luy-k4-843"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="wvv-YL-UbN" firstAttribute="centerX" secondItem="mow-gN-Jql" secondAttribute="centerX" multiplier="0.666" constant="8" id="4vg-Id-oX7"/>
<constraint firstItem="pom-Zb-FA3" firstAttribute="leading" secondItem="Kkc-sL-6Tw" secondAttribute="leadingMargin" id="70B-84-eVj"/>
<constraint firstItem="FBw-7N-Tqf" firstAttribute="trailing" secondItem="Kkc-sL-6Tw" secondAttribute="trailingMargin" id="CC1-NS-k3Y"/>
<constraint firstItem="Sjj-Ih-5FV" firstAttribute="baseline" secondItem="FBw-7N-Tqf" secondAttribute="baseline" id="HfQ-2j-0zT"/>
<constraint firstItem="nzK-83-4if" firstAttribute="baseline" secondItem="pom-Zb-FA3" secondAttribute="baseline" id="Mev-Dk-0c9"/>
<constraint firstItem="mow-gN-Jql" firstAttribute="leading" secondItem="Kkc-sL-6Tw" secondAttribute="leadingMargin" id="TFC-Dm-vNM"/>
<constraint firstItem="nzK-83-4if" firstAttribute="leading" secondItem="pom-Zb-FA3" secondAttribute="trailing" constant="8" id="V7W-aw-bbd"/>
<constraint firstItem="mow-gN-Jql" firstAttribute="trailing" secondItem="Kkc-sL-6Tw" secondAttribute="trailingMargin" id="Xbw-Sb-YNg"/>
<constraint firstItem="nzK-83-4if" firstAttribute="baseline" secondItem="dPp-EI-EPd" secondAttribute="baseline" id="Xzb-gN-PpM"/>
<constraint firstItem="wvv-YL-UbN" firstAttribute="centerY" secondItem="mow-gN-Jql" secondAttribute="centerY" id="bXJ-Ni-buf"/>
<constraint firstAttribute="bottom" secondItem="mow-gN-Jql" secondAttribute="bottom" constant="20" id="dmn-M8-d5e"/>
<constraint firstItem="nzK-83-4if" firstAttribute="baseline" secondItem="Sjj-Ih-5FV" secondAttribute="baseline" id="eOD-6x-tQJ"/>
<constraint firstItem="dPp-EI-EPd" firstAttribute="leading" secondItem="nzK-83-4if" secondAttribute="trailing" constant="8" id="gE7-s6-0TE"/>
<constraint firstItem="mow-gN-Jql" firstAttribute="top" secondItem="nzK-83-4if" secondAttribute="bottom" constant="40" id="gZa-ha-f2r"/>
<constraint firstItem="FBw-7N-Tqf" firstAttribute="leading" secondItem="Sjj-Ih-5FV" secondAttribute="trailing" constant="8" id="n9q-fF-QMT"/>
<constraint firstItem="Sjj-Ih-5FV" firstAttribute="leading" secondItem="n4J-R9-MNF" secondAttribute="trailing" constant="8" id="nQr-Wv-PN4"/>
<constraint firstItem="nzK-83-4if" firstAttribute="top" secondItem="Kkc-sL-6Tw" secondAttribute="top" constant="16" id="rSn-r5-FKR"/>
<constraint firstItem="Sjj-Ih-5FV" firstAttribute="baseline" secondItem="n4J-R9-MNF" secondAttribute="baseline" id="vf3-Bt-KPp"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="zAY-rl-FzJ" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="5Qk-p5-GK5"/>
<constraint firstItem="Kkc-sL-6Tw" firstAttribute="top" secondItem="zAY-rl-FzJ" secondAttribute="bottom" id="Aov-rD-aIH"/>
<constraint firstItem="zAY-rl-FzJ" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="Nm2-ev-6n6"/>
<constraint firstAttribute="trailing" secondItem="zAY-rl-FzJ" secondAttribute="trailing" id="Rwb-RE-vFn"/>
<constraint firstAttribute="trailing" secondItem="Kkc-sL-6Tw" secondAttribute="trailing" id="f1K-FM-fsH"/>
<constraint firstItem="DfD-2w-NCY" firstAttribute="width" secondItem="8bC-Xf-vdC" secondAttribute="width" id="hVX-hx-CcD"/>
<constraint firstItem="Kkc-sL-6Tw" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="oca-zB-JTc"/>
<constraint firstItem="wEW-By-gXh" firstAttribute="top" secondItem="Kkc-sL-6Tw" secondAttribute="bottom" id="rhI-oy-Qcu"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Simple" id="9Iu-DR-LXv"/>
<connections>
<outlet property="blurImageView" destination="aqc-Px-Q6o" id="vFe-RW-vBc"/>
<outlet property="hashLabel" destination="tub-3a-hqA" id="w7D-xQ-9Qn"/>
<outlet property="originalImageView" destination="P5Q-KT-MGh" id="oK0-BN-PK3"/>
<outlet property="xComponentsLabel" destination="nzK-83-4if" id="DLz-x8-yNz"/>
<outlet property="yComponentsLabel" destination="Sjj-Ih-5FV" id="k0G-pQ-GQq"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
<tapGestureRecognizer id="M6f-Nq-Frc">
<connections>
<action selector="imageTapped" destination="BYZ-38-t0r" id="Hhv-Mr-j4m"/>
</connections>
</tapGestureRecognizer>
</objects>
<point key="canvasLocation" x="198" y="-576"/>
</scene>
<!--Generated-->
<scene sceneID="NOY-B9-bA2">
<objects>
<viewController id="ieU-Ur-ANQ" customClass="GeneratedViewController" customModule="BlurHashTest" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="jrB-Vn-KjF"/>
<viewControllerLayoutGuide type="bottom" id="U20-p6-Vfo"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="9Ht-Zj-35m">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OiX-cZ-DuB">
<rect key="frame" x="0.0" y="0.0" width="375" height="570"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="nI3-Nb-BBU">
<rect key="frame" x="0.0" y="0.0" width="375" height="481.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zMO-tx-PSM">
<rect key="frame" x="0.0" y="0.0" width="375" height="118"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="7DP-rI-WZI">
<rect key="frame" x="16" y="0.0" width="343" height="118"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nBd-Uw-V1a">
<rect key="frame" x="0.0" y="44.5" width="29.5" height="29"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="nBd-Uw-V1a" secondAttribute="height" id="koh-wr-pN0"/>
</constraints>
</view>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="uJQ-pG-3ne">
<rect key="frame" x="45.5" y="0.0" width="118" height="118"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="uJQ-pG-3ne" secondAttribute="height" id="xSV-S2-Pmt"/>
</constraints>
<connections>
<outletCollection property="gestureRecognizers" destination="nbx-vo-oxi" appends="YES" id="x5F-rP-aMR"/>
</connections>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nTn-FV-dGN">
<rect key="frame" x="179.5" y="44" width="29.5" height="30"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="nTn-FV-dGN" secondAttribute="height" multiplier="1:1" id="Z1A-19-2wx"/>
</constraints>
</view>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0Lz-yC-ahj">
<rect key="frame" x="225" y="0.0" width="118" height="118"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="0Lz-yC-ahj" secondAttribute="height" id="b2d-S7-DZf"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint firstItem="nTn-FV-dGN" firstAttribute="width" secondItem="0Lz-yC-ahj" secondAttribute="width" multiplier="1:4" id="Hbz-aW-UOd"/>
<constraint firstItem="0Lz-yC-ahj" firstAttribute="width" secondItem="uJQ-pG-3ne" secondAttribute="width" id="Wyc-8k-rsK"/>
<constraint firstItem="nBd-Uw-V1a" firstAttribute="width" secondItem="uJQ-pG-3ne" secondAttribute="width" multiplier="1:4" id="gDE-Vo-RZl"/>
<constraint firstAttribute="height" secondItem="uJQ-pG-3ne" secondAttribute="height" id="rGP-ny-WRW"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="7DP-rI-WZI" secondAttribute="trailing" constant="16" id="CcK-dH-GBi"/>
<constraint firstItem="7DP-rI-WZI" firstAttribute="leading" secondItem="zMO-tx-PSM" secondAttribute="leading" constant="16" id="OWm-Uv-wxO"/>
<constraint firstAttribute="bottom" secondItem="7DP-rI-WZI" secondAttribute="bottom" id="rMA-yQ-UHp"/>
<constraint firstItem="7DP-rI-WZI" firstAttribute="top" secondItem="zMO-tx-PSM" secondAttribute="top" id="tSA-fF-y5d"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="OXi-in-RbQ">
<rect key="frame" x="0.0" y="134" width="375" height="16"/>
<subviews>
<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">
<rect key="frame" x="16" y="0.0" width="343" height="16"/>
<fontDescription key="fontDescription" name="Courier" family="Courier" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="oJ9-fc-rpC" secondAttribute="bottom" id="75l-Fa-Pwq"/>
<constraint firstItem="oJ9-fc-rpC" firstAttribute="top" secondItem="OXi-in-RbQ" secondAttribute="top" id="OBq-7z-oNI"/>
<constraint firstItem="oJ9-fc-rpC" firstAttribute="leading" secondItem="OXi-in-RbQ" secondAttribute="leading" constant="16" id="XcM-n7-fZ2"/>
<constraint firstAttribute="trailing" secondItem="oJ9-fc-rpC" secondAttribute="trailing" constant="16" id="mEa-MV-qjO"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zml-8h-D7V">
<rect key="frame" x="0.0" y="166" width="375" height="118"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="iOO-51-zGo">
<rect key="frame" x="16" y="0.0" width="343" height="118"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="lds-gs-sJ2">
<rect key="frame" x="0.0" y="0.0" width="29.5" height="118"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qvi-2F-PxB">
<rect key="frame" x="0.0" y="0.0" width="29.5" height="29.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="qvi-2F-PxB" secondAttribute="height" id="gzn-ch-ZaO"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="te0-f2-YUl">
<rect key="frame" x="0.0" y="88.5" width="29.5" height="29.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="te0-f2-YUl" secondAttribute="height" id="GSS-gs-1E8"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="te0-f2-YUl" secondAttribute="trailing" id="8xO-JJ-MHF"/>
<constraint firstItem="te0-f2-YUl" firstAttribute="leading" secondItem="lds-gs-sJ2" secondAttribute="leading" id="PLu-12-Zoa"/>
<constraint firstItem="qvi-2F-PxB" firstAttribute="top" secondItem="lds-gs-sJ2" secondAttribute="top" id="bhi-Mf-ZmS"/>
<constraint firstAttribute="trailing" secondItem="qvi-2F-PxB" secondAttribute="trailing" id="dUf-ma-RWp"/>
<constraint firstItem="qvi-2F-PxB" firstAttribute="leading" secondItem="lds-gs-sJ2" secondAttribute="leading" id="w58-8c-vvC"/>
<constraint firstAttribute="bottom" secondItem="te0-f2-YUl" secondAttribute="bottom" id="z23-LA-q1J"/>
</constraints>
</view>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="1z6-Mz-QyS">
<rect key="frame" x="45.5" y="0.0" width="118" height="118"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="1z6-Mz-QyS" secondAttribute="height" id="BA1-Kw-Or5"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZI8-Og-CKj">
<rect key="frame" x="179.5" y="0.0" width="29.5" height="118"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xzE-aB-s59">
<rect key="frame" x="225" y="0.0" width="118" height="118"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="xzE-aB-s59" secondAttribute="height" id="Bmb-kk-81B"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint firstItem="ZI8-Og-CKj" firstAttribute="width" secondItem="xzE-aB-s59" secondAttribute="width" multiplier="1:4" id="4bj-v3-0ob"/>
<constraint firstItem="ZI8-Og-CKj" firstAttribute="height" secondItem="iOO-51-zGo" secondAttribute="height" id="KKe-q6-V2l"/>
<constraint firstAttribute="height" secondItem="1z6-Mz-QyS" secondAttribute="height" id="SWD-x6-XQf"/>
<constraint firstItem="lds-gs-sJ2" firstAttribute="height" secondItem="iOO-51-zGo" secondAttribute="height" id="TWf-2v-8sh"/>
<constraint firstItem="lds-gs-sJ2" firstAttribute="width" secondItem="1z6-Mz-QyS" secondAttribute="width" multiplier="1:4" id="oVv-NO-fYW"/>
<constraint firstItem="xzE-aB-s59" firstAttribute="width" secondItem="1z6-Mz-QyS" secondAttribute="width" id="uhW-36-G23"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="iOO-51-zGo" firstAttribute="leading" secondItem="zml-8h-D7V" secondAttribute="leading" constant="16" id="g96-Gz-X5i"/>
<constraint firstAttribute="bottom" secondItem="iOO-51-zGo" secondAttribute="bottom" id="uMQ-yd-JEb"/>
<constraint firstItem="iOO-51-zGo" firstAttribute="top" secondItem="zml-8h-D7V" secondAttribute="top" id="xtp-V1-8b4"/>
<constraint firstAttribute="trailing" secondItem="iOO-51-zGo" secondAttribute="trailing" constant="16" id="y5G-jm-BRM"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HOn-we-vW1">
<rect key="frame" x="0.0" y="300" width="375" height="16"/>
<subviews>
<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">
<rect key="frame" x="16" y="0.0" width="343" height="16"/>
<fontDescription key="fontDescription" name="Courier" family="Courier" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="ODR-OG-Qrx" firstAttribute="top" secondItem="HOn-we-vW1" secondAttribute="top" id="0l6-EJ-G0x"/>
<constraint firstAttribute="bottom" secondItem="ODR-OG-Qrx" secondAttribute="bottom" id="HYb-qG-tJC"/>
<constraint firstItem="ODR-OG-Qrx" firstAttribute="leading" secondItem="HOn-we-vW1" secondAttribute="leading" constant="16" id="UjN-8W-Frh"/>
<constraint firstAttribute="trailing" secondItem="ODR-OG-Qrx" secondAttribute="trailing" constant="16" id="x0z-lz-3l4"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RO2-Tp-p9h">
<rect key="frame" x="0.0" y="332" width="375" height="117.5"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="QEz-V4-8bE">
<rect key="frame" x="16" y="0.0" width="343" height="117.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="P8F-48-18L">
<rect key="frame" x="0.0" y="0.0" width="30" height="117.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gMu-7g-yMT">
<rect key="frame" x="0.0" y="0.0" width="30" height="30"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="gMu-7g-yMT" secondAttribute="height" id="IxH-LG-fHS"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="coh-ki-69y">
<rect key="frame" x="0.0" y="87.5" width="30" height="30"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="coh-ki-69y" secondAttribute="height" id="mxU-tr-TWD"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="coh-ki-69y" firstAttribute="leading" secondItem="P8F-48-18L" secondAttribute="leading" id="4xn-aT-DrO"/>
<constraint firstItem="gMu-7g-yMT" firstAttribute="leading" secondItem="P8F-48-18L" secondAttribute="leading" id="8ht-Ed-glO"/>
<constraint firstAttribute="bottom" secondItem="coh-ki-69y" secondAttribute="bottom" id="GvK-Yf-Glh"/>
<constraint firstItem="gMu-7g-yMT" firstAttribute="top" secondItem="P8F-48-18L" secondAttribute="top" id="fH2-U8-HpM"/>
<constraint firstAttribute="trailing" secondItem="gMu-7g-yMT" secondAttribute="trailing" id="o5w-Ho-3cq"/>
<constraint firstAttribute="trailing" secondItem="coh-ki-69y" secondAttribute="trailing" id="qyC-mz-Ww5"/>
</constraints>
</view>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="f9s-eI-MLC">
<rect key="frame" x="46" y="0.0" width="117.5" height="117.5"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="f9s-eI-MLC" secondAttribute="height" id="lp3-Kc-m1P"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="foN-P7-xvH">
<rect key="frame" x="179.5" y="0.0" width="29.5" height="117.5"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FNG-mj-Vnw">
<rect key="frame" x="0.0" y="0.0" width="29.5" height="29.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="FNG-mj-Vnw" secondAttribute="height" id="rXX-mT-vFX"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NGt-FT-U7U">
<rect key="frame" x="0.0" y="88" width="29.5" height="29.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" secondItem="NGt-FT-U7U" secondAttribute="height" id="2qK-N7-bUe"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="FNG-mj-Vnw" secondAttribute="trailing" id="35f-Oh-Z0X"/>
<constraint firstItem="FNG-mj-Vnw" firstAttribute="leading" secondItem="foN-P7-xvH" secondAttribute="leading" id="Hdv-BU-6fl"/>
<constraint firstAttribute="bottom" secondItem="NGt-FT-U7U" secondAttribute="bottom" id="JxH-DV-QNB"/>
<constraint firstAttribute="trailing" secondItem="NGt-FT-U7U" secondAttribute="trailing" id="Z7K-Pd-HgP"/>
<constraint firstItem="FNG-mj-Vnw" firstAttribute="top" secondItem="foN-P7-xvH" secondAttribute="top" id="hIv-bG-JhV"/>
<constraint firstItem="NGt-FT-U7U" firstAttribute="leading" secondItem="foN-P7-xvH" secondAttribute="leading" id="nNg-C6-faM"/>
</constraints>
</view>
<imageView contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="HCU-rK-iSi">
<rect key="frame" x="225" y="0.0" width="118" height="117.5"/>
<gestureRecognizers/>
<constraints>
<constraint firstAttribute="width" secondItem="HCU-rK-iSi" secondAttribute="height" id="fyV-48-BI4"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint firstItem="foN-P7-xvH" firstAttribute="width" secondItem="HCU-rK-iSi" secondAttribute="width" multiplier="1:4" id="2mP-B7-9Ng"/>
<constraint firstItem="HCU-rK-iSi" firstAttribute="width" secondItem="f9s-eI-MLC" secondAttribute="width" id="Rhg-QH-6rn"/>
<constraint firstAttribute="height" secondItem="f9s-eI-MLC" secondAttribute="height" id="hmT-we-EIh"/>
<constraint firstItem="foN-P7-xvH" firstAttribute="height" secondItem="QEz-V4-8bE" secondAttribute="height" id="i3W-To-jis"/>
<constraint firstItem="P8F-48-18L" firstAttribute="height" secondItem="QEz-V4-8bE" secondAttribute="height" id="lng-VS-o5r"/>
<constraint firstItem="P8F-48-18L" firstAttribute="width" secondItem="f9s-eI-MLC" secondAttribute="width" multiplier="1:4" id="tX2-bu-MgL"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="QEz-V4-8bE" secondAttribute="bottom" id="LyO-JQ-tY7"/>
<constraint firstItem="QEz-V4-8bE" firstAttribute="top" secondItem="RO2-Tp-p9h" secondAttribute="top" id="WDI-lG-DdS"/>
<constraint firstAttribute="trailing" secondItem="QEz-V4-8bE" secondAttribute="trailing" constant="16" id="bIG-zK-Xtl"/>
<constraint firstItem="QEz-V4-8bE" firstAttribute="leading" secondItem="RO2-Tp-p9h" secondAttribute="leading" constant="16" id="llz-Ia-h5O"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U76-Ud-6N8">
<rect key="frame" x="0.0" y="465.5" width="375" height="16"/>
<subviews>
<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">
<rect key="frame" x="16" y="0.0" width="343" height="16"/>
<fontDescription key="fontDescription" name="Courier" family="Courier" pointSize="16"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="fEF-Tp-CJy" secondAttribute="trailing" constant="16" id="2nF-AN-e0T"/>
<constraint firstAttribute="bottom" secondItem="fEF-Tp-CJy" secondAttribute="bottom" id="NHU-qD-xqp"/>
<constraint firstItem="fEF-Tp-CJy" firstAttribute="leading" secondItem="U76-Ud-6N8" secondAttribute="leading" constant="16" id="Xp0-Qi-Vr1"/>
<constraint firstItem="fEF-Tp-CJy" firstAttribute="top" secondItem="U76-Ud-6N8" secondAttribute="top" id="hyR-MI-8h5"/>
</constraints>
</view>
</subviews>
</stackView>
</subviews>
<constraints>
<constraint firstItem="nI3-Nb-BBU" firstAttribute="width" secondItem="OiX-cZ-DuB" secondAttribute="width" id="084-VX-nrj"/>
<constraint firstItem="nI3-Nb-BBU" firstAttribute="leading" secondItem="OiX-cZ-DuB" secondAttribute="leading" id="9w4-ej-NRk"/>
<constraint firstItem="nI3-Nb-BBU" firstAttribute="top" secondItem="OiX-cZ-DuB" secondAttribute="top" id="A4B-jG-ucL"/>
<constraint firstAttribute="trailing" secondItem="nI3-Nb-BBU" secondAttribute="trailing" id="cck-ss-aa6"/>
<constraint firstAttribute="bottom" secondItem="nI3-Nb-BBU" secondAttribute="bottom" id="yCB-tR-Zdn"/>
</constraints>
</scrollView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Rqx-x4-v7Z">
<rect key="frame" x="0.0" y="570" width="375" height="48"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gFD-tb-P7p">
<rect key="frame" x="0.0" y="0.0" width="375" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="tTy-bV-PG7"/>
</constraints>
<state key="normal" title="Randomise"/>
<connections>
<action selector="randomiseTapped" destination="ieU-Ur-ANQ" eventType="touchUpInside" id="wHF-5D-wL9"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="gFD-tb-P7p" firstAttribute="top" secondItem="Rqx-x4-v7Z" secondAttribute="top" id="Y2d-hA-CPb"/>
<constraint firstAttribute="trailing" secondItem="gFD-tb-P7p" secondAttribute="trailing" id="tqF-rr-C6R"/>
<constraint firstItem="gFD-tb-P7p" firstAttribute="leading" secondItem="Rqx-x4-v7Z" secondAttribute="leading" id="yCR-eL-cvk"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="OiX-cZ-DuB" firstAttribute="leading" secondItem="9Ht-Zj-35m" secondAttribute="leading" id="1Yw-wB-kjU"/>
<constraint firstAttribute="trailing" secondItem="Rqx-x4-v7Z" secondAttribute="trailing" id="Bfc-eo-dyt"/>
<constraint firstItem="U20-p6-Vfo" firstAttribute="top" secondItem="gFD-tb-P7p" secondAttribute="bottom" id="BpF-t3-HVn"/>
<constraint firstItem="U20-p6-Vfo" firstAttribute="top" secondItem="Rqx-x4-v7Z" secondAttribute="bottom" id="CoA-ef-IGa"/>
<constraint firstItem="OiX-cZ-DuB" firstAttribute="top" secondItem="9Ht-Zj-35m" secondAttribute="top" id="PXm-Nk-9KM"/>
<constraint firstItem="Rqx-x4-v7Z" firstAttribute="leading" secondItem="9Ht-Zj-35m" secondAttribute="leading" id="bOi-bw-nc9"/>
<constraint firstAttribute="trailing" secondItem="OiX-cZ-DuB" secondAttribute="trailing" id="l3L-ta-qKW"/>
<constraint firstItem="Rqx-x4-v7Z" firstAttribute="top" secondItem="OiX-cZ-DuB" secondAttribute="bottom" id="lxS-4p-8WQ"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Generated" id="8sH-aA-Ohl"/>
<connections>
<outlet property="cornerBottomLeftView" destination="coh-ki-69y" id="DHw-cF-rpi"/>
<outlet property="cornerBottomRightView" destination="NGt-FT-U7U" id="CxX-vB-Fmb"/>
<outlet property="cornerCompressedImageView" destination="HCU-rK-iSi" id="XV0-Tz-RlQ"/>
<outlet property="cornerHashLabel" destination="fEF-Tp-CJy" id="uDh-GQ-zt3"/>
<outlet property="cornerTopLeftView" destination="gMu-7g-yMT" id="fO2-Rm-NYB"/>
<outlet property="cornerTopRightView" destination="FNG-mj-Vnw" id="1NB-ul-NWG"/>
<outlet property="cornerUncompressedImageView" destination="f9s-eI-MLC" id="ySq-Pg-u8e"/>
<outlet property="horizontalCompressedImageView" destination="0Lz-yC-ahj" id="4kU-Vr-xhO"/>
<outlet property="horizontalHashLabel" destination="oJ9-fc-rpC" id="gyz-92-BN7"/>
<outlet property="horizontalLeftView" destination="nBd-Uw-V1a" id="Nqk-Tc-nlm"/>
<outlet property="horizontalRightView" destination="nTn-FV-dGN" id="PQF-rD-Znn"/>
<outlet property="horizontalUncompressedImageView" destination="uJQ-pG-3ne" id="uJw-Yu-YlR"/>
<outlet property="verticalBottomView" destination="te0-f2-YUl" id="x8S-tt-4QF"/>
<outlet property="verticalCompressedImageView" destination="xzE-aB-s59" id="CDD-5m-Jtt"/>
<outlet property="verticalHashLabel" destination="ODR-OG-Qrx" id="iLI-w2-lB7"/>
<outlet property="verticalTopView" destination="qvi-2F-PxB" id="xlJ-fn-3yO"/>
<outlet property="verticalUncompressedImageView" destination="1z6-Mz-QyS" id="18k-gC-Rd9"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="EVj-kF-JnH" userLabel="First Responder" sceneMemberID="firstResponder"/>
<tapGestureRecognizer id="nbx-vo-oxi"/>
</objects>
<point key="canvasLocation" x="197.59999999999999" y="903.59820089955031"/>
</scene>
</scenes>
</document>

View File

@ -1,122 +0,0 @@
import UIKit
import BlurHashKit
class GeneratedViewController: UIViewController {
@IBOutlet weak var horizontalUncompressedImageView: UIImageView?
@IBOutlet weak var horizontalCompressedImageView: UIImageView?
@IBOutlet weak var horizontalLeftView: UIView?
@IBOutlet weak var horizontalRightView: UIView?
@IBOutlet weak var horizontalHashLabel: UILabel?
@IBOutlet weak var verticalUncompressedImageView: UIImageView?
@IBOutlet weak var verticalCompressedImageView: UIImageView?
@IBOutlet weak var verticalTopView: UIView?
@IBOutlet weak var verticalBottomView: UIView?
@IBOutlet weak var verticalHashLabel: UILabel?
@IBOutlet weak var cornerUncompressedImageView: UIImageView?
@IBOutlet weak var cornerCompressedImageView: UIImageView?
@IBOutlet weak var cornerTopLeftView: UIView?
@IBOutlet weak var cornerTopRightView: UIView?
@IBOutlet weak var cornerBottomLeftView: UIView?
@IBOutlet weak var cornerBottomRightView: UIView?
@IBOutlet weak var cornerHashLabel: UILabel?
/* private var horizontalLeftColour = UIColor.red
private var horizontalRightColour = UIColor.green
private var verticalTopColour = UIColor.white
private var verticalBottomColour = UIColor.black
private var cornerTopLeftColour = UIColor.white
private var cornerTopRightColour = UIColor.red
private var cornerBottomLeftColour = UIColor.green
private var cornerBottomRightColour = UIColor.black
*/
private var horizontalLeftColour = UIColor.white
private var horizontalRightColour = UIColor.black
private var verticalTopColour = UIColor.white
private var verticalBottomColour = UIColor.black
private var cornerTopLeftColour = UIColor.white
private var cornerTopRightColour = UIColor.black
private var cornerBottomLeftColour = UIColor.black
private var cornerBottomRightColour = UIColor.white
override func viewDidLoad() {
super.viewDidLoad()
horizontalLeftView?.layer.borderWidth = 1
horizontalLeftView?.layer.borderColor = UIColor.black.cgColor
horizontalRightView?.layer.borderWidth = 1
horizontalRightView?.layer.borderColor = UIColor.black.cgColor
verticalTopView?.layer.borderWidth = 1
verticalTopView?.layer.borderColor = UIColor.black.cgColor
verticalBottomView?.layer.borderWidth = 1
verticalBottomView?.layer.borderColor = UIColor.black.cgColor
cornerTopLeftView?.layer.borderWidth = 1
cornerTopLeftView?.layer.borderColor = UIColor.black.cgColor
cornerTopRightView?.layer.borderWidth = 1
cornerTopRightView?.layer.borderColor = UIColor.black.cgColor
cornerBottomLeftView?.layer.borderWidth = 1
cornerBottomLeftView?.layer.borderColor = UIColor.black.cgColor
cornerBottomRightView?.layer.borderWidth = 1
cornerBottomRightView?.layer.borderColor = UIColor.black.cgColor
update()
}
@IBAction func randomiseTapped() {
horizontalLeftColour = .random()
horizontalRightColour = .random()
verticalTopColour = .random()
verticalBottomColour = .random()
cornerTopLeftColour = .random()
cornerTopRightColour = .random()
cornerBottomLeftColour = .random()
cornerBottomRightColour = .random()
update()
}
func update() {
horizontalLeftView?.backgroundColor = horizontalLeftColour
horizontalRightView?.backgroundColor = horizontalRightColour
verticalTopView?.backgroundColor = verticalTopColour
verticalBottomView?.backgroundColor = verticalBottomColour
cornerTopLeftView?.backgroundColor = cornerTopLeftColour
cornerTopRightView?.backgroundColor = cornerTopRightColour
cornerBottomLeftView?.backgroundColor = cornerBottomLeftColour
cornerBottomRightView?.backgroundColor = cornerBottomRightColour
let horizontalBlurHash = BlurHash(horizontalGradientFrom: horizontalLeftColour, to: horizontalRightColour)
horizontalUncompressedImageView?.image = horizontalBlurHash.image(size: CGSize(width: 32, height: 32))
horizontalCompressedImageView?.image = BlurHash(string: horizontalBlurHash.string)?.image(size: CGSize(width: 32, height: 32))
horizontalHashLabel?.text = horizontalBlurHash.string
let verticalBlurHash = BlurHash(verticalGradientFrom: verticalTopColour, to: verticalBottomColour)
verticalUncompressedImageView?.image = verticalBlurHash.image(size: CGSize(width: 32, height: 32))
verticalCompressedImageView?.image = BlurHash(string: verticalBlurHash.string)?.image(size: CGSize(width: 32, height: 32))
verticalHashLabel?.text = verticalBlurHash.string
let cornerBlurHash = BlurHash(blendingTopLeft: cornerTopLeftColour, topRight: cornerTopRightColour, bottomLeft: cornerBottomLeftColour, bottomRight: cornerBottomRightColour)
cornerUncompressedImageView?.image = cornerBlurHash.image(size: CGSize(width: 32, height: 32))
cornerCompressedImageView?.image = BlurHash(string: cornerBlurHash.string)?.image(size: CGSize(width: 32, height: 32))
cornerHashLabel?.text = cornerBlurHash.string
}
}
extension UIColor {
static func random() -> UIColor {
let hue = CGFloat(arc4random()) / CGFloat(UInt32.max)
let brightness = CGFloat(arc4random()) / CGFloat(UInt32.max)
if brightness < 0.5 {
return UIColor(hue: hue, saturation: 1, brightness: brightness * 2, alpha: 1)
} else {
return UIColor(hue: hue, saturation: 2 - brightness * 2, brightness: 1, alpha: 1)
}
}
}

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@ -1,88 +0,0 @@
import UIKit
class SimpleViewController: UIViewController {
@IBOutlet weak var originalImageView: UIImageView?
@IBOutlet weak var hashLabel: UILabel?
@IBOutlet weak var blurImageView: UIImageView?
@IBOutlet weak var xComponentsLabel: UILabel?
@IBOutlet weak var yComponentsLabel: UILabel?
let images: [UIImage] = [
UIImage(named: "pic2.png")!,
UIImage(named: "pic1.png")!,
UIImage(named: "pic3.png")!,
UIImage(named: "pic6.png")!,
]
var imageIndex: Int = 0
var xComponents: Int = 4
var yComponents: Int = 3
var blurHash: String = ""
var punch: Float = 1
override func viewDidLoad() {
super.viewDidLoad()
updateEncode()
updateDecode()
}
@IBAction func imageTapped() {
imageIndex = (imageIndex + 1) % images.count
updateEncode()
updateDecode()
}
@IBAction func xPlusTapped() {
if xComponents < 8 {
xComponents += 1
updateEncode()
updateDecode()
}
}
@IBAction func xMinusTapped() {
if xComponents > 1 {
xComponents -= 1
updateEncode()
updateDecode()
}
}
@IBAction func yPlusTapped() {
if yComponents < 8 {
yComponents += 1
updateEncode()
updateDecode()
}
}
@IBAction func yMinusTapped() {
if yComponents > 1 {
yComponents -= 1
updateEncode()
updateDecode()
}
}
@IBAction func sliderChanged(slider: UISlider) {
punch = slider.value
updateDecode()
}
func updateEncode() {
originalImageView?.image = images[imageIndex]
blurHash = images[imageIndex].blurHash(numberOfComponents: (xComponents, yComponents))!
hashLabel?.text = blurHash
xComponentsLabel?.text = String(xComponents)
yComponentsLabel?.text = String(yComponents)
}
func updateDecode() {
let blurImage = UIImage(blurHash: blurHash, size: CGSize(width: 32, height: 32), punch: punch)
blurImageView?.image = blurImage
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

View File

@ -1,19 +0,0 @@
Copyright (c) 2018 Wolt Enterprises
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,45 +0,0 @@
# BlurHash for iOS, in Swift
## Standalone decoder and encoder
[BlurHashDecode.swift](BlurHashDecode.swift) and [BlurHashEncode.swift](BlurHashEncode.swift) contain a decoder
and encoder for BlurHash to and from `UIImage`. Both files are completeiy standalone, and can simply be copied into your
project directly.
### Decoding
[BlurHashDecode.swift](BlurHashDecode.swift) implements the following extension on `UIImage`:
public convenience init?(blurHash: String, size: CGSize, punch: Float = 1)
This creates a UIImage containing the placeholder image decoded from the BlurHash string, or returns nil if decoding failed.
The parameters are:
* `blurHash` - A string containing the BlurHash.
* `size` - The requested output size. You should keep this small, and let UIKit scale it up for you. 32 pixels wide is plenty.
* `punch` - Adjusts the contrast of the output image. Tweak it if you want a different look for your placeholders.
### Encoding
[BlurHashEncode.swift](BlurHashEncode.swift) implements the following extension on `UIImage`:
public func blurHash(numberOfComponents components: (Int, Int)) -> String?
This returns a string containing the BlurHash for the image, or nil if the image was in a weird format that is not supported.
The parameters are:
* `numberOfComponents` - a Tuple of integers specifying the number of components in the X and Y directions. Both must be
between 1 and 9 inclusive, or the function will return nil. 3 to 5 is usually a good range.
## BlurHashKit
This is a more advanced library, currently in development. It will let you do more advanced operations using BlurHashes,
such testing whether various parts of an image are dark and light, or generating BlurHashes as gradients from corner colours.
It is currently not documented or finalised, but feel free to look into the different files and what they implement, or look at
how it is used by the test app.
## BlurHashTest.app
This is a simple test app that shows how to use the various pieces of BlurHash functionality, and lets you play with the
algorithm.

View File

@ -1,2 +0,0 @@
node_modules/
dist/

View File

@ -1,3 +0,0 @@
tsconfig.json
src
demo

View File

@ -1,9 +0,0 @@
{
"printWidth": 80,
"overrides": [
{
"files": ["*.ts"],
"options": {}
}
]
}

View File

@ -1,10 +0,0 @@
# Changelog
## 1.1.2 (June 29, 2019)
- added `isBlurhashValid()` utility
## 1.1.1 (June 29, 2019)
- fixed incorrect type declaration path in package.json
- improved error handling

View File

@ -1,78 +0,0 @@
# blurhash
[![NPM Version](https://img.shields.io/npm/v/blurhash.svg?style=flat)](https://npmjs.org/package/blurhash)
[![NPM Downloads](https://img.shields.io/npm/dm/blurhash.svg?style=flat)](https://npmjs.org/package/blurhash)
> JavaScript encoder and decoder for the [Wolt BlurHash](https://github.com/woltapp/blurhash) algorithm
## Install
```sh
npm install --save blurhash
```
See [react-blurhash](https://github.com/woltapp/react-blurhash) to use blurhash with React.
## API
### `decode(blurhash: string, width: number, height: number, punch?: number) => Uint8ClampedArray`
> Decodes a blurhash string to pixels
#### Example
```js
import { decode } from "blurhash";
const pixels = decode("LEHV6nWB2yk8pyo0adR*.7kCMdnj", 32, 32);
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
const imageData = ctx.createImageData(width, height);
imageData.data.set(pixels);
ctx.putImageData(imageData, 0, 0);
document.body.append(canvas);
```
### `encode(pixels: Uint8ClampedArray, width: number, height: number, componentX: number, componentY: number) => string`
> Encodes pixels to a blurhash string
```js
import { encode } from "blurhash";
const loadImage = async src =>
new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = (...args) => reject(args);
img.src = src;
});
const getImageData = image => {
const canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
const context = canvas.getContext("2d");
context.drawImage(image, 0, 0);
return context.getImageData(0, 0, image.width, image.height);
};
const encodeImageToBlurhash = async imageUrl => {
const image = await loadImage(imageUrl);
const imageData = getImageData(image);
return encode(imageData.data, imageData.width, imageData.height, 4, 4);
};
```
### `isBlurhashValid(blurhash: string) => { result: boolean; errorReason?: string }`
```js
import { isBlurhashValid } from "blurhash";
const validRes = isBlurhashValid("LEHV6nWB2yk8pyo0adR*.7kCMdnj");
// { result: true }
const invalidRes = isBlurhashValid("???");
// { result: false, errorReason: "The blurhash string must be at least 6 characters" }
```

View File

@ -1,74 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Blurhash test file</title>
<style>
* {
box-sizing: border-box;
}
.wrapper {
display: flex;
align-items: flex-start;
}
.blurhashWrapper {
padding: 0 20px;
}
canvas {
display: block;
width: 632px;
height: 356px;
background: #ccc;
}
#blurhash {
margin-top: 20px;
font-size: 24px;
width: 632px;
}
label {
display: block;
padding: 10px 0;
}
label > span {
display: inline-block;
width: 100px;
}
</style>
</head>
<body>
<h1>BlurHash demo</h1>
<div class="wrapper">
<div>
<h2>Encode</h2>
<canvas id="original" width="100" height="100"></canvas>
<label>
<span>File:</span>
<input id="fileinput" type="file" accept="image/*" />
</label>
<label>
<span>Components</span>
<input type="number" id="x" value="4" min="1" max="9" />
×
<input type="number" id="y" value="3" min="1" max="9" />
</label>
</div>
<div class="blurhashWrapper">
<h2>Blurhash</h2>
<input id="blurhash" type="text" value="" />
</div>
<div>
<h2>Decode</h2>
<canvas id="canvas" width="32" height="32"></canvas>
</div>
</div>
<script src="./demo.js"></script>
</body>
</html>

View File

@ -1,37 +0,0 @@
{
"name": "blurhash",
"version": "1.1.3",
"description": "Encoder and decoder for the Wolt BlurHash algorithm.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/woltapp/blurhash/tree/master/TypeScript"
},
"homepage": "http://blurhash.com",
"scripts": {
"prepublishOnly": "npm run build",
"build": "npm run ts",
"demo": "webpack-dev-server --mode development",
"prettier": "prettier src/**/*.ts",
"prettier-fix": "npm run prettier -- --write",
"ts": "tsc",
"ts:watch": "npm run ts -- --noEmit --watch"
},
"keywords": [
"blurhash",
"blur",
"hash",
"image"
],
"author": "omahlama",
"license": "MIT",
"devDependencies": {
"prettier": "1.18.2",
"ts-loader": "6.0.4",
"typescript": "3.5.3",
"webpack": "4.38.0",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "3.7.2"
}
}

View File

@ -1,104 +0,0 @@
const digitCharacters = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"#",
"$",
"%",
"*",
"+",
",",
"-",
".",
":",
";",
"=",
"?",
"@",
"[",
"]",
"^",
"_",
"{",
"|",
"}",
"~"
];
export const decode83 = (str: String) => {
let value = 0;
for (let i = 0; i < str.length; i++) {
const c = str[i];
const digit = digitCharacters.indexOf(c);
value = value * 83 + digit;
}
return value;
};
export const encode83 = (n: number, length: number): string => {
var result = "";
for (let i = 1; i <= length; i++) {
let digit = (Math.floor(n) / Math.pow(83, length - i)) % 83;
result += digitCharacters[Math.floor(digit)];
}
return result;
};

View File

@ -1,125 +0,0 @@
import { decode83 } from "./base83";
import { sRGBToLinear, signPow, linearTosRGB } from "./utils";
import { ValidationError } from "./error";
/**
* Returns an error message if invalid or undefined if valid
* @param blurhash
*/
const validateBlurhash = (blurhash: string) => {
if (!blurhash || blurhash.length < 6) {
throw new ValidationError(
"The blurhash string must be at least 6 characters"
);
}
const sizeFlag = decode83(blurhash[0]);
const numY = Math.floor(sizeFlag / 9) + 1;
const numX = (sizeFlag % 9) + 1;
if (blurhash.length !== 4 + 2 * numX * numY) {
throw new ValidationError(
`blurhash length mismatch: length is ${
blurhash.length
} but it should be ${4 + 2 * numX * numY}`
);
}
};
export const isBlurhashValid = (
blurhash: string
): { result: boolean; errorReason?: string } => {
try {
validateBlurhash(blurhash);
} catch (error) {
return { result: false, errorReason: error.message };
}
return { result: true };
};
const decodeDC = (value: number) => {
const intR = value >> 16;
const intG = (value >> 8) & 255;
const intB = value & 255;
return [sRGBToLinear(intR), sRGBToLinear(intG), sRGBToLinear(intB)];
};
const decodeAC = (value: number, maximumValue: number) => {
const quantR = Math.floor(value / (19 * 19));
const quantG = Math.floor(value / 19) % 19;
const quantB = value % 19;
const rgb = [
signPow((quantR - 9) / 9, 2.0) * maximumValue,
signPow((quantG - 9) / 9, 2.0) * maximumValue,
signPow((quantB - 9) / 9, 2.0) * maximumValue
];
return rgb;
};
const decode = (
blurhash: string,
width: number,
height: number,
punch?: number
) => {
validateBlurhash(blurhash);
punch = punch | 1;
const sizeFlag = decode83(blurhash[0]);
const numY = Math.floor(sizeFlag / 9) + 1;
const numX = (sizeFlag % 9) + 1;
const quantisedMaximumValue = decode83(blurhash[1]);
const maximumValue = (quantisedMaximumValue + 1) / 166;
const colors = new Array(numX * numY);
for (let i = 0; i < colors.length; i++) {
if (i === 0) {
const value = decode83(blurhash.substring(2, 6));
colors[i] = decodeDC(value);
} else {
const value = decode83(blurhash.substring(4 + i * 2, 6 + i * 2));
colors[i] = decodeAC(value, maximumValue * punch);
}
}
const bytesPerRow = width * 4;
const pixels = new Uint8ClampedArray(bytesPerRow * height);
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
let r = 0;
let g = 0;
let b = 0;
for (let j = 0; j < numY; j++) {
for (let i = 0; i < numX; i++) {
const basis =
Math.cos((Math.PI * x * i) / width) *
Math.cos((Math.PI * y * j) / height);
let color = colors[i + j * numX];
r += color[0] * basis;
g += color[1] * basis;
b += color[2] * basis;
}
}
let intR = linearTosRGB(r);
let intG = linearTosRGB(g);
let intB = linearTosRGB(b);
pixels[4 * x + 0 + y * bytesPerRow] = intR;
pixels[4 * x + 1 + y * bytesPerRow] = intG;
pixels[4 * x + 2 + y * bytesPerRow] = intB;
pixels[4 * x + 3 + y * bytesPerRow] = 255; // alpha
}
}
return pixels;
};
export default decode;

View File

@ -1,66 +0,0 @@
import decode from "./decode";
import encode from "./encode";
const blurhashElement = document.getElementById("blurhash") as HTMLInputElement;
const canvas = document.getElementById("canvas") as HTMLCanvasElement;
const originalCanvas = document.getElementById("original") as HTMLCanvasElement;
const fileInput = document.getElementById("fileinput") as HTMLInputElement;
const componentXElement = document.getElementById("x") as HTMLInputElement;
const componentYElement = document.getElementById("y") as HTMLInputElement;
function render() {
const blurhash = blurhashElement.value;
if (blurhash) {
const pixels = decode(blurhash, 32, 32);
if (pixels) {
const ctx = canvas.getContext("2d");
const imageData = new ImageData(pixels, 32, 32);
ctx.putImageData(imageData, 0, 0);
}
}
}
function clamp(n: number) {
return Math.min(9, Math.max(1, n));
}
function doEncode() {
const file = fileInput.files[0];
const componentX = clamp(+componentXElement.value);
const componentY = clamp(+componentYElement.value);
if (file) {
const ctx = originalCanvas.getContext("2d");
var img = new Image();
img.onload = function() {
ctx.drawImage(img, 0, 0, originalCanvas.width, originalCanvas.height);
URL.revokeObjectURL(img.src);
setTimeout(() => {
const imageData = ctx.getImageData(
0,
0,
originalCanvas.width,
originalCanvas.height
);
const blurhash = encode(
imageData.data,
imageData.width,
imageData.height,
componentX,
componentY
);
blurhashElement.value = blurhash;
render();
}, 0);
};
img.src = URL.createObjectURL(fileInput.files[0]);
}
}
blurhashElement.addEventListener("keyup", render);
fileInput.addEventListener("change", doEncode);
componentXElement.addEventListener("change", doEncode);
componentYElement.addEventListener("change", doEncode);
render();

Some files were not shown because too many files have changed in this diff Show More