Something went wrong. Try again.
Zig bindings to Google's WUFFS image decoders for PNG, JPEG, GIF and Netpbm
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334// SPDX-FileCopyrightText: © 2024 Mitchell Hashimoto, Ghostty contributors// SPDX-FileCopyrightText: © 2024-2026 Jeffrey C. Ollie <jeff@ocjtech.us>// SPDX-License-Identifier: MIT
const std = @import("std");const Allocator = std.mem.Allocator;const decoder = @import("decoder.zig");const Error = @import("error.zig").Error;
const log = std.log.scoped(.wuffs_jpeg);
/// Decode a JPEG image.pub fn decode(alloc: Allocator, data: []const u8) Error!decoder.Image { return decoder.decode("jpeg", log, alloc, data);}
test "jpeg_decode_000000" { const data = try decode(std.testing.allocator, @embedFile("1x1#000000.jpg")); defer std.testing.allocator.free(data.data);
try std.testing.expectEqual(1, data.width); try std.testing.expectEqual(1, data.height); try std.testing.expectEqualSlices(u8, &.{ 0, 0, 0, 255 }, data.data);}
test "jpeg_decode_FFFFFF" { const data = try decode(std.testing.allocator, @embedFile("1x1#FFFFFF.jpg")); defer std.testing.allocator.free(data.data);
try std.testing.expectEqual(1, data.width); try std.testing.expectEqual(1, data.height); try std.testing.expectEqualSlices(u8, &.{ 255, 255, 255, 255 }, data.data);}