lib/uncompng: rearrange Encode argument order
diff --git a/example/convert-to-nia/convert-to-nia.c b/example/convert-to-nia/convert-to-nia.c index 168a6e9..5e7a4e8 100644 --- a/example/convert-to-nia/convert-to-nia.c +++ b/example/convert-to-nia/convert-to-nia.c
@@ -804,10 +804,10 @@ uint32_t h = wuffs_base__pixel_config__height(&g_pixbuf.pixcfg); wuffs_base__table_u8 tab = wuffs_base__pixel_buffer__plane(&g_pixbuf, 0); return UNCOMPNG__RESULT__OK == - uncompng__encode(&my_uncompng_write_func, NULL, tab.ptr, + uncompng__encode(&my_uncompng_write_func, NULL, pixfmt, w, h, tab.ptr, wuffs_base__table__flattened_length( tab.width, tab.height, tab.stride), - w, h, tab.stride, pixfmt); + tab.stride); } void //
diff --git a/lib/uncompng/uncompng.go b/lib/uncompng/uncompng.go index b3b0c74..a4d5fec 100644 --- a/lib/uncompng/uncompng.go +++ b/lib/uncompng/uncompng.go
@@ -196,7 +196,7 @@ // pix holds the pixel data, either 1 or 4 bytes per pixel (doubled for // Depth16) depending on the colorType. width and height are measured in // pixels. stride is measured in bytes. depth must be either Depth8 or Depth16. -func (e *Encoder) Encode(w io.Writer, pix []byte, width int, height int, stride int, depth Depth, colorType ColorType) error { +func (e *Encoder) Encode(w io.Writer, depth Depth, colorType ColorType, width int, height int, pix []byte, stride int) error { if (width < 0) || (height < 0) || ((depth != Depth8) && (depth != Depth16)) || (colorType.pngFileFormatEncoding() == 0xFF) {
diff --git a/lib/uncompng/uncompng_test.go b/lib/uncompng/uncompng_test.go index 7375f33..bcd5f15 100644 --- a/lib/uncompng/uncompng_test.go +++ b/lib/uncompng/uncompng_test.go
@@ -26,39 +26,39 @@ switch src := src.(type) { case *image.Gray: - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth8, ColorTypeGray) + return e.Encode(w, Depth8, ColorTypeGray, b.Dx(), b.Dy(), src.Pix, src.Stride) case *image.Gray16: - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth16, ColorTypeGray) + return e.Encode(w, Depth16, ColorTypeGray, b.Dx(), b.Dy(), src.Pix, src.Stride) case *image.RGBA: if src.Opaque() { - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth8, ColorTypeRGBX) + return e.Encode(w, Depth8, ColorTypeRGBX, b.Dx(), b.Dy(), src.Pix, src.Stride) } case *image.RGBA64: if src.Opaque() { - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth16, ColorTypeRGBX) + return e.Encode(w, Depth16, ColorTypeRGBX, b.Dx(), b.Dy(), src.Pix, src.Stride) } case *image.NRGBA: if src.Opaque() { - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth8, ColorTypeRGBX) + return e.Encode(w, Depth8, ColorTypeRGBX, b.Dx(), b.Dy(), src.Pix, src.Stride) } else { - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth8, ColorTypeNRGBA) + return e.Encode(w, Depth8, ColorTypeNRGBA, b.Dx(), b.Dy(), src.Pix, src.Stride) } case *image.NRGBA64: if src.Opaque() { - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth16, ColorTypeRGBX) + return e.Encode(w, Depth16, ColorTypeRGBX, b.Dx(), b.Dy(), src.Pix, src.Stride) } else { - return e.Encode(w, src.Pix, b.Dx(), b.Dy(), src.Stride, Depth16, ColorTypeNRGBA) + return e.Encode(w, Depth16, ColorTypeNRGBA, b.Dx(), b.Dy(), src.Pix, src.Stride) } } tmp := image.NewNRGBA(b) draw.Draw(tmp, b, src, b.Min, draw.Src) - return e.Encode(w, tmp.Pix, b.Dx(), b.Dy(), tmp.Stride, Depth8, ColorTypeNRGBA) + return e.Encode(w, Depth8, ColorTypeNRGBA, b.Dx(), b.Dy(), tmp.Pix, tmp.Stride) } func getPix(m image.Image) []byte { @@ -144,7 +144,7 @@ enc := Encoder{} pix := make([]byte, 4*3*5) got := testing.AllocsPerRun(100, func() { - enc.Encode(io.Discard, pix, 3, 5, 4*3, Depth8, ColorTypeNRGBA) + enc.Encode(io.Discard, Depth8, ColorTypeNRGBA, 3, 5, pix, 4*3) }) if got != 0 { tt.Errorf("AllocsPerRun: got %v, want 0", got)
diff --git a/snippet/uncompng.c b/snippet/uncompng.c index 41eebcb..2b62c5f 100644 --- a/snippet/uncompng.c +++ b/snippet/uncompng.c
@@ -94,12 +94,12 @@ const uint8_t* data_ptr, size_t data_len), void* context, - const uint8_t* pixel_ptr, - size_t pixel_len, + uint32_t pixel_format, uint32_t width, uint32_t height, - size_t stride, - uint32_t pixel_format); + const uint8_t* pixel_ptr, + size_t pixel_len, + size_t stride); // -------- @@ -581,12 +581,12 @@ const uint8_t* data_ptr, size_t data_len), void* context, - const uint8_t* pixel_ptr, - size_t pixel_len, + uint32_t pixel_format, uint32_t width, uint32_t height, - size_t stride, - uint32_t pixel_format) { + const uint8_t* pixel_ptr, + size_t pixel_len, + size_t stride) { if (!write_func) { return UNCOMPNG__RESULT__INVALID_ARGUMENT; }