示例#1
0
文件: canvas.go 项目: jmrobles/canvas
// Reads an image or image sequence from a blob.
func (self Canvas) OpenBlob(blob []byte, length uint) error {
	status := C.MagickReadImageBlob(self.wand, unsafe.Pointer(&blob[0]), C.size_t(length))
	if status == C.MagickFalse {
		return fmt.Errorf(`Could not open image from blob: %s`, self.Error())
	}
	return nil
}
示例#2
0
/* Reads an image or image sequence from a blob. */
func (w *MagickWand) ReadImageBlob(blob []byte, length uint) error {
	if C.MagickReadImageBlob(w.wand, unsafe.Pointer(&blob[0]), C.size_t(length)) == C.MagickFalse {
		eStr, eCode := w.Exception()
		return fmt.Errorf("ReadImageBlob() failed : [%d] %s", eStr, eCode)
	}

	return nil
}
示例#3
0
文件: canvas.go 项目: vuleetu/canvas
// Opens an image from binary, returns true on success.
func (cv Canvas) OpenBlob(data []byte) bool {
	cv.filename = ""
	status := C.MagickReadImageBlob(cv.wand, unsafe.Pointer(&data[0]), C.size_t(len(data)))
	if status == C.MagickFalse {
		return false
	}
	return true
}
示例#4
0
func Open(filename string) (img *Image, err error) {
	img = &Image{wand: C.NewMagickWand()}
	var file *os.File
	if file, err = os.Open(filename); err != nil {
		return nil, err
	}
	var data []byte
	if data, err = ioutil.ReadAll(file); err != nil {
		return nil, err
	}

	C.MagickReadImageBlob(img.wand, unsafe.Pointer(&data[0]), C.size_t(len(data)))

	return img, nil
}
示例#5
0
文件: mage.go 项目: dqminh/mage
// Public: read a blob data into the current wand
//
// Examples:
//  im = NewMage()
//  original, err := ioutil.ReadFile("test.jpg")
//  success := im.ReadBlob(original)
func (m *Mage) ReadBlob(blob []byte) bool {
	return mBoolean(C.MagickReadImageBlob(
		m.wand,
		unsafe.Pointer(&blob[0]),
		C.size_t(len(blob))))
}