commit 20a84951fc7c5df4eecb97cfd2fa199f7e1bd95d
parent b410cf6d30e70ae5057fc0698422c1f0b5e53858
Author: Chris Waldon <christopher.waldon.dev@gmail.com>
Date: Tue, 25 Jan 2022 11:11:17 -0500
feat: convert input image to RGBA automatically
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/main.go b/main.go
@@ -42,11 +42,11 @@ func run(args []string) error {
if err != nil {
return fmt.Errorf("decoding src image: %w", err)
}
- rgbaImg := image.NewNRGBA(img.Bounds())
+ rgbaImage := image.NewRGBA(img.Bounds())
rect := img.Bounds()
for y := rect.Min.Y; y < rect.Max.Y; y++ {
for x := rect.Min.X; x < rect.Max.X; x++ {
- rgbaImg.Set(x, y, img.At(x, y))
+ rgbaImage.Set(x, y, img.At(x, y))
}
}
var (
@@ -55,10 +55,10 @@ func run(args []string) error {
)
size := Encode(
libc.NewTLS(),
- uintptr(unsafe.Pointer(&rgbaImg.Pix[0])),
+ uintptr(unsafe.Pointer(&rgbaImage.Pix[0])),
int32(img.Bounds().Dx()),
int32(img.Bounds().Dy()),
- int32(rgbaImg.Stride),
+ int32(rgbaImage.Stride),
// Function pointers are generated by taking a pointer to
// a struct who's first field is that function.
*(*uintptr)(unsafe.Pointer(