-
zigimg's README says:
This project assume current Zig master (0.10.0+)
but accutually it only works with 0.11.0+, not 0.10.0+.
- Mainly due to incompatibilities of
std.buildin.Type.StructField
.
- Mainly due to incompatibilities of
-
Images of any format can be read using
Image.fromFilePath/fromFile/fromMemory
, as value of theImage
type. -
In addition to pixel data, we can get width and height of the image from struct
Image
. -
An iterator that iterates over pixels of the image can be obtained from
Image
byiterator
method.
- Via
io.FixedBufferStream([]u8)
, we can use[]u8
asio.Writer
andio.Reader
.
var buf = [100]u8 = undefined;
var stream = std.io.fixedBufferStream(buf); // convenient constructor is available
stream.writer(); // convert to `io.Writer`
stream.reader(); // convert to `io.Reader`
-
io.StreamSource
abstracts overFile(.file)
,FixedBuffer([]u8)(.buffer)
andFixedBuffer([]const u8)(.const_buffer)
and offers generic I/O interface w/ seeking.- if it is
.const_buffer
variant, writing to it will always return error.
- if it is
-
io.Writer
andio.Reader
has useful methods for serializing to/deserializing from binary data.reader.readIntBig(u32)
reads big-endian binary data from thereader
asu32
value.writer.writeIntBig(u32, n)
writesu32
value to thewriter
as big-endian binary data.
-
To test functions that have
comptime
parameter (e.g.type
) in Table Driven Testing style, useinline for
instead of barefor
to iterate over a test table.- It makes the for loop unrolled, and the value in the loop variable compile-time known as an additional effect.
- If you use bare for loop, compiler complains with the error like:
error: values of type '[N]SomeType' must be comptime-known, but index value is runtime-known
-
We can skip tests according to some runtime conditions by returning
error.SkipZigTest
.