コード例 #1
0
ファイル: image.go プロジェクト: Kimau/GoCam
func ToComputeImage(src image.Image) *image.Gray {
	// Small M
	bSize := src.Bounds().Size()
	smallBounds := image.Rect(0, 0, bSize.X/16, bSize.Y/16)
	smallM := image.NewGray(smallBounds)

	rez.Convert(smallM, src, rez.NewBilinearFilter())
	return smallM
}
コード例 #2
0
ファイル: image.go プロジェクト: Kimau/GoCam
func ToComputeImageCol(src image.Image) *image.RGBA {
	// Small M
	//bSize := src.Bounds().Size()
	smallBounds := src.Bounds() // image.Rect(0, 0, bSize.X/16, bSize.Y/16)
	smallM := image.NewRGBA(smallBounds)

	rez.Convert(smallM, src, rez.NewBilinearFilter())

	return smallM
}
コード例 #3
0
ファイル: resize.go プロジェクト: pierrre/imageresizebench
func newResizeFuncRez(filter rez.Filter) resizeFunc {
	return func(im image.Image) image.Image {
		newIm := newImageFunc(image.Rect(0, 0, width, height))
		err := rez.Convert(newIm, im, filter)
		if err != nil {
			panic(err)
		}
		return newIm
	}
}
コード例 #4
0
ファイル: image.go プロジェクト: fragmenta/model
// ResizeImage resizes the given image IF it is larger than maxWidth or maxHeight
func ResizeImage(src image.Image, maxWidth int64, maxHeight int64, square bool) (image.Image, error) {
	var dst image.Image

	// Check the original dimensions first, and bail out if this image is not larger than max dimensions
	srcSize := src.Bounds().Size()
	if int64(srcSize.X) < maxWidth && int64(srcSize.Y) < maxHeight {
		return src, nil
	}

	// Use the original image dimensions to keep it in pro
	// Distorting images is a sin of which we are never guilty
	ratio := float64(maxWidth) / float64(srcSize.X)
	yRatio := float64(maxHeight) / float64(srcSize.Y)
	if yRatio < ratio {
		ratio = yRatio
	}

	// Now adjust desired width and height according to ratio
	width := float64(srcSize.X) * ratio
	height := float64(srcSize.Y) * ratio

	// Create a new resized image with the desired dimensions and fill it with resized image data
	// We switch on input image type - is YCbCrSubsampleRatio444 correct?
	switch src.(type) {
	case *image.YCbCr:
		dst = image.NewYCbCr(image.Rect(0, 0, int(width), int(height)), image.YCbCrSubsampleRatio444)
	case *image.RGBA:
		dst = image.NewRGBA(image.Rect(0, 0, int(width), int(height)))
	default:
		dst = nil
	}

	err := rez.Convert(dst, src, rez.NewBicubicFilter())
	// IF we want thumbnails to be square/cropped we could do this
	// for now we don't need this. We may not even want it for camping?
	//   err :=  imaging.Thumbnail(srcImage, 100, 100, imaging.Lanczos)

	if err != nil {
		return nil, err
	}

	return dst, nil

}
コード例 #5
0
ファイル: bug2.go プロジェクト: kjk/test_go_image
func ConvertThreads(output, input image.Image, filter rez.Filter) error {
	return rez.Convert(output, input, filter)
}