From 1ba82d206154de5fd0f68de44dc2ece402f4c46b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= <adria.arrufat@gmail.com>
Date: Sat, 10 Aug 2024 22:30:52 +0900
Subject: [PATCH] image: minor tweaks

- make init methods return Image(T) instead of Self to help ZLS
- remove unneeded pointers
---
 examples/src/face_alignment.zig | 2 +-
 src/image.zig                   | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/src/face_alignment.zig b/examples/src/face_alignment.zig
index eaa43be..8c5cfac 100644
--- a/examples/src/face_alignment.zig
+++ b/examples/src/face_alignment.zig
@@ -94,7 +94,7 @@ pub fn extractAlignedFace(
     // Resize it to the desired size.
     var resized = try Image(Rgba).initAlloc(allocator, out.rows, out.cols);
     defer resized.deinit(allocator);
-    chip.resize(&resized);
+    chip.resize(resized);
     for (out.data, resized.data) |*c, b| {
         c.* = b;
     }
diff --git a/src/image.zig b/src/image.zig
index 06c398c..937bc27 100644
--- a/src/image.zig
+++ b/src/image.zig
@@ -19,11 +19,11 @@ pub fn Image(comptime T: type) type {
         const Self = @This();
         /// Constructs an image of rows and cols size.  If the slice is owned by this image,
         /// deinit should also be called.
-        pub fn init(rows: usize, cols: usize, data: []T) Self {
+        pub fn init(rows: usize, cols: usize, data: []T) Image(T) {
             return .{ .rows = rows, .cols = cols, .data = data };
         }
 
-        pub fn initAlloc(allocator: std.mem.Allocator, rows: usize, cols: usize) !Self {
+        pub fn initAlloc(allocator: std.mem.Allocator, rows: usize, cols: usize) !Image(T) {
             var array = std.ArrayList(T).init(allocator);
             try array.resize(rows * cols);
             return .{ .rows = rows, .cols = cols, .data = try array.toOwnedSlice() };
@@ -117,7 +117,7 @@ pub fn Image(comptime T: type) type {
         }
 
         /// Resizes an image to fit in out, using bilinear interpolation.
-        pub fn resize(self: Self, out: *Self) void {
+        pub fn resize(self: Self, out: Self) void {
             const x_scale: f32 = as(f32, self.cols - 1) / as(f32, @max(out.cols - 1, 1));
             const y_scale: f32 = as(f32, self.rows - 1) / as(f32, @max(out.rows - 1, 1));
             var sy: f32 = -y_scale;