Exporting ResizeByNearest func

master
Vitali Fedulov 2023-12-03 17:04:57 +01:00
parent 93d6a8e184
commit f053061208
3 changed files with 4 additions and 4 deletions

View File

@ -42,7 +42,7 @@ func IconNN(img image.Image) IconT {
// Resizing to a large icon approximating average color // Resizing to a large icon approximating average color
// values of the source image. YCbCr space is used instead // values of the source image. YCbCr space is used instead
// of RGB for better results in image comparison. // of RGB for better results in image comparison.
resImg, imgSize := resizeByNearest( resImg, imgSize := ResizeByNearest(
img, image.Point{resizedImgSize, resizedImgSize}) img, image.Point{resizedImgSize, resizedImgSize})
largeIcon := sizedIcon(largeIconSize) largeIcon := sizedIcon(largeIconSize)
var r, g, b, sumR, sumG, sumB uint32 var r, g, b, sumR, sumG, sumB uint32

View File

@ -24,10 +24,10 @@ func Open(path string) (img image.Image, err error) {
return img, err return img, err
} }
// resizeByNearest resizes an image to the destination size // ResizeByNearest resizes an image to the destination size
// with the nearest neighbour method. It also returns the source // with the nearest neighbour method. It also returns the source
// image size. // image size.
func resizeByNearest( func ResizeByNearest(
src image.Image, dstSize image.Point) ( src image.Image, dstSize image.Point) (
dst image.RGBA, srcSize image.Point) { dst image.RGBA, srcSize image.Point) {
// Original image size. // Original image size.

View File

@ -35,7 +35,7 @@ func TestResizeByNearest(t *testing.T) {
if err != nil { if err != nil {
t.Error("Cannot decode", path.Join(testDir, table.outFile)) t.Error("Cannot decode", path.Join(testDir, table.outFile))
} }
resampled, srcSize := resizeByNearest(inImg, resampled, srcSize := ResizeByNearest(inImg,
image.Point{table.dstX, table.dstY}) image.Point{table.dstX, table.dstY})
if !reflect.DeepEqual( if !reflect.DeepEqual(
outImg.(*image.RGBA), &resampled) || outImg.(*image.RGBA), &resampled) ||