Golang C.ulong类(方法)实例源码

下面列出了Golang C.ulong 类(方法)源码代码实例,从而了解它的用法。

作者:vuleet    项目:canva   
// Adaptively changes the size of the canvas, returns true on success.
func (cv Canvas) AdaptiveResize(width uint, height uint) bool {
	status := C.MagickAdaptiveResizeImage(cv.wand, C.ulong(width), C.ulong(height))
	if status == C.MagickFalse {
		return false
	}
	return true
}

作者:Kimbse    项目:magic   
// ResizeBlur returns a new image resized to the given dimensions using the provided
// filter and blur factor (where > 1 is blurry, < 1 is sharp). If width or height is
// < 0, it's calculated proportionally to the other dimension. If both of them are < 0,
// an error is returned.
func (im *Image) ResizeBlur(width, height int, filter Filter, blur float64) (*Image, error) {
	var data C.ResizeData
	if width < 0 {
		if height < 0 {
			return nil, fmt.Errorf("invalid resize %dx%d", width, height)
		}
		h := float64(im.Height())
		var ratio float64
		if h != 0 {
			ratio = float64(im.Width()) / h
		}
		width = int(float64(height) * ratio)
	}
	if height < 0 {
		if width < 0 {
			return nil, fmt.Errorf("invalid resize %dx%d", width, height)
		}
		var ratio float64
		w := float64(im.Width())
		if w != 0 {
			ratio = float64(im.Height()) / w
		}
		height = int(float64(width) * ratio)
	}
	data.columns = C.ulong(width)
	data.rows = C.ulong(height)
	data.filter = C.FilterTypes(filter)
	data.blur = C.double(blur)
	return im.applyDataFunc("resizing", C.ImageDataFunc(C.resizeImage), &data)
}

作者:sb    项目:ne   
// Extract runs the extractor and returns a slice of Entities found in the
// given tokens.
func (ext *Extractor) Extract(tokens []string) ([]Entity, error) {
	ctokens := C.ner_arr_make(C.int(len(tokens)) + 1) // NULL termination
	defer C.ner_arr_free(ctokens, C.int(len(tokens))+1)
	for i, t := range tokens {
		cs := C.CString(t) // released by ner_arr_free
		C.ner_arr_set(ctokens, cs, C.int(i))
	}

	dets := C.mitie_extract_entities(ext.ner, ctokens)
	defer C.mitie_free(unsafe.Pointer(dets))
	if dets == nil {
		return nil, ErrMemory
	}

	n := int(C.mitie_ner_get_num_detections(dets))
	entities := make([]Entity, n, n)

	for i := 0; i < n; i++ {
		pos := int(C.mitie_ner_get_detection_position(dets, C.ulong(i)))
		len := int(C.mitie_ner_get_detection_length(dets, C.ulong(i)))

		entities[i] = Entity{
			Tag:   int(C.mitie_ner_get_detection_tag(dets, C.ulong(i))),
			Score: float64(C.mitie_ner_get_detection_score(dets, C.ulong(i))),
			Name:  strings.Join(tokens[pos:pos+len], " "),
			Range: Range{pos, pos + len},
		}
	}
	return entities, nil
}

作者:vuleet    项目:canva   
// Extracts a region from the canvas.
func (cv Canvas) Crop(x int, y int, width uint, height uint) bool {
	status := C.MagickCropImage(cv.wand, C.ulong(width), C.ulong(height), C.long(x), C.long(y))
	if status == C.MagickFalse {
		return false
	}
	return true
}

作者:vuleet    项目:canva   
// Creates an empty canvas of the given dimensions.
func (cv Canvas) Blank(width uint, height uint) bool {
	status := C.MagickNewImage(cv.wand, C.ulong(width), C.ulong(height), cv.bg)
	if status == C.MagickFalse {
		return false
	}
	return true
}

作者:yvasiyaro    项目:canva   
// Changes the size of the canvas using specified filter and blur, returns true on success.
func (self *Canvas) ResizeWithFilter(width uint, height uint, filter uint, blur float32) error {
	if width == 0 && height == 0 {
		return fmt.Errorf("Please specify at least one of dimensions")
	}

	if width == 0 || height == 0 {
		origHeight := uint(C.MagickGetImageHeight(self.wand))
		origWidth := uint(C.MagickGetImageWidth(self.wand))

		if width == 0 {
			ratio := float32(origHeight) / float32(height)
			width = uint(float32(origWidth) / ratio)
		}
		if height == 0 {
			ratio := float32(origWidth) / float32(width)
			height = uint(float32(origHeight) / ratio)
		}
	}

	success := C.MagickResizeImage(self.wand, C.ulong(width), C.ulong(height), C.FilterTypes(filter), C.double(blur))

	if success == C.MagickFalse {
		return fmt.Errorf("Could not resize: %s", self.Error())
	}

	return nil
}

作者:vuleet    项目:canva   
// Changes the size of the canvas, returns true on success.
func (cv Canvas) Resize(width uint, height uint) bool {
	status := C.MagickResizeImage(cv.wand, C.ulong(width), C.ulong(height), C.GaussianFilter, C.double(1.0))
	if status == C.MagickFalse {
		return false
	}
	return true
}

作者:kita    项目:magic   
// ResizeBlur returns a new image resized to the given dimensions using the provided
// filter and blur factor (where > 1 is blurry, < 1 is sharp).
func (im *Image) ResizeBlur(width, height int, filter Filter, blur float64) (*Image, error) {
	var data C.ResizeData
	data.columns = C.ulong(width)
	data.rows = C.ulong(height)
	data.filter = C.FilterTypes(filter)
	data.blur = C.double(blur)
	return im.applyDataFunc("resizing", C.ImageDataFunc(C.resizeImage), &data)
}

作者:matt    项目:go-d   
func Call(p, a1, a2, a3 uintptr) uintptr {
	ret := C.dlcall(
		C.ulong(p),
		C.ulong(a1),
		C.ulong(a2),
		C.ulong(a3))
	return uintptr(ret)
}

作者:jmroble    项目:canva   
// Adaptively changes the size of the canvas, returns true on success.
func (self Canvas) AdaptiveResize(width uint, height uint) error {
	success := C.MagickAdaptiveResizeImage(self.wand, C.ulong(width), C.ulong(height))

	if success == C.MagickFalse {
		return fmt.Errorf("Could not resize: %s", self.Error())
	}

	return nil
}

作者:jmroble    项目:canva   
// Creates an empty canvas of the given dimensions.
func (self Canvas) Blank(width uint, height uint) error {
	success := C.MagickNewImage(self.wand, C.ulong(width), C.ulong(height), self.bg)

	if success == C.MagickFalse {
		return fmt.Errorf("Could not create image: %s", self.Error())
	}

	return nil
}

作者:jmroble    项目:canva   
// Extracts a region from the canvas.
func (self Canvas) Crop(x int, y int, width uint, height uint) error {
	success := C.MagickCropImage(self.wand, C.ulong(width), C.ulong(height), C.long(x), C.long(y))

	if success == C.MagickFalse {
		return fmt.Errorf("Could not crop: %s", self.Error())
	}

	return nil
}

作者:kaustavh    项目:kirisur   
func fastHMAC(msg, key []byte) []byte {
	toret := make([]byte, 512/8)
	thing := C.ulong(512 / 8)
	C.hmac_memory(sha512idx,
		unsafe_bytes(key), C.ulong(len(key)),
		unsafe_bytes(msg), C.ulong(len(msg)),
		unsafe_bytes(toret), (&thing))
	return toret
}

作者:jmroble    项目:canva   
// Changes the size of the canvas, returns true on success.
func (self Canvas) Resize(width uint, height uint) error {
	success := C.MagickResizeImage(self.wand, C.ulong(width), C.ulong(height), C.GaussianFilter, C.double(1.0))

	if success == C.MagickFalse {
		return fmt.Errorf("Could not resize: %s", self.Error())
	}

	return nil
}

作者:locus    项目:gm   
// SetBit sets z to x, with x's i'th bit set to b (0 or 1).
// That is, if b is 1 SetBit sets z = x | (1 << i);
// if b is 0 SetBit sets z = x &^ (1 << i). If b is not 0 or 1,
// SetBit will panic.
func (z *Int) SetBit(x *Int, i int, b uint) *Int {
	if z != x {
		z.Set(x)
	}
	if b == 0 {
		C._mpz_clrbit(&z.i[0], C.ulong(i))
	} else {
		C._mpz_setbit(&z.i[0], C.ulong(i))
	}
	return z
}

作者:jbardi    项目:go_talk   
func Resize(img *C.Image, x, y int) (*C.Image, error) {
	newImg := C.ResizeImage(img, C.ulong(x), C.ulong(y), C.LanczosFilter, 1.0, &exceptionInfo)

	if newImg == nil {
		C.CatchException(&exceptionInfo)
		return nil, fmt.Errorf(C.GoString(exceptionInfo.reason))
	}

	C.DestroyImage(img)
	return newImg, nil
}

作者:kilny    项目:magic   
func (im *Image) setPixels(r *Rect, src *C.PixelPacket, ex *C.ExceptionInfo) bool {
	dst := C.SetImagePixelsEx(im.image, C.long(r.X), C.long(r.Y), C.ulong(r.Width), C.ulong(r.Height), ex)
	if dst == nil {
		return false
	}
	C.copy_pixel_packets(src, dst, C.int(r.Width*r.Height))
	if C.SyncImagePixelsEx(im.image, ex) != C.MagickPass {
		return false
	}
	return true
}

作者:padste    项目:go-jac   
func (client *Client) PortRegister(portName, portType string, flags, bufferSize uint64) *Port {
	cname := C.CString(portName)
	defer C.free(unsafe.Pointer(cname))
	ctype := C.CString(portType)
	defer C.free(unsafe.Pointer(ctype))

	cport := C.jack_port_register(client.handler, cname, ctype, C.ulong(flags), C.ulong(bufferSize))
	if cport != nil {
		return &Port{cport}
	}
	return nil
}

作者:ymqyt    项目:cse223_distFileSy   
func (s *StatVfs) toCStat(o *C.struct_statvfs) {
	o.f_bsize = C.ulong(s.BlockSize)
	o.f_blocks = C.fsblkcnt_t(s.Blocks)
	o.f_bfree = C.fsblkcnt_t(s.BlocksFree)

	o.f_files = C.fsfilcnt_t(s.Files)
	o.f_ffree = C.fsfilcnt_t(s.FilesFree)

	o.f_fsid = C.ulong(s.Fsid)
	o.f_flag = C.ulong(s.Flags)
	o.f_namemax = C.ulong(s.NameMax)
}

作者:zesus1    项目:nephel   
/*
Scale() scales the size of this image to the given dimensions.

columns: The number of columns in the scaled image.
rows: The number of rows in the scaled image
*/
func (this *Image) Scale(columns int64, rows int64) error {
	if this.magickWand == nil {
		return errors.New("error scale image:magickwand is nil")
	}

	status := C.MagickScaleImage(this.magickWand, C.ulong(columns), C.ulong(rows))
	if status == 0 {
		var etype int
		descr := C.MagickGetException(this.magickWand, (*C.ExceptionType)(unsafe.Pointer(&etype)))
		defer C.MagickRelinquishMemory(unsafe.Pointer(descr))
		return errors.New(fmt.Sprintf("error scale image: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}


问题


面经


文章

微信
公众号

扫码关注公众号