Exemplo n.º 1
0
func (this *Image) Read(name string, flags int) (err os.Error) {
	cn := C.CString(name)
	defer C.free(unsafe.Pointer(cn))
	if C.glfwReadImage(cn, this.ptr, C.int(flags)) != 1 {
		err = os.NewError("Failed to read image " + name)
	}
	return
}
Exemplo n.º 2
0
// ReadImage reads an image from the file specified by the parameter name and
// returns the image or an error.
//
// Note: By default the read image is rescaled to the nearest larger power of
// two resolution using bilinear interpolation, if necessary. Which is useful
// if the image is to be used as an OpenGL texture. This behavior can be
// disabled by setting the glfw.NoRescaleBit flag.
//
// Note: Unless the glfw.OriginUlBit flag is set, the first pixel in img.Data
// is the lower left corner of the image. Otherwise the first pixel is the upper
// left corner.
//
// Note: For single component images (i.e. gray scale), Format is set to
// GL_ALPHA if the glfw.AlphaMapBit flag is set, otherwise Format is set to GL_LUMINANCE.
//
// Note: ReadImage supports the Truevision Targa version 1 file format
// (.TGA). Supported pixel formats are: 8-bit gray scale, 8-bit paletted
// (24/32-bit color), 24-bit true color and 32-bit true color + alpha.
func ReadImage(name string, flags int) (i *Image, err error) {
	i = new(Image)

	str := C.CString(name)
	defer C.free(unsafe.Pointer(str))

	if C.glfwReadImage(str, &i.img, C.int(flags)) != 1 {
		return nil, errors.New("Failed to read image " + name)
	}

	return
}