scaler: support Stretch

This commit is contained in:
mappu 2018-06-09 17:20:27 +12:00
parent 1a7a435460
commit bc4eb13058
2 changed files with 5 additions and 0 deletions

View File

@ -12,6 +12,7 @@ const (
FitOutside AspectFormat = 80 // Pad out with black bars to dimensions FitOutside AspectFormat = 80 // Pad out with black bars to dimensions
FitInside AspectFormat = 82 // Crop to dimensions FitInside AspectFormat = 82 // Crop to dimensions
Stretch AspectFormat = 83 // Doesn't preserve aspect ratio
NearestNeighbour ScaleFormat = 120 NearestNeighbour ScaleFormat = 120
BilinearFast ScaleFormat = 121 BilinearFast ScaleFormat = 121

View File

@ -52,6 +52,10 @@ func (this *DirectThumbnailer) scaleImage(src image.Image) (image.Image, error)
srcCopyPosition = image.Rect(offsetX, offsetY, srcSmallestDim+offsetX, srcSmallestDim+offsetY) srcCopyPosition = image.Rect(offsetX, offsetY, srcSmallestDim+offsetX, srcSmallestDim+offsetY)
destCopyPosition = image.Rect(0, 0, this.cfg.Width, this.cfg.Height) destCopyPosition = image.Rect(0, 0, this.cfg.Width, this.cfg.Height)
case Stretch:
srcCopyPosition = src.Bounds()
destCopyPosition = image.Rect(0, 0, this.cfg.Width, this.cfg.Height)
default: default:
return nil, ErrInvalidOption return nil, ErrInvalidOption
} }