move stb to src/stb, add stb_image for png decoding

This commit is contained in:
Mitchell Hashimoto
2023-08-20 11:46:43 -07:00
parent 824d586afc
commit ec69644de6
8 changed files with 8008 additions and 79 deletions

View File

@@ -8,7 +8,7 @@ const std = @import("std");
const builtin = @import("builtin");
const freetype = @import("freetype");
const harfbuzz = @import("harfbuzz");
const resize = @import("stb_image_resize");
const stb = @import("../../stb/main.zig");
const assert = std.debug.assert;
const testing = std.testing;
const Allocator = std.mem.Allocator;
@@ -204,7 +204,7 @@ pub const Face = struct {
result.buffer = buf.ptr;
errdefer alloc.free(buf);
if (resize.stbir_resize_uint8(
if (stb.stbir_resize_uint8(
bm.buffer,
@intCast(bm.width),
@intCast(bm.rows),

4
src/stb/main.zig Normal file
View File

@@ -0,0 +1,4 @@
pub usingnamespace @cImport({
@cInclude("stb_image.h");
@cInclude("stb_image_resize.h");
});

13
src/stb/stb.c Normal file
View File

@@ -0,0 +1,13 @@
// For STBI we only need PNG because the only use case we have right now
// is the Kitty Graphics protocol which only supports PNG as a format
// besides raw RGB/RGBA buffers.
#define STBI_ONLY_PNG
// We don't want to support super large images.
#define STBI_MAX_DIMENSIONS 131072
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include <stb_image_resize.h>

7987
src/stb/stb_image.h Normal file

File diff suppressed because it is too large Load Diff

2634
src/stb/stb_image_resize.h Normal file

File diff suppressed because it is too large Load Diff