mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
1217 lines
55 KiB
C
1217 lines
55 KiB
C
// Copyright 2024 The Wuffs Authors.
|
||
//
|
||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
|
||
// option. This file may not be copied, modified, or distributed
|
||
// except according to those terms.
|
||
//
|
||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||
|
||
// ----------------
|
||
|
||
/*
|
||
stb-imagedumper decodes images, printing them (as ANSI color codes) to stdout.
|
||
|
||
It demonstrates using the STB Image API (e.g. stbi_load and stbi_image_free)
|
||
with either the actual STB Image implementation or Wuffs' reimplementation. By
|
||
default, it uses Wuffs' reimplementation. Define the USE_THE_REAL_STBI macro to
|
||
use the actual STB Image implementation instead: the stb_image.h file from
|
||
https://github.com/nothings/stb
|
||
|
||
The STB Image API is simple, covering the basic "decode this image data (as a
|
||
file, as bytes, etc) as RGB pixels" need. Wuffs also has its own API. Two, in
|
||
fact: a higher-level C++ one and a lower-level C one.
|
||
|
||
Wuffs' C++ API is also a one-shot "decode an image, synchronously" API but also
|
||
gives the caller access to metadata (e.g. EXIF orientation, color profiles),
|
||
more control over destination pixel formats (e.g. RGB versus BGR byte order,
|
||
premultiplied versus non-premultiplied alpha) and over memory allocators (e.g.
|
||
early rejection of malicious "1 zillion pixel wide × 1 zillion pixel high"
|
||
images attempting Denial of Service by exhausting the available memory).
|
||
|
||
Wuffs' C API provides all of that (since the C++ API is implemented using the C
|
||
API) but also supports multi-shot streaming (asynchronous) I/O and animated
|
||
(not just still, single-frame) images. This lower-level C API is also capable
|
||
of running in a very restrictive sandbox (Linux's SECCOMP_MODE_STRICT).
|
||
|
||
See example/convert-to-nia and example/imageviewer in the Wuffs repository for
|
||
examples of using its C and C++ APIs.
|
||
|
||
Coming back to this program, pass the -demo flag to decode six versions of the
|
||
same image of the Mona Lisa, in Thumbhash, Handsum (q=0), Handsum (q=3),
|
||
PKM/ETC2, JPEG and PNG formats. Only the last one is lossless.
|
||
|
||
As of April 2026, the actual STB Image implementation only decodes two out of
|
||
six: JPEG and PNG. Wuffs' reimplementation decodes all six demo images.
|
||
|
||
Define the DECODE_ONLY_JPEG macro to limit the variety of image file formats
|
||
that Wuffs decodes to just JPEG, for smaller binaries and faster compiles.
|
||
|
||
Pass the -resize=N flag (or -r as an abbreviation of -resize=64) to resize each
|
||
image to fit within an N×N square (while preserving the aspect ratio).
|
||
|
||
Pass the -a or -ascii-art flag to print ASCII art instead of ANSI color codes.
|
||
|
||
Pass the -b or -braille-art-light-mode (for black text on a white background)
|
||
or -B or -braille-art-dark-mode (for white text on a black background) flag to
|
||
print Unicode Braille Pattern characters instead of ANSI color codes. For
|
||
example:
|
||
|
||
----
|
||
$ stb-imagedumper -braille-art-light-mode test/data/pjw-thumbnail.png
|
||
|
||
test/data/pjw-thumbnail.png (208 bytes, 164 microseconds)
|
||
⠀⠀⠀⠀⢀⢴⣶⣶⣶⣦⣄⡀⠀⠀⠀⠀
|
||
⠀⠀⠀⢀⠈⠀⠀⠀⠹⣯⣿⣿⣷⣆⠀⠀
|
||
⠀⠀⣼⡇⢀⡀⠀⠀⠀⣙⣿⣿⣿⣿⡃⠀
|
||
⠀⢾⣿⢿⠔⠾⢞⠺⡿⣿⣿⣿⣿⣿⠂⠀
|
||
⠀⠈⢛⠅⠠⠔⣂⣀⣳⡮⣮⣿⣿⠉⠀⠀
|
||
⠀⠀⠸⡄⠠⠤⠤⠽⣿⡾⡾⣿⣿⠀⠀⠀
|
||
⠀⠀⠀⠀⠐⡂⠉⠛⣹⣷⣟⡓⠂⠀⠀⠀
|
||
⠀⠀⠀⠀⠈⢖⢽⣿⣿⣿⣿⠁⠀⠀⠀⠀
|
||
----
|
||
|
||
To run:
|
||
|
||
$CC stb-imagedumper.c && ./a.out *.{jpeg,png}; rm -f a.out
|
||
|
||
for a C compiler $CC, such as clang or gcc.
|
||
*/
|
||
|
||
#include <inttypes.h>
|
||
#include <stdbool.h>
|
||
#include <stdio.h>
|
||
|
||
#if defined(USE_THE_REAL_STBI)
|
||
|
||
#define STBI_NO_HDR
|
||
#define STBI_NO_LINEAR
|
||
#define STB_IMAGE_IMPLEMENTATION
|
||
#include "/path/to/your/copy/of/github.com/nothings/stb/stb_image.h"
|
||
|
||
#else // defined(USE_THE_REAL_STBI)
|
||
|
||
// Wuffs ships as a "single file C library" or "header file library" as per
|
||
// https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
|
||
//
|
||
// To use that single file as a "foo.c"-like implementation, instead of a
|
||
// "foo.h"-like header, #define WUFFS_IMPLEMENTATION before #include'ing or
|
||
// compiling it.
|
||
#define WUFFS_IMPLEMENTATION
|
||
|
||
// Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when
|
||
// combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs'
|
||
// functions have static storage.
|
||
//
|
||
// This can help the compiler ignore or discard unused code, which can produce
|
||
// faster compiles and smaller binaries. Other motivations are discussed in the
|
||
// "ALLOW STATIC IMPLEMENTATION" section of
|
||
// https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt
|
||
#define WUFFS_CONFIG__STATIC_FUNCTIONS
|
||
|
||
// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of
|
||
// release/c/etc.c choose which parts of Wuffs to build. That file contains the
|
||
// entire Wuffs standard library, implementing a variety of codecs and file
|
||
// formats. Without this macro definition, an optimizing compiler or linker may
|
||
// very well discard Wuffs code for unused codecs, but listing the Wuffs
|
||
// modules we use makes that process explicit. Preprocessing means that such
|
||
// code simply isn't compiled.
|
||
#define WUFFS_CONFIG__MODULES
|
||
#define WUFFS_CONFIG__MODULE__BASE
|
||
#define WUFFS_CONFIG__MODULE__JPEG
|
||
#if !defined(DECODE_ONLY_JPEG)
|
||
#define WUFFS_CONFIG__MODULE__ADLER32
|
||
#define WUFFS_CONFIG__MODULE__BMP
|
||
#define WUFFS_CONFIG__MODULE__CRC32
|
||
#define WUFFS_CONFIG__MODULE__DEFLATE
|
||
#define WUFFS_CONFIG__MODULE__ETC2
|
||
#define WUFFS_CONFIG__MODULE__GIF
|
||
#define WUFFS_CONFIG__MODULE__HANDSUM
|
||
#define WUFFS_CONFIG__MODULE__NETPBM
|
||
#define WUFFS_CONFIG__MODULE__NIE
|
||
#define WUFFS_CONFIG__MODULE__PNG
|
||
#define WUFFS_CONFIG__MODULE__QOI
|
||
#define WUFFS_CONFIG__MODULE__TARGA
|
||
#define WUFFS_CONFIG__MODULE__THUMBHASH
|
||
#define WUFFS_CONFIG__MODULE__VP8
|
||
#define WUFFS_CONFIG__MODULE__WBMP
|
||
#define WUFFS_CONFIG__MODULE__WEBP
|
||
#define WUFFS_CONFIG__MODULE__ZLIB
|
||
#endif
|
||
|
||
// Defining the WUFFS_CONFIG__DST_PIXEL_FORMAT__ENABLE_ALLOWLIST (and the
|
||
// associated ETC__ALLOW_FOO) macros are optional, but can lead to smaller
|
||
// programs (in terms of binary size). By default (without these macros),
|
||
// Wuffs' standard library can decode images to a variety of pixel formats,
|
||
// such as BGR_565, BGRA_PREMUL or RGBA_NONPREMUL. The destination pixel format
|
||
// is selectable at runtime. Using these macros essentially makes the selection
|
||
// at compile time, by narrowing the list of supported destination pixel
|
||
// formats. The FOO in ETC__ALLOW_FOO should match the pixel format passed (as
|
||
// part of the wuffs_base__image_config argument) to the decode_frame method.
|
||
//
|
||
// If using the wuffs_aux C++ API, without overriding the SelectPixfmt method,
|
||
// the implicit destination pixel format is BGRA_PREMUL.
|
||
//
|
||
// ----
|
||
//
|
||
// This program uses the STB API, not the wuffs_aux C++ API. We only ever pass
|
||
// 1 (STBI_grey) or 4 (STBI_rgb_alpha), not 0, 2 or 3, as the desired_channels
|
||
// argument to stbi_load_etc functions, so we only need ALLOW_Y and
|
||
// ALLOW_RGBA_NONPREMUL.
|
||
#define WUFFS_CONFIG__DST_PIXEL_FORMAT__ENABLE_ALLOWLIST
|
||
#define WUFFS_CONFIG__DST_PIXEL_FORMAT__ALLOW_Y
|
||
#define WUFFS_CONFIG__DST_PIXEL_FORMAT__ALLOW_RGBA_NONPREMUL
|
||
|
||
// Defining this enables Wuffs' reimplementation of the STB library's API.
|
||
#define WUFFS_CONFIG__ENABLE_DROP_IN_REPLACEMENT__STB
|
||
|
||
// If building this program in an environment that doesn't easily accommodate
|
||
// relative includes, you can use the script/inline-c-relative-includes.go
|
||
// program to generate a stand-alone C file.
|
||
#include "../../release/c/wuffs-unsupported-snapshot.c"
|
||
|
||
#define PARSE_COLOR_CONFIG__STATIC_FUNCTIONS
|
||
#define PARSE_COLOR_IMPLEMENTATION
|
||
#include "../../snippet/parse-color.c"
|
||
|
||
#endif // defined(USE_THE_REAL_STBI)
|
||
|
||
// ----------------
|
||
|
||
#if defined(__unix__) || defined(__MACH__)
|
||
|
||
#include <sys/stat.h>
|
||
#include <time.h>
|
||
|
||
#define WUFFS_EXAMPLE_USE_TIMERS
|
||
|
||
uint64_t //
|
||
get_filesize(const char* filename) {
|
||
struct stat z;
|
||
if (stat(filename, &z) == 0) {
|
||
return z.st_size;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
bool g_started = false;
|
||
struct timespec g_start_time = {0};
|
||
|
||
int64_t //
|
||
micros_since_start(struct timespec* now) {
|
||
if (!g_started) {
|
||
return 0;
|
||
}
|
||
int64_t nanos = (int64_t)(now->tv_sec - g_start_time.tv_sec) * 1000000000 +
|
||
(int64_t)(now->tv_nsec - g_start_time.tv_nsec);
|
||
if (nanos < 0) {
|
||
return 0;
|
||
}
|
||
return nanos / 1000;
|
||
}
|
||
|
||
#else // defined(__unix__) || defined(__MACH__)
|
||
|
||
#warning "TODO: stat and timers on non-POSIX systems"
|
||
|
||
uint64_t //
|
||
get_filesize(const char* filename) {
|
||
return 0;
|
||
}
|
||
|
||
#endif // defined(__unix__) || defined(__MACH__)
|
||
|
||
// ----------------
|
||
|
||
const uint8_t g_src_ptr__mona_lisa_21_32_th[] = {
|
||
0xc3, 0xbe, 0xfe, 0xd1, 0x18, 0x0a, 0x1d, 0x02, 0x78, 0x95, 0x7f, 0x88,
|
||
0x87, 0x88, 0x87, 0x88, 0x77, 0x87, 0x47, 0x49, 0x7f, 0xa6, 0x02, 0x17,
|
||
};
|
||
const size_t g_src_len__mona_lisa_21_32_th = 24;
|
||
|
||
const uint8_t g_src_ptr__mona_lisa_21_32_c3q1_handsum[] = {
|
||
0xfe, 0xd7, 0x1a, 0x76, 0x8b, 0x9a, 0x76, 0x58, 0x88, 0x99, 0x68, 0xb6,
|
||
0x79, 0xaa, 0xa6, 0x86, 0x99, 0x97, 0x63, 0x7b, 0x89, 0x98, 0xb9, 0x59,
|
||
0x79, 0x28, 0xb8, 0x88, 0x8a, 0x89, 0x8a, 0x99, 0x98, 0x77, 0x94, 0x98,
|
||
0x79, 0x88, 0x88, 0x88, 0x97, 0x79, 0x87, 0x77, 0x88, 0x88, 0x88, 0x98,
|
||
};
|
||
const size_t g_src_len__mona_lisa_21_32_c3q1_handsum = 48;
|
||
|
||
const uint8_t g_src_ptr__mona_lisa_21_32_c3q4_handsum[] = {
|
||
0xfe, 0xd7, 0x7a, 0x87, 0x76, 0x68, 0x87, 0x75, 0x89, 0x77, 0x8c, 0xb7,
|
||
0xc7, 0x9b, 0x78, 0x64, 0x5a, 0x98, 0xb4, 0x79, 0xe6, 0x75, 0x57, 0x8a,
|
||
0x84, 0x88, 0x03, 0x86, 0x7a, 0x68, 0x87, 0x76, 0x68, 0xf4, 0x55, 0xe2,
|
||
0x68, 0x9a, 0x89, 0xf4, 0x3b, 0x94, 0x75, 0x6a, 0xb8, 0xf8, 0x32, 0x68,
|
||
0x55, 0x6a, 0x78, 0x55, 0x48, 0xac, 0x53, 0x6b, 0xf6, 0x93, 0x3b, 0x78,
|
||
0x83, 0x25, 0x99, 0x92, 0x29, 0xb6, 0x66, 0x6a, 0x9a, 0x81, 0x19, 0x97,
|
||
0x92, 0x2c, 0xb9, 0xd5, 0x3f, 0x88, 0x82, 0x48, 0xa6, 0x91, 0x19, 0x98,
|
||
0x71, 0x38, 0x96, 0xa3, 0x26, 0x79, 0x81, 0x29, 0x97, 0x91, 0x1a, 0x98,
|
||
0x81, 0x19, 0x97, 0x95, 0x58, 0xbb, 0x86, 0x57, 0x98, 0x96, 0x5a, 0x9e,
|
||
0x26, 0x6c, 0x99, 0x87, 0x76, 0x4a, 0x78, 0x84, 0x6a, 0xa9, 0x67, 0x08,
|
||
0x78, 0x94, 0x88, 0x88, 0x97, 0x45, 0xa8, 0x86, 0x78, 0x89, 0xa5, 0x85,
|
||
0xba, 0x86, 0x58, 0x8a, 0x9a, 0xa8, 0x89, 0x9a, 0xa7, 0x79, 0xa9, 0xc8,
|
||
0x99, 0x8b, 0x87,
|
||
};
|
||
const size_t g_src_len__mona_lisa_21_32_c3q4_handsum = 147;
|
||
|
||
const uint8_t g_src_ptr__mona_lisa_21_32_etc2_pkm[] = {
|
||
0x50, 0x4b, 0x4d, 0x20, 0x32, 0x30, 0x00, 0x01, 0x00, 0x18, 0x00, 0x20,
|
||
0x00, 0x15, 0x00, 0x20, 0xb2, 0x74, 0x15, 0x32, 0x74, 0x8c, 0xb3, 0x18,
|
||
0xae, 0x70, 0x14, 0xaf, 0x70, 0x84, 0xf3, 0x58, 0xbb, 0xf2, 0x29, 0x92,
|
||
0x88, 0x80, 0x99, 0x1b, 0x63, 0x72, 0x42, 0x0b, 0x51, 0x19, 0x33, 0x2a,
|
||
0xac, 0x70, 0x15, 0x2f, 0x78, 0x9c, 0xf3, 0x18, 0xae, 0x72, 0x15, 0xaf,
|
||
0x72, 0x9c, 0xf3, 0xd9, 0x97, 0x97, 0x65, 0x09, 0x99, 0x9f, 0xe6, 0x09,
|
||
0x96, 0x94, 0x65, 0x4e, 0xe8, 0x08, 0xc3, 0x48, 0xb8, 0x96, 0x43, 0x70,
|
||
0x71, 0x99, 0x12, 0x23, 0x37, 0x27, 0x25, 0x6c, 0x8c, 0xe7, 0x2d, 0x11,
|
||
0x8a, 0x91, 0x60, 0x66, 0xf1, 0x0c, 0x0c, 0x08, 0x96, 0x9e, 0x60, 0x07,
|
||
0x99, 0x99, 0x22, 0x22, 0x42, 0x42, 0x31, 0x22, 0xcc, 0x8e, 0xd9, 0x19,
|
||
0x57, 0x54, 0x3e, 0x2a, 0xe2, 0x67, 0xd8, 0x80, 0xb7, 0x85, 0x42, 0x71,
|
||
0xfa, 0xa8, 0xa1, 0x69, 0x24, 0x14, 0x23, 0x08, 0x0f, 0xf0, 0x1e, 0x0b,
|
||
0x44, 0x06, 0xa2, 0xa2, 0xee, 0xef, 0x18, 0x96, 0x66, 0x6d, 0x56, 0x27,
|
||
0x22, 0x22, 0x33, 0x33, 0x53, 0x48, 0x3e, 0x27, 0x00, 0xdf, 0xd6, 0x01,
|
||
0x0c, 0x22, 0x76, 0x4b, 0x41, 0x5f, 0xc1, 0x46, 0x8d, 0x6b, 0x35, 0x85,
|
||
0x11, 0x17, 0x2a, 0xe9, 0x99, 0x05, 0x42, 0x93, 0x88, 0x8f, 0xa7, 0x91,
|
||
0x6f, 0x66, 0x46, 0x2f, 0x30, 0x9f, 0xc6, 0xdb, 0x63, 0x5a, 0x48, 0x07,
|
||
0x66, 0x66, 0xcc, 0xcc, 0x42, 0x15, 0xa9, 0x9a, 0xc0, 0x4f, 0x35, 0x36,
|
||
0xf3, 0x84, 0x42, 0x27, 0xcd, 0xfe, 0x22, 0x11, 0xb4, 0x93, 0x52, 0x85,
|
||
0xe2, 0x2a, 0xe1, 0x56, 0x15, 0x63, 0x32, 0x27, 0x32, 0xee, 0xdd, 0x1c,
|
||
0x25, 0x13, 0x23, 0x24, 0x0f, 0x0b, 0x3c, 0x04, 0x14, 0x64, 0x64, 0x43,
|
||
0xee, 0xee, 0x44, 0x44, 0x48, 0x3f, 0x30, 0x27, 0x7e, 0xe8, 0xb6, 0xd0,
|
||
0x33, 0x22, 0x28, 0x2f, 0x77, 0x44, 0x4c, 0x03, 0x36, 0x27, 0x28, 0x22,
|
||
0xfc, 0xcc, 0x89, 0x90, 0x05, 0x12, 0x21, 0x23, 0xf0, 0x20, 0x11, 0x10,
|
||
0x21, 0x19, 0x29, 0x02, 0x8c, 0xef, 0x38, 0xcb, 0x07, 0x34, 0x54, 0x43,
|
||
0x77, 0x77, 0x77, 0x77, 0x36, 0x27, 0x30, 0x43, 0xee, 0xf8, 0xd4, 0xcc,
|
||
0x5a, 0x37, 0x23, 0x6c, 0xc6, 0x2f, 0x93, 0x94, 0x96, 0x63, 0x32, 0x50,
|
||
0xb1, 0x98, 0x13, 0xbb, 0xa9, 0x15, 0x10, 0x92, 0xb9, 0x99, 0x57, 0x33,
|
||
0x27, 0x1f, 0x36, 0x03, 0x08, 0xdf, 0xd0, 0xab, 0x32, 0x28, 0x3f, 0x03,
|
||
0xee, 0xee, 0x00, 0x00, 0x8e, 0x90, 0x0d, 0x0f, 0x0e, 0x40, 0x81, 0x09,
|
||
0xb1, 0x15, 0x10, 0x92, 0xee, 0xef, 0xdc, 0xce, 0x34, 0x1e, 0x27, 0x23,
|
||
0xfe, 0x20, 0x62, 0x1c, 0x8a, 0x88, 0x07, 0x87, 0x06, 0x30, 0x40, 0x86,
|
||
0x0a, 0x01, 0x18, 0x02, 0xcc, 0xc4, 0x33, 0x10, 0x98, 0x9a, 0x0d, 0x9a,
|
||
0x1a, 0x58, 0x60, 0x47,
|
||
};
|
||
const size_t g_src_len__mona_lisa_21_32_etc2_pkm = 400;
|
||
|
||
const uint8_t g_src_ptr__mona_lisa_21_32_q90_lossy_webp[] = {
|
||
0x52, 0x49, 0x46, 0x46, 0xe2, 0x01, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50,
|
||
0x56, 0x50, 0x38, 0x20, 0xd6, 0x01, 0x00, 0x00, 0xd0, 0x09, 0x00, 0x9d,
|
||
0x01, 0x2a, 0x15, 0x00, 0x20, 0x00, 0x3e, 0x31, 0x14, 0x88, 0x42, 0xa2,
|
||
0x21, 0x21, 0x18, 0x04, 0x00, 0x20, 0x03, 0x04, 0xb6, 0x00, 0x4e, 0x99,
|
||
0x42, 0x3f, 0x1b, 0xd5, 0x78, 0x42, 0x5c, 0xae, 0x00, 0x1b, 0x60, 0x39,
|
||
0xea, 0xb4, 0xd9, 0xb7, 0x97, 0x26, 0x13, 0xfd, 0x43, 0x18, 0x07, 0x8f,
|
||
0x74, 0xad, 0xad, 0x41, 0x4c, 0xa7, 0xc7, 0x62, 0x04, 0x89, 0x18, 0xdb,
|
||
0x50, 0x71, 0x72, 0xeb, 0x5a, 0xf3, 0x8c, 0x59, 0x60, 0x61, 0x45, 0x47,
|
||
0xc9, 0x94, 0x1c, 0xcb, 0x6e, 0x72, 0x8c, 0x37, 0x2e, 0x5a, 0x40, 0x00,
|
||
0xfe, 0x27, 0x6f, 0x6a, 0xd7, 0x61, 0x77, 0x45, 0xb5, 0x74, 0x81, 0x0e,
|
||
0xb3, 0x86, 0x35, 0xc8, 0x16, 0x8c, 0xd7, 0xca, 0x34, 0xc3, 0xba, 0xb2,
|
||
0x0f, 0x6e, 0x22, 0x0e, 0x66, 0x81, 0x70, 0x63, 0xbf, 0x7c, 0x4f, 0xb1,
|
||
0xcd, 0x06, 0x6c, 0x18, 0x39, 0xc3, 0xf9, 0x3f, 0xdd, 0xb6, 0xe1, 0x33,
|
||
0xed, 0x55, 0xca, 0x5b, 0xb5, 0xba, 0xf2, 0x6d, 0xc6, 0x21, 0x00, 0x06,
|
||
0x43, 0xfd, 0x1d, 0xd9, 0xa3, 0x6f, 0x95, 0x2d, 0xb8, 0x07, 0xe7, 0x59,
|
||
0x76, 0x95, 0x0b, 0xfb, 0xf9, 0xff, 0xa7, 0x6e, 0xee, 0x6b, 0xe6, 0xd7,
|
||
0x8b, 0xa2, 0x27, 0x71, 0x19, 0xb2, 0x18, 0x2f, 0x73, 0x7d, 0xbc, 0xdc,
|
||
0x07, 0x6d, 0x99, 0x4d, 0xf7, 0xf0, 0xce, 0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
||
0xff, 0x3d, 0x01, 0xce, 0x68, 0x06, 0xc9, 0x67, 0x51, 0x5c, 0xc6, 0x2a,
|
||
0x06, 0x9d, 0xb7, 0xa4, 0xbe, 0x62, 0x7d, 0x6b, 0x4c, 0xe6, 0x29, 0x9f,
|
||
0xf2, 0x97, 0xaf, 0x19, 0x7b, 0x68, 0x15, 0xfd, 0xab, 0xe3, 0xba, 0xf6,
|
||
0xca, 0x7b, 0x30, 0x33, 0x88, 0x2e, 0x6a, 0x4d, 0xd9, 0xff, 0xec, 0x7b,
|
||
0x7b, 0x48, 0xe4, 0xdc, 0x19, 0x7e, 0xa9, 0x40, 0xd4, 0x27, 0x2d, 0xfd,
|
||
0x84, 0x55, 0xb5, 0xd0, 0x78, 0x15, 0xa9, 0x8e, 0xe7, 0xdc, 0x92, 0xac,
|
||
0x14, 0xaa, 0x35, 0x0b, 0xce, 0x01, 0xa2, 0xac, 0x8a, 0xe3, 0x9b, 0x48,
|
||
0xb5, 0x10, 0x6f, 0x77, 0x9d, 0xce, 0xda, 0x61, 0x69, 0x71, 0xdb, 0x69,
|
||
0xf0, 0x84, 0x36, 0x9a, 0x3e, 0x58, 0x52, 0xe0, 0x00, 0x00,
|
||
};
|
||
const size_t g_src_len__mona_lisa_21_32_q90_lossy_webp = 490;
|
||
|
||
const uint8_t g_src_ptr__mona_lisa_21_32_q50_jpeg[] = {
|
||
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
|
||
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x43,
|
||
0x00, 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 0x0d, 0x0e, 0x12,
|
||
0x11, 0x10, 0x13, 0x18, 0x28, 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23,
|
||
0x25, 0x1d, 0x28, 0x3a, 0x33, 0x3d, 0x3c, 0x39, 0x33, 0x38, 0x37, 0x40,
|
||
0x48, 0x5c, 0x4e, 0x40, 0x44, 0x57, 0x45, 0x37, 0x38, 0x50, 0x6d, 0x51,
|
||
0x57, 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 0x79, 0x70, 0x64,
|
||
0x78, 0x5c, 0x65, 0x67, 0x63, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x11, 0x12,
|
||
0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a, 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42,
|
||
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
|
||
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
|
||
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
|
||
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
|
||
0x63, 0x63, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x20, 0x00, 0x15, 0x03,
|
||
0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00,
|
||
0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00,
|
||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||
0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00,
|
||
0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00,
|
||
0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21,
|
||
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81,
|
||
0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24,
|
||
0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25,
|
||
0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a,
|
||
0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56,
|
||
0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
|
||
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86,
|
||
0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
|
||
0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3,
|
||
0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
|
||
0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
|
||
0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1,
|
||
0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00,
|
||
0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||
0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00,
|
||
0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00,
|
||
0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31,
|
||
0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08,
|
||
0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15,
|
||
0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18,
|
||
0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39,
|
||
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55,
|
||
0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
||
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84,
|
||
0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
|
||
0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa,
|
||
0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4,
|
||
0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
|
||
0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
|
||
0xf2, 0xf3, 0xf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x2c, 0x66, 0xdb,
|
||
0x11, 0x01, 0x88, 0xe7, 0xb1, 0xc5, 0x15, 0x46, 0x19, 0x80, 0x5e, 0x68,
|
||
0xab, 0x71, 0x42, 0x4d, 0x9f, 0xff, 0xd9,
|
||
};
|
||
const size_t g_src_len__mona_lisa_21_32_q50_jpeg = 799;
|
||
|
||
const uint8_t g_src_ptr__mona_lisa_21_32_png[] = {
|
||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x20,
|
||
0x08, 0x02, 0x00, 0x00, 0x00, 0x72, 0xc2, 0xa4, 0xdf, 0x00, 0x00, 0x06,
|
||
0x07, 0x49, 0x44, 0x41, 0x54, 0x38, 0x11, 0x05, 0xc1, 0x49, 0x6f, 0x1c,
|
||
0xc7, 0x15, 0x00, 0xe0, 0xf7, 0x5e, 0x55, 0x75, 0x4f, 0xcf, 0xc6, 0x19,
|
||
0x92, 0xe2, 0x2a, 0x79, 0xd3, 0x62, 0x51, 0x4b, 0x64, 0x05, 0x50, 0x60,
|
||
0x04, 0xc9, 0xd5, 0xc8, 0x21, 0x08, 0x92, 0x8b, 0x91, 0x6b, 0x72, 0x09,
|
||
0xf2, 0x07, 0xfc, 0x7b, 0x72, 0xcf, 0x3d, 0x97, 0x9c, 0x02, 0x23, 0x80,
|
||
0x01, 0x5b, 0xb6, 0xe1, 0x48, 0x72, 0x44, 0x59, 0x1c, 0x6e, 0xe2, 0x32,
|
||
0xe4, 0xec, 0x3d, 0xdd, 0x5d, 0x5d, 0xf5, 0xde, 0xf3, 0xf7, 0xe1, 0x5f,
|
||
0xbf, 0xf8, 0xa3, 0xb0, 0x17, 0x40, 0x00, 0x46, 0xa2, 0x10, 0x02, 0x21,
|
||
0x00, 0x9a, 0x06, 0x29, 0xa3, 0x51, 0xb4, 0x51, 0x18, 0xd5, 0x8b, 0x88,
|
||
0x04, 0x8e, 0x40, 0x8a, 0x46, 0xc9, 0x91, 0x31, 0x84, 0xce, 0x88, 0xd8,
|
||
0x1b, 0x2d, 0x65, 0x21, 0x16, 0x01, 0xb4, 0x28, 0x50, 0x13, 0x01, 0xaa,
|
||
0xb5, 0x64, 0x38, 0xa8, 0x73, 0xe8, 0x5c, 0xac, 0x09, 0x94, 0xc8, 0x19,
|
||
0x08, 0x8c, 0x28, 0xa0, 0xa0, 0x36, 0x33, 0x04, 0xc6, 0xa0, 0xd4, 0x62,
|
||
0x93, 0x24, 0x51, 0xb0, 0x48, 0xa0, 0xe0, 0x48, 0x23, 0xb0, 0x63, 0x15,
|
||
0x4b, 0x60, 0x4c, 0xc6, 0x62, 0x35, 0x30, 0x35, 0x9c, 0xb8, 0x86, 0xa2,
|
||
0xd5, 0xba, 0x04, 0x11, 0x40, 0x8b, 0x2e, 0x23, 0x14, 0x82, 0xa0, 0x36,
|
||
0xb5, 0x69, 0x23, 0x23, 0x10, 0x03, 0x41, 0x15, 0x10, 0x53, 0x6b, 0x33,
|
||
0xe1, 0xd2, 0xd8, 0x74, 0xbc, 0x7f, 0x74, 0xf5, 0x6a, 0x70, 0x32, 0x44,
|
||
0xaf, 0x74, 0xeb, 0xc1, 0xd6, 0x83, 0xdf, 0xdc, 0xab, 0x84, 0x54, 0x8c,
|
||
0x49, 0xb3, 0x94, 0x82, 0x35, 0xc4, 0x62, 0x04, 0x9d, 0xf9, 0xec, 0xb3,
|
||
0x5f, 0x34, 0x5b, 0x59, 0x9a, 0x38, 0x4b, 0xd4, 0x6c, 0x24, 0x96, 0xb0,
|
||
0xd9, 0x6e, 0xe7, 0x97, 0xcb, 0x7e, 0x7e, 0xfe, 0xeb, 0x5f, 0x6d, 0x43,
|
||
0xf4, 0x2f, 0x5e, 0x2f, 0xbf, 0xfd, 0xfa, 0xaa, 0xd7, 0x6f, 0xdc, 0x7e,
|
||
0xfc, 0x3e, 0x28, 0x35, 0xb3, 0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47, 0x73, 0xda, 0x58,
|
||
0xd1, 0x76, 0x2a, 0x77, 0xee, 0xd0, 0xe1, 0xb9, 0xbc, 0x5b, 0xf0, 0xa4,
|
||
0xe2, 0x1c, 0xdc, 0x52, 0x8c, 0xbd, 0xb3, 0x6b, 0x6e, 0xde, 0xee, 0xae,
|
||
0x74, 0xe0, 0xea, 0x9b, 0x52, 0x44, 0x03, 0x53, 0x5e, 0x19, 0x83, 0x72,
|
||
0x74, 0x16, 0x3a, 0x4d, 0xaa, 0x18, 0xf2, 0x82, 0x53, 0x87, 0x85, 0xd7,
|
||
0xb6, 0xd5, 0xd1, 0x54, 0x06, 0x57, 0xe8, 0x32, 0x43, 0xce, 0xe6, 0xe4,
|
||
0x3a, 0x4d, 0xb6, 0x11, 0xec, 0xfe, 0x69, 0x55, 0x56, 0xfc, 0xd3, 0x85,
|
||
0x6c, 0xf7, 0x60, 0x5e, 0x40, 0xe1, 0xd1, 0x10, 0x2a, 0x60, 0xea, 0x74,
|
||
0x96, 0xab, 0x08, 0x96, 0x51, 0xd6, 0xba, 0x34, 0xb8, 0x94, 0xeb, 0x89,
|
||
0x18, 0x24, 0x05, 0xac, 0x58, 0x4e, 0x66, 0xb2, 0x03, 0xc1, 0x86, 0x10,
|
||
0x4f, 0xa6, 0x3c, 0xc9, 0x35, 0x35, 0xe0, 0x90, 0x1b, 0xe8, 0xf3, 0xa0,
|
||
0x8c, 0x94, 0xa5, 0xea, 0x6b, 0x98, 0x2e, 0x04, 0x11, 0x91, 0x70, 0x5e,
|
||
0x70, 0x59, 0xe8, 0x9a, 0xc3, 0x5a, 0x58, 0x39, 0xb2, 0xb8, 0x2a, 0x00,
|
||
0x0b, 0xd9, 0x58, 0x87, 0xe9, 0x42, 0x33, 0x88, 0x1d, 0xa8, 0xeb, 0x4a,
|
||
0xa6, 0x0b, 0x98, 0xcc, 0x85, 0x8c, 0x36, 0x52, 0xf2, 0x15, 0x0a, 0x43,
|
||
0x50, 0x55, 0xc5, 0xdc, 0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
||
0x8e, 0xe7, 0x7c, 0x79, 0x5e, 0x6e, 0x18, 0xee, 0x18, 0xdf, 0xa6, 0xa8,
|
||
0x41, 0xad, 0xe8, 0x55, 0x09, 0x93, 0xa2, 0x06, 0x44, 0x50, 0x5d, 0x4f,
|
||
0xc5, 0x8e, 0x8b, 0x88, 0xc0, 0x99, 0x51, 0x2f, 0x7a, 0xa3, 0x09, 0x1f,
|
||
0xf5, 0x65, 0x25, 0xd3, 0xa3, 0x49, 0xdc, 0x1f, 0x94, 0x9b, 0xab, 0x26,
|
||
0x9f, 0xc7, 0xa3, 0xf3, 0x38, 0x18, 0x01, 0x1a, 0x1b, 0x19, 0x0a, 0x0f,
|
||
0x55, 0x88, 0x35, 0xa8, 0x33, 0x98, 0x99, 0x34, 0x25, 0xb0, 0xc8, 0x8c,
|
||
0xa0, 0x55, 0x10, 0x54, 0x2d, 0x6a, 0x7a, 0x79, 0x50, 0x5f, 0x4d, 0xea,
|
||
0xe7, 0x6f, 0x42, 0x14, 0xfd, 0xe9, 0x2c, 0x2e, 0x4b, 0x5e, 0x78, 0xbd,
|
||
0xcc, 0xb1, 0x12, 0x04, 0x04, 0x15, 0xf1, 0x2c, 0x89, 0xa1, 0x44, 0x99,
|
||
0x62, 0x18, 0x2f, 0xd1, 0x12, 0x6a, 0x64, 0x11, 0x95, 0xc4, 0xc0, 0xa2,
|
||
0x8a, 0xdf, 0x0f, 0x20, 0x39, 0x94, 0xa9, 0xd7, 0x66, 0xd3, 0x84, 0x52,
|
||
0xa7, 0xb9, 0x44, 0x01, 0x2f, 0xe0, 0x59, 0x22, 0x00, 0x01, 0x08, 0xa8,
|
||
0x57, 0xed, 0x82, 0x54, 0x21, 0x90, 0x31, 0x36, 0x44, 0xae, 0x63, 0x34,
|
||
0x04, 0x15, 0x6b, 0x93, 0x74, 0x54, 0x40, 0x1d, 0xc5, 0x22, 0x94, 0x75,
|
||
0x5c, 0x44, 0x28, 0x45, 0x83, 0xaa, 0x45, 0x15, 0x55, 0x51, 0x00, 0x50,
|
||
0x05, 0x60, 0x0e, 0x55, 0xcd, 0x0a, 0x84, 0x8a, 0x96, 0x05, 0x51, 0x91,
|
||
0x05, 0x53, 0x03, 0x68, 0xa0, 0x0c, 0x2a, 0x0a, 0x0d, 0x02, 0x05, 0x42,
|
||
0x54, 0x4b, 0x8a, 0xa0, 0x09, 0x68, 0x00, 0xf5, 0x0c, 0x04, 0x02, 0x00,
|
||
0x51, 0xa1, 0x62, 0x35, 0x08, 0x15, 0xc3, 0xcf, 0x54, 0x8f, 0x0d, 0x07,
|
||
0x3c, 0xd1, 0x0f, 0x66, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
|
||
0xae, 0x42, 0x60, 0x82,
|
||
};
|
||
const size_t g_src_len__mona_lisa_21_32_png = 1600;
|
||
|
||
// ----------------
|
||
|
||
// g_braille holds the Unicode Code Point bit masks for the 8 dots in a Unicode
|
||
// Braille Pattern character (a character in U+2800 ..= U+28FF).
|
||
const uint8_t g_braille[4][2] = {
|
||
{0x01, 0x08},
|
||
{0x02, 0x10},
|
||
{0x04, 0x20},
|
||
{0x40, 0x80},
|
||
};
|
||
|
||
// g_noise is a 32×32 blue noise texture, based on "LDR_LLL1_42.png" (but
|
||
// tweaked so that the values range in 0x00 ..= 0xfe) from the zip file linked
|
||
// to from http://momentsingraphics.de/BlueNoise.html (the files within are
|
||
// mirrored at https://github.com/Calinou/free-blue-noise-textures) and whose
|
||
// LICENSE.txt says "To the extent possible under law, Christoph Peters has
|
||
// waived all copyright and related or neighboring rights".
|
||
const uint8_t g_noise[32][32] = {
|
||
{0x3c, 0xd4, 0xb6, 0x77, 0x64, 0xab, 0xef, 0x03, 0x7d, 0x2f, 0xc0,
|
||
0x24, 0x79, 0x3e, 0x87, 0x9a, 0x36, 0x7f, 0xbc, 0xf0, 0x42, 0xaf,
|
||
0x2d, 0x63, 0x22, 0xc3, 0x4e, 0x33, 0xe9, 0x67, 0x9c, 0x01},
|
||
{0xa9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 0x61, 0xc4, 0xa4, 0x57, 0x6d, 0x2c, 0xdd, 0xed, 0xb1,
|
||
0x92, 0x63, 0xa8, 0xe2, 0x35, 0xc8, 0x7f, 0xd5, 0x9d, 0x49},
|
||
{0x85, 0xae, 0xe2, 0x41, 0x0c, 0xfe, 0x76, 0xc5, 0x20, 0x45, 0xac,
|
||
0x30, 0xcb, 0x73, 0x24, 0xef, 0xda, 0x80, 0xab, 0x5e, 0x89, 0x6e,
|
||
0xd2, 0x16, 0x40, 0x98, 0x52, 0xfb, 0x10, 0x2c, 0xe8, 0xc3},
|
||
{0x04, 0x60, 0x73, 0xca, 0x9a, 0xa8, 0x59, 0x38, 0xdd, 0x5e, 0x70,
|
||
0x0a, 0x51, 0x84, 0x98, 0x34, 0x44, 0x0f, 0xf6, 0x1b, 0x38, 0x49,
|
||
0x08, 0xbb, 0xea, 0x72, 0x03, 0xaa, 0x8d, 0x59, 0x77, 0x20},
|
||
{0x39, 0xd8, 0x2f, 0xee, 0x1c, 0x2b, 0x87, 0xb3, 0x95, 0xed, 0xd1,
|
||
0xa2, 0xf6, 0xe1, 0x16, 0xd2, 0x69, 0xb7, 0xcd, 0x94, 0xc5, 0xa3,
|
||
0xfd, 0x58, 0x86, 0x25, 0xda, 0x65, 0xee, 0x42, 0xba, 0x97},
|
||
{0xf4, 0xb4, 0x8c, 0x48, 0xbf, 0x6d, 0xe7, 0x08, 0x19, 0x7c, 0x29,
|
||
0x8e, 0x3b, 0xb9, 0x4a, 0xa7, 0x8b, 0x07, 0x55, 0x74, 0x25, 0xe0,
|
||
0x7c, 0x30, 0xcd, 0xb5, 0x3a, 0xc4, 0xa2, 0x18, 0xce, 0x69},
|
||
{0x11, 0xa1, 0x5a, 0x06, 0x7e, 0xda, 0x4f, 0xc9, 0x42, 0xbb, 0x56,
|
||
0x1d, 0x6a, 0x02, 0x7a, 0x59, 0xfc, 0x2d, 0xe6, 0x3f, 0xb0, 0x13,
|
||
0x9a, 0x6a, 0x1b, 0x90, 0x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0x96, 0x87, 0x1d},
|
||
{0xa8, 0x98, 0x21, 0xaf, 0x72, 0x16, 0xdf, 0x28, 0x4c, 0xa9, 0x1e,
|
||
0x56, 0x32, 0xb4, 0xec, 0x7b, 0x25, 0x41, 0x86, 0xb5, 0x21, 0x69,
|
||
0x84, 0x28, 0xeb, 0x76, 0xe1, 0x53, 0x05, 0xc5, 0x35, 0x71},
|
||
{0xdc, 0x80, 0xc1, 0x57, 0x31, 0x90, 0xb9, 0xf5, 0x0e, 0xce, 0x75,
|
||
0xf8, 0xdb, 0x49, 0x91, 0x5b, 0xe1, 0x10, 0xf6, 0x33, 0xe6, 0xa6,
|
||
0xbd, 0x5c, 0x48, 0xaa, 0x16, 0xba, 0xa2, 0xe4, 0x5e, 0x0f},
|
||
{0x2e, 0x4a, 0xf7, 0x0a, 0xe6, 0x40, 0x5b, 0x9c, 0x6a, 0x3a, 0x8d,
|
||
0x07, 0x66, 0x19, 0x2b, 0x6f, 0xab, 0xc9, 0x9d, 0x74, 0x50, 0x0d,
|
||
0xdb, 0x3c, 0x07, 0xd0, 0x6b, 0x27, 0x40, 0x7a, 0xb1, 0xf2},
|
||
{0x8c, 0x6b, 0x18, 0x9f, 0xcb, 0x82, 0x1e, 0xd3, 0xb4, 0x52, 0xe5,
|
||
0x9f, 0xaf, 0xd4, 0xc3, 0xde, 0x02, 0x4a, 0x64, 0x1b, 0xd2, 0x93,
|
||
0x7b, 0xf3, 0x9e, 0x86, 0xfa, 0x92, 0xd6, 0x1c, 0x51, 0xc9},
|
||
};
|
||
|
||
// ----------------
|
||
|
||
struct {
|
||
int remaining_argc;
|
||
char** remaining_argv;
|
||
|
||
bool ascii_art;
|
||
bool braille_art_dark_mode;
|
||
bool braille_art_light_mode;
|
||
bool demo;
|
||
bool natural_size;
|
||
int resize;
|
||
|
||
// background_color is in 0xAABBGGRR order, the same as STB (assuming
|
||
// little-endian).
|
||
uint32_t background_color;
|
||
} g_flags = {0};
|
||
|
||
static const char* g_usage =
|
||
"Usage: stb-imagedumper *.{jpeg,png}\n"
|
||
"\n"
|
||
"The \"-\" filename is a special case, a short equivalent of /dev/stdin\n"
|
||
"\n"
|
||
"Flags:\n"
|
||
" -a or -ascii-art (use ASCII art instead of ANSI color codes)\n"
|
||
" -B or -braille-art-dark-mode (use white-on-black Braille art)\n"
|
||
" -b or -braille-art-light-mode (use black-on-white Braille art)\n"
|
||
" -c=orange or -bg=f90 or -background-color=ff9800 (set a background\n"
|
||
" color, for transparent input)\n"
|
||
" -demo (dump the built-in demonstration images)\n"
|
||
" -n or -natural-size (use each image's natural size); this\n"
|
||
" overrides -resize=N\n"
|
||
" -resize=N (resize to fit in N×N, N≤1024); if neither this\n"
|
||
" or -n is given, the default is -resize=64\n";
|
||
|
||
const char* //
|
||
parse_flags(int argc, char** argv) {
|
||
g_flags.resize = 64;
|
||
|
||
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
|
||
for (; c < argc; c++) {
|
||
char* arg = argv[c];
|
||
if (*arg++ != '-') {
|
||
break;
|
||
}
|
||
|
||
// A double-dash "--foo" is equivalent to a single-dash "-foo". As special
|
||
// cases, a bare "-" is not a flag (some programs may interpret it as
|
||
// stdin) and a bare "--" means to stop parsing flags.
|
||
if (*arg == '\x00') {
|
||
break;
|
||
} else if (*arg == '-') {
|
||
arg++;
|
||
if (*arg == '\x00') {
|
||
c++;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (!strcmp(arg, "a") || !strcmp(arg, "ascii-art")) {
|
||
g_flags.ascii_art = true;
|
||
continue;
|
||
}
|
||
if (!strcmp(arg, "B") || !strcmp(arg, "braille-art-dark-mode")) {
|
||
g_flags.braille_art_dark_mode = true;
|
||
continue;
|
||
}
|
||
if (!strcmp(arg, "b") || !strcmp(arg, "braille-art-light-mode")) {
|
||
g_flags.braille_art_light_mode = true;
|
||
continue;
|
||
}
|
||
if (!strcmp(arg, "demo")) {
|
||
g_flags.demo = true;
|
||
continue;
|
||
}
|
||
if (!strcmp(arg, "n") || !strcmp(arg, "natural-size")) {
|
||
g_flags.natural_size = true;
|
||
continue;
|
||
}
|
||
if (!strncmp(arg, "c=", 2) || //
|
||
!strncmp(arg, "bg=", 3) || //
|
||
!strncmp(arg, "background-color=", 17)) {
|
||
while (*arg++ != '=') {
|
||
}
|
||
int64_t c = parse_color(arg, strlen(arg));
|
||
if (c < 0) {
|
||
return g_usage;
|
||
}
|
||
g_flags.background_color = wuffs_base__color_swap_u32_argb_abgr(
|
||
wuffs_base__color_u32_argb_nonpremul__as__color_u32_argb_premul(
|
||
(uint32_t)(c)));
|
||
continue;
|
||
}
|
||
if (!strncmp(arg, "resize=", 7)) {
|
||
while (*arg++ != '=') {
|
||
}
|
||
g_flags.resize = atoi(arg);
|
||
if ((g_flags.resize <= 0) || (1024 < g_flags.resize)) {
|
||
return g_usage;
|
||
}
|
||
continue;
|
||
}
|
||
|
||
return g_usage;
|
||
}
|
||
|
||
g_flags.remaining_argc = argc - c;
|
||
g_flags.remaining_argv = argv + c;
|
||
return NULL;
|
||
}
|
||
|
||
// ----------------
|
||
|
||
static int //
|
||
intmax(int a, int b) {
|
||
return (a < b) ? b : a;
|
||
}
|
||
|
||
static uint64_t //
|
||
u64min(uint64_t a, uint64_t b) {
|
||
return (a < b) ? a : b;
|
||
}
|
||
|
||
static bool //
|
||
resize_wh(int* inout_w, int* inout_h, int dst_wh) {
|
||
// Check arguments.
|
||
if (!inout_w || !inout_h || (dst_wh <= 0) || (0x4000 < dst_wh) || //
|
||
(*inout_w <= 0) || (0xffffff < *inout_w) || //
|
||
(*inout_h <= 0) || (0xffffff < *inout_h)) {
|
||
printf("main: resize failed: invalid argument\n");
|
||
return false;
|
||
}
|
||
|
||
// Compute dst width × height from src width × height.
|
||
uint64_t dw = 0;
|
||
uint64_t dh = 0;
|
||
uint64_t sw = (uint64_t)(*inout_w);
|
||
uint64_t sh = (uint64_t)(*inout_h);
|
||
if (sw < sh) {
|
||
dw = intmax(1, (int)(((sw * dst_wh * 2) + sh) / (2 * sh)));
|
||
dh = dst_wh;
|
||
} else {
|
||
dw = dst_wh;
|
||
dh = intmax(1, (int)(((sh * dst_wh * 2) + sw) / (2 * sw)));
|
||
}
|
||
|
||
// Return width and height.
|
||
*inout_w = (int)dw;
|
||
*inout_h = (int)dh;
|
||
return true;
|
||
}
|
||
|
||
static unsigned char* //
|
||
resize(int* inout_w,
|
||
int* inout_h,
|
||
unsigned char* src_pixels,
|
||
int dst_wh,
|
||
int bytes_per_pixel) {
|
||
// Check arguments.
|
||
if (!inout_w || !inout_h || (dst_wh <= 0) || (0x4000 < dst_wh) || //
|
||
(*inout_w <= 0) || (0xffffff < *inout_w) || //
|
||
(*inout_h <= 0) || (0xffffff < *inout_h) || //
|
||
((bytes_per_pixel != 1) && (bytes_per_pixel != 4))) {
|
||
printf("main: resize failed: invalid argument\n");
|
||
return NULL;
|
||
}
|
||
|
||
// Compute dst width × height from src width × height.
|
||
uint64_t dw = 0;
|
||
uint64_t dh = 0;
|
||
uint64_t sw = (uint64_t)(*inout_w);
|
||
uint64_t sh = (uint64_t)(*inout_h);
|
||
if (sw < sh) {
|
||
dw = intmax(1, (int)(((sw * dst_wh * 2) + sh) / (2 * sh)));
|
||
dh = dst_wh;
|
||
} else {
|
||
dw = dst_wh;
|
||
dh = intmax(1, (int)(((sh * dst_wh * 2) + sw) / (2 * sw)));
|
||
}
|
||
|
||
// Allocate the dst pixel buffer.
|
||
unsigned char* dst_pixels =
|
||
malloc((size_t)dw * (size_t)dh * (size_t)bytes_per_pixel);
|
||
if (!dst_pixels) {
|
||
printf("main: resize failed: out of memory\n");
|
||
return NULL;
|
||
}
|
||
|
||
// For every dst pixel, accumulate the weighted sum of the corresponding
|
||
// source pixels. It's a basic box filter (scaling (sw×sh) explicit src
|
||
// pixels up to ((sw*dw)×(sh*dh)) implicit tmp pixels down to (dw×dh)
|
||
// explicit dst pixels) and the implementation is very slow (no SIMD and lots
|
||
// of branches and uint64_t divisions) but also very simple (for an image
|
||
// resizing algorithm).
|
||
unsigned char* dst = dst_pixels;
|
||
for (uint64_t dy = 0; dy < dh; dy++) {
|
||
for (uint64_t dx = 0; dx < dw; dx++) {
|
||
uint64_t tot0 = 0;
|
||
uint64_t tot1 = 0;
|
||
uint64_t tot2 = 0;
|
||
uint64_t tot3 = 0;
|
||
uint64_t totw = 0;
|
||
|
||
uint64_t ty = dy * sh;
|
||
int sy = (int)(ty / dh);
|
||
for (uint64_t ty_end = (dy + 1) * sh; ty < ty_end; sy++) {
|
||
uint64_t weighty = u64min(ty_end - ty, dh - (ty % dh));
|
||
ty += weighty;
|
||
|
||
uint64_t tx = dx * sw;
|
||
int sx = (int)(tx / dw);
|
||
for (uint64_t tx_end = (dx + 1) * sw; tx < tx_end; sx++) {
|
||
uint64_t weightx = u64min(tx_end - tx, dw - (tx % dw));
|
||
tx += weightx;
|
||
|
||
uint64_t weight = weightx * weighty;
|
||
totw += weight;
|
||
if (bytes_per_pixel == 1) {
|
||
size_t i = (((size_t)sy * (size_t)sw) + (size_t)sx) * 1;
|
||
tot0 += weight * src_pixels[i + 0];
|
||
} else {
|
||
size_t i = (((size_t)sy * (size_t)sw) + (size_t)sx) * 4;
|
||
tot0 += weight * src_pixels[i + 0];
|
||
tot1 += weight * src_pixels[i + 1];
|
||
tot2 += weight * src_pixels[i + 2];
|
||
tot3 += weight * src_pixels[i + 3];
|
||
}
|
||
}
|
||
}
|
||
|
||
if (bytes_per_pixel == 1) {
|
||
*dst++ = (unsigned char)(((tot0 * 2) + totw) / (totw * 2));
|
||
} else {
|
||
*dst++ = (unsigned char)(((tot0 * 2) + totw) / (totw * 2));
|
||
*dst++ = (unsigned char)(((tot1 * 2) + totw) / (totw * 2));
|
||
*dst++ = (unsigned char)(((tot2 * 2) + totw) / (totw * 2));
|
||
*dst++ = (unsigned char)(((tot3 * 2) + totw) / (totw * 2));
|
||
}
|
||
}
|
||
}
|
||
|
||
// Return width, height and pixel buffer.
|
||
*inout_w = (int)dw;
|
||
*inout_h = (int)dh;
|
||
return dst_pixels;
|
||
}
|
||
|
||
static inline uint32_t //
|
||
composite_premul_nonpremul_u32_axxx(uint32_t dst_premul,
|
||
uint32_t src_nonpremul) {
|
||
// Extract 16-bit color components.
|
||
uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));
|
||
uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));
|
||
uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));
|
||
uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));
|
||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||
|
||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||
uint32_t ia = 0xFFFF - sa;
|
||
|
||
// Composite src (nonpremul) over dst (premul).
|
||
da = sa + ((da * ia) / 0xFFFF);
|
||
dr = ((sr * sa) + (dr * ia)) / 0xFFFF;
|
||
dg = ((sg * sa) + (dg * ia)) / 0xFFFF;
|
||
db = ((sb * sa) + (db * ia)) / 0xFFFF;
|
||
|
||
// Convert from 16-bit color to 8-bit color.
|
||
da >>= 8;
|
||
dr >>= 8;
|
||
dg >>= 8;
|
||
db >>= 8;
|
||
|
||
// Combine components.
|
||
return (db << 0) | (dg << 8) | (dr << 16) | (da << 24);
|
||
}
|
||
|
||
static void //
|
||
apply_background_color(uint32_t bg_color_premul,
|
||
unsigned char* pixels,
|
||
int w,
|
||
int h) {
|
||
for (int64_t n = ((int64_t)(w)) * ((int64_t)(h)); n--;) {
|
||
uint32_t fg_color_nonpremul =
|
||
wuffs_base__peek_u32le__no_bounds_check(pixels);
|
||
if ((fg_color_nonpremul >> 24) != 0xFFu) {
|
||
wuffs_base__poke_u32le__no_bounds_check(
|
||
pixels, composite_premul_nonpremul_u32_axxx(bg_color_premul,
|
||
fg_color_nonpremul));
|
||
}
|
||
pixels += 4;
|
||
}
|
||
}
|
||
|
||
// ----------------
|
||
|
||
#define MAX_INCL_DIMENSION 16384
|
||
|
||
// BYTES_PER_COLOR_OUTPUT_CHARACTER is long enough to contain
|
||
// "\x1B[38;2;255;255;255m\x1B[48;2;255;255;255mABC" plus a trailing NUL byte.
|
||
// It starts with a true color terminal escape code. ABC is three bytes for the
|
||
// UTF-8 representation "\xE2\x96\x80" of "▀", U+2580 UPPER HALF BLOCK.
|
||
#define BYTES_PER_COLOR_OUTPUT_CHARACTER 42
|
||
|
||
static void //
|
||
handle(const char* filename,
|
||
uint64_t filesize,
|
||
const uint8_t* src_ptr,
|
||
const size_t src_len) {
|
||
int src_w = 0;
|
||
int src_h = 0;
|
||
int channels_in_file = 0;
|
||
int bytes_per_pixel = (g_flags.ascii_art || g_flags.braille_art_dark_mode ||
|
||
g_flags.braille_art_light_mode)
|
||
? STBI_grey // 1.
|
||
: STBI_rgb_alpha; // 4.
|
||
|
||
unsigned char* src_pixels = NULL;
|
||
|
||
#if defined(WUFFS_EXAMPLE_USE_TIMERS)
|
||
g_started = true;
|
||
clock_gettime(CLOCK_MONOTONIC, &g_start_time);
|
||
#endif
|
||
|
||
if (src_len > 0) {
|
||
src_pixels = stbi_load_from_memory(src_ptr, src_len, //
|
||
&src_w, &src_h, &channels_in_file,
|
||
bytes_per_pixel);
|
||
} else {
|
||
const char* fn = filename;
|
||
if ((fn[0] == '-') && (fn[1] == '\x00')) {
|
||
fn = "/dev/stdin";
|
||
}
|
||
src_pixels = stbi_load(fn, //
|
||
&src_w, &src_h, &channels_in_file, bytes_per_pixel);
|
||
}
|
||
|
||
int64_t elapsed_micros = 0;
|
||
#if defined(WUFFS_EXAMPLE_USE_TIMERS)
|
||
struct timespec now;
|
||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||
elapsed_micros = micros_since_start(&now);
|
||
#endif
|
||
|
||
char resize_info_string[64];
|
||
resize_info_string[0] = 0;
|
||
int target_resize_wh = g_flags.natural_size ? 0 : g_flags.resize;
|
||
if (target_resize_wh <= 0) {
|
||
// No-op.
|
||
} else if ((src_w <= 0) || (src_h <= 0)) {
|
||
snprintf(resize_info_string, sizeof(resize_info_string), " → 0×0");
|
||
} else {
|
||
int resize_w = src_w;
|
||
int resize_h = src_h;
|
||
if (!resize_wh(&resize_w, &resize_h, target_resize_wh)) {
|
||
stbi_image_free(src_pixels);
|
||
return;
|
||
}
|
||
snprintf(resize_info_string, sizeof(resize_info_string), " → %d×%d",
|
||
resize_w, resize_h);
|
||
}
|
||
|
||
printf("\n%s (%" PRIu64 " bytes, %d×%d%s pixels, %" PRIi64 " microseconds)\n",
|
||
filename, filesize, src_w, src_h, resize_info_string, elapsed_micros);
|
||
|
||
if (!src_pixels) {
|
||
printf("%s\n\n", stbi_failure_reason());
|
||
return;
|
||
} else if ((src_w < 0) || (MAX_INCL_DIMENSION < src_w) || //
|
||
(src_h < 0) || (MAX_INCL_DIMENSION < src_h)) {
|
||
printf("main: image is too large\n\n");
|
||
stbi_image_free(src_pixels);
|
||
return;
|
||
} else if ((src_w == 0) || (src_h == 0)) {
|
||
stbi_image_free(src_pixels);
|
||
printf("\n");
|
||
return;
|
||
}
|
||
|
||
uint8_t* dst_pixels = NULL;
|
||
uint8_t* pixels = src_pixels;
|
||
int w = src_w;
|
||
int h = src_h;
|
||
if (target_resize_wh > 0) {
|
||
dst_pixels = resize(&w, &h, src_pixels, target_resize_wh, bytes_per_pixel);
|
||
if (!dst_pixels) {
|
||
stbi_image_free(src_pixels);
|
||
printf("\n");
|
||
return;
|
||
}
|
||
pixels = dst_pixels;
|
||
}
|
||
|
||
// The +16 is some slack for a new-line and ANSI reset code.
|
||
static char
|
||
buffer[(MAX_INCL_DIMENSION * BYTES_PER_COLOR_OUTPUT_CHARACTER) + 16];
|
||
|
||
if (g_flags.ascii_art) {
|
||
unsigned char* src = pixels;
|
||
for (int y = 0; y < h; y++) {
|
||
char* dst = buffer;
|
||
for (int x = 0; x < w; x++) {
|
||
*dst++ = "-:=+IOX@"[(src[0] & 0xff) >> 5];
|
||
src++;
|
||
}
|
||
*dst++ = '\n';
|
||
fwrite(buffer, sizeof(char), dst - buffer, stdout);
|
||
}
|
||
|
||
} else if (g_flags.braille_art_dark_mode || g_flags.braille_art_light_mode) {
|
||
uint8_t xor = g_flags.braille_art_dark_mode ? 0x00 : 0xff;
|
||
// Each 2×4 pixel block becomes one Unicode Braille Pattern character. We
|
||
// also apply blue noise dithering, similar to what's described at
|
||
// https://surma.dev/things/ditherpunk/
|
||
for (int y = 0; y < h; y += 4) {
|
||
char* dst = buffer;
|
||
for (int x = 0; x < w; x += 2) {
|
||
dst[0] = 0xE2; // The 3-byte UTF-8 encoding of U+2800
|
||
dst[1] = 0xA0; // BRAILLE PATTERN BLANK. We'll then set
|
||
dst[2] = 0x80; // dst[1] and dst[2]'s low 2 and 6 bits.
|
||
for (int dy = 0; (dy < 4) && ((y + dy) < h); dy++) {
|
||
size_t ty = y + dy;
|
||
for (int dx = 0; (dx < 2) && ((x + dx) < w); dx++) {
|
||
size_t tx = x + dx;
|
||
uint8_t pixel = pixels[(ty * (size_t)w) + tx];
|
||
uint8_t threshold = g_noise[ty & 31][tx & 31];
|
||
if ((xor^pixel) > (xor^threshold)) {
|
||
uint8_t b = g_braille[dy][dx];
|
||
dst[1] |= b >> 6;
|
||
dst[2] |= b & 0x3f;
|
||
}
|
||
}
|
||
}
|
||
dst += 3;
|
||
}
|
||
*dst++ = '\n';
|
||
fwrite(buffer, sizeof(char), dst - buffer, stdout);
|
||
}
|
||
|
||
} else if (bytes_per_pixel == 4) {
|
||
apply_background_color(g_flags.background_color, pixels, w, h);
|
||
unsigned char* src = pixels;
|
||
for (int y = 0; y < h; y += 2) {
|
||
char* dst = buffer;
|
||
for (int x = 0; x < w; x++) {
|
||
// "\xE2\x96\x80" is U+2588 UPPER HALF BLOCK. Before that is a true
|
||
// color terminal escape code for foreground and background color, to
|
||
// dump two pixels per output character.
|
||
uint8_t upper0 = (uint8_t)src[0];
|
||
uint8_t upper1 = (uint8_t)src[1];
|
||
uint8_t upper2 = (uint8_t)src[2];
|
||
if ((y + 1) >= h) {
|
||
dst += sprintf(dst, "\x1B[38;2;%d;%d;%dm\xE2\x96\x80", //
|
||
upper0, upper1, upper2);
|
||
} else {
|
||
uint8_t lower0 = (uint8_t)src[(w * bytes_per_pixel) + 0];
|
||
uint8_t lower1 = (uint8_t)src[(w * bytes_per_pixel) + 1];
|
||
uint8_t lower2 = (uint8_t)src[(w * bytes_per_pixel) + 2];
|
||
dst +=
|
||
sprintf(dst,
|
||
"\x1B[38;2;%d;%d;%dm\x1B[48;2;%d;%d;%dm\xE2\x96\x80", //
|
||
upper0, upper1, upper2, lower0, lower1, lower2);
|
||
}
|
||
src += bytes_per_pixel;
|
||
}
|
||
memcpy(dst, "\x1B[0m\n", 5);
|
||
dst += 5;
|
||
fwrite(buffer, sizeof(char), dst - buffer, stdout);
|
||
if ((y + 1) < h) {
|
||
src += w * bytes_per_pixel;
|
||
}
|
||
}
|
||
}
|
||
|
||
fflush(stdout);
|
||
free(dst_pixels);
|
||
stbi_image_free(src_pixels);
|
||
printf("\n");
|
||
}
|
||
|
||
int //
|
||
main(int argc, char** argv) {
|
||
const char* usage = parse_flags(argc, argv);
|
||
if (usage) {
|
||
fputs(usage, stderr);
|
||
return 1;
|
||
}
|
||
|
||
struct {
|
||
const char* filename;
|
||
const uint8_t* src_ptr;
|
||
const size_t src_len;
|
||
} demos[] = {
|
||
{
|
||
"«demo»/mona-lisa.21x32.th",
|
||
g_src_ptr__mona_lisa_21_32_th,
|
||
g_src_len__mona_lisa_21_32_th,
|
||
},
|
||
{
|
||
"«demo»/mona-lisa.21x32.c3q1.handsum",
|
||
g_src_ptr__mona_lisa_21_32_c3q1_handsum,
|
||
g_src_len__mona_lisa_21_32_c3q1_handsum,
|
||
},
|
||
{
|
||
"«demo»/mona-lisa.21x32.c3q4.handsum",
|
||
g_src_ptr__mona_lisa_21_32_c3q4_handsum,
|
||
g_src_len__mona_lisa_21_32_c3q4_handsum,
|
||
},
|
||
{
|
||
"«demo»/mona-lisa.21x32.etc2.pkm",
|
||
g_src_ptr__mona_lisa_21_32_etc2_pkm,
|
||
g_src_len__mona_lisa_21_32_etc2_pkm,
|
||
},
|
||
{
|
||
"«demo»/mona-lisa.21x32.q90.lossy.webp",
|
||
g_src_ptr__mona_lisa_21_32_q90_lossy_webp,
|
||
g_src_len__mona_lisa_21_32_q90_lossy_webp,
|
||
},
|
||
{
|
||
"«demo»/mona-lisa.21x32.q50.jpeg",
|
||
g_src_ptr__mona_lisa_21_32_q50_jpeg,
|
||
g_src_len__mona_lisa_21_32_q50_jpeg,
|
||
},
|
||
{
|
||
"«demo»/mona-lisa.21x32.png",
|
||
g_src_ptr__mona_lisa_21_32_png,
|
||
g_src_len__mona_lisa_21_32_png,
|
||
},
|
||
{
|
||
NULL,
|
||
NULL,
|
||
0,
|
||
},
|
||
};
|
||
|
||
if (g_flags.demo) {
|
||
for (size_t c = 0; demos[c].filename != NULL; c++) {
|
||
handle(demos[c].filename, demos[c].src_len, demos[c].src_ptr,
|
||
demos[c].src_len);
|
||
}
|
||
}
|
||
|
||
for (int c = 0; c < g_flags.remaining_argc; c++) {
|
||
const char* filename = g_flags.remaining_argv[c];
|
||
handle(filename, get_filesize(filename), NULL, 0);
|
||
}
|
||
|
||
return 0;
|
||
}
|