use helper

This commit is contained in:
Celogeek 2023-01-15 14:25:11 +01:00
parent 7adea5ddbd
commit 6c904ad70b
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A
2 changed files with 9 additions and 12 deletions

View File

@ -17,15 +17,15 @@ type cropSplitDoublePage struct {
func (p *cropSplitDoublePage) Bounds(srcBounds image.Rectangle) (dstBounds image.Rectangle) {
if p.right {
dstBounds = image.Rectangle{
Min: image.Point{srcBounds.Max.X / 2, srcBounds.Min.Y},
Max: srcBounds.Max,
}
dstBounds = image.Rect(
srcBounds.Max.X/2, srcBounds.Min.Y,
srcBounds.Max.X, srcBounds.Max.Y,
)
} else {
dstBounds = image.Rectangle{
Min: srcBounds.Min,
Max: image.Point{srcBounds.Max.X / 2, srcBounds.Max.Y},
}
dstBounds = image.Rect(
srcBounds.Min.X, srcBounds.Min.Y,
srcBounds.Max.X/2, srcBounds.Max.Y,
)
}
return
}

View File

@ -145,10 +145,7 @@ func LoadImages(path string, options *ImageOptions) ([]*Image, error) {
// Convert image
dst := image.NewPaletted(g.Bounds(src.Bounds()), options.Palette)
if dst.Bounds().Dx() == 0 || dst.Bounds().Dy() == 0 {
dst = image.NewPaletted(image.Rectangle{
Min: image.Point{0, 0},
Max: image.Point{1, 1},
}, dst.Palette)
dst = image.NewPaletted(image.Rect(0, 0, 1, 1), dst.Palette)
dst.Set(0, 0, color.White)
} else {
g.Draw(dst, src)