Added support for creating image from a sub image.
- With a non-zero Min coordinate.
This commit is contained in:
parent
eee707c4ec
commit
4e6d089efe
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user