Example #1
0
File: image.go Project: Kimau/GoCam
func MakeComputeMaker(src image.Image) *ComMaker {
	b := src.Bounds()
	sz := b.Size()
	width := sz.X / 8
	height := sz.Y / 8
	smallB := image.Rect(0, 0, width, height)

	cm := ComMaker{
		width:  sz.X / 8,
		height: sz.Y / 8,
		bound:  smallB,
	}

	// Make Grey Img
	gSrc := image.NewGray(b)
	draw.Draw(gSrc, b, src, image.ZP, draw.Src)

	// Make Smaller
	gDst := image.NewGray(smallB)

	// Prep Conversion
	cfg, err := rez.PrepareConversion(gDst, gSrc)
	if err != nil {
		log.Println(err)
		return nil
	}

	cm.rConv, err = rez.NewConverter(cfg, rez.NewBilinearFilter())
	if err != nil {
		log.Println(err)
		return nil
	}

	return &cm
}
Example #2
0
func ConvertNoThreads(output, input image.Image, filter rez.Filter) error {
	cfg, err := rez.PrepareConversion(output, input)
	if err != nil {
		return err
	}
	cfg.Threads = 1
	converter, err := rez.NewConverter(cfg, filter)
	if err != nil {
		return err
	}
	return converter.Convert(output, input)
}
Example #3
0
func prepare(dst, src image.Image, interlaced bool, filter rez.Filter) rez.Converter {
	cfg, err := rez.PrepareConversion(dst, src)
	if err != nil {
		log.Fatalf("prepare: PrepareConversion() failed with %q", err)
	}
	cfg.Input.Interlaced = interlaced
	cfg.Output.Interlaced = interlaced
	converter, err := rez.NewConverter(cfg, filter)
	if err != nil {
		log.Fatalf("prepare: NewConverter() failed with %q", err)
	}
	return converter
}