Пример #1
0
func DisplaySubImageShifted(
	itlx, itly int, w, h int,
	image *opencv.IplImage,
	otlx, otly int) {

	channels := image.Channels()
	in := toByteSlice(image.ImageData(),
		image.Width()*image.Height()*channels)

	for iy, oy := itly, otly; iy < itly+h; iy, oy = iy+1, oy+1 {
		for ix, ox := itlx, otlx; ix < itlx+w; ix, ox = ix+1, ox+1 {
			// image origin is top-left
			imagep := (ix + (iHeight-1-iy)*iWidth) * channels
			// openVG origin is bottom-left
			outp := (ox + oy*iWidth) * VG_CHANS

			out[outp+0] = C.VGubyte(in[imagep+2]) // red
			out[outp+1] = C.VGubyte(in[imagep+1]) // green
			out[outp+2] = C.VGubyte(in[imagep+0]) // blue
			out[outp+3] = 255                     // alpha
		}
	}
}
Пример #2
0
func DisplayImage(image *opencv.IplImage) {
	DisplaySubImage(0, 0, image.Width(), image.Height(), image)
}