예제 #1
0
파일: image.go 프로젝트: rosylilly/hpdf
func (pdf *PDF) LoadRawImageFromFile(
	filename string, width, height uint32, colorSpace ColorSpace,
) (*Image, error) {
	cfilename := C.CString(filename)
	cimage := C.HPDF_LoadRawImageFromFile(
		pdf.doc, cfilename,
		C.HPDF_UINT(width), C.HPDF_UINT(height),
		C.HPDF_ColorSpace(colorSpace),
	)
	C.free(unsafe.Pointer(cfilename))

	if cimage != nil {
		return newImage(cimage, pdf), nil
	} else {
		return nil, pdf.GetLastError()
	}
}
예제 #2
0
파일: image.go 프로젝트: rosylilly/hpdf
func (pdf *PDF) LoadRawImageFromMem(
	mem []byte,
	width uint32,
	height uint32,
	colorSpace ColorSpace,
	bitsPerComponent uint32,
) (*Image, error) {
	ptr := (*C.HPDF_BYTE)((unsafe.Pointer(&mem[0])))
	cimage := C.HPDF_LoadRawImageFromMem(
		pdf.doc,
		ptr,
		C.HPDF_UINT(width),
		C.HPDF_UINT(height),
		C.HPDF_ColorSpace(colorSpace),
		C.HPDF_UINT(bitsPerComponent),
	)

	if cimage != nil {
		return newImage(cimage, pdf), nil
	} else {
		return nil, pdf.GetLastError()
	}
}