Example #1
0
// Set dst, over the region of interest, to be a resized version of the
// corresponding portion of src (mapping such that the "full" image
// window of each correspond to each other, regardless of resolution).
//
// The filter is used to weight the src pixels falling underneath it for
// each dst pixel.  The caller may specify a reconstruction filter by name
// and width (expressed  in pixels unts of the dst image), or ResizeFilter() will
// choose a reasonable default high-quality default filter (blackman-harris
// when upsizing, lanczos3 when downsizing) if the empty string is passed
// or if filterWidth is 0.
//
// The nthreads AlgoOpts specifies how many threads (potentially) may
// be used, but it's not a guarantee.  If nthreads == 0, it will use
// the global OIIO attribute "nthreads".  If nthreads == 1, it
// guarantees that it will not launch any new threads.
func ResizeFilter(dst, src *ImageBuf, filter string, filterWidth float32, opts ...AlgoOpts) error {
	opt := flatAlgoOpts(opts)

	c_filtname := C.CString(filter)
	defer C.free(unsafe.Pointer(c_filtname))

	ok := C.resize(dst.ptr, src.ptr, c_filtname, C.float(filterWidth), opt.ROI.validOrAllPtr(), C.int(opt.Threads))
	if !bool(ok) {
		return dst.LastError()
	}

	return nil
}
Example #2
0
File: fmap.go Project: postfix/fs2
func (self *BlockFile) resize(size uint64) error {
	if self.outstanding > 0 {
		return errors.Errorf("cannot resize the file while there are outstanding pointers")
	}
	if !self.opened {
		return errors.Errorf("File is not open")
	}
	if self.file == nil {
		return self.anonResize(size)
	}
	var new_mmap unsafe.Pointer
	errno := C.resize(self.mmap, &new_mmap, C.int(self.file.Fd()), C.size_t(size))
	if errno != 0 {
		return errors.Errorf("resize failed, %d", errno)
	}
	self.size = size
	self.mmap = new_mmap
	return nil
}