From 4e6d089efe82f319dbb8d27201f5f33d81b9cf4e Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Fri, 21 Jun 2019 10:47:10 +0200 Subject: [PATCH] Added support for creating image from a sub image. - With a non-zero Min coordinate. --- allg5/bitmap.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/allg5/bitmap.go b/allg5/bitmap.go index e001574..a6e8977 100644 --- a/allg5/bitmap.go +++ b/allg5/bitmap.go @@ -103,10 +103,11 @@ func NewBitmapFromImage(src image.Image, video bool) (*Bitmap, error) { return nil, errors.New("unable to lock bitmap") } dst := (*[1 << 30]uint8)(region.data) + left, top := bnd.Min.X, bnd.Min.Y for y := 0; y < height; y++ { row := dst[y*int(region.pitch):] for x := 0; x < width; x++ { - r, g, b, a := src.At(x, y).RGBA() + r, g, b, a := src.At(left+x, top+y).RGBA() row[x*4] = uint8(r >> 8) row[x*4+1] = uint8(g >> 8) row[x*4+2] = uint8(b >> 8)