mimepattern

package
v0.0.0-...-1fae4d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2014 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package mimepattern creates patterns from images that, when possible, directly embed the uncompressed image data into the target surface.

Direct embedding is only possible when:

  • The surface supports embedding (PDF, PS, SVG, and Win32 Printing)
  • The particular variant of the uncompressed image data is not supported by that surface. (That is, a surface may support a mime type but not a particular compression method or extension used in that file).
  • The pattern is being applied in a way that the surface cannot directly use the data, such as a compositing operation not natively supported by that surface.

If direct embedding is not possible, the pattern still works as expected, but the image data will be re-encoded. If the image is being stored in a lossy format such as JPEG this could result in degradation of image quality.

For SVG surfaces, there is the special case. Instead of embedding the uncompressed image contents, a url to the image is embedded in the document.

Index

Constants

View Source
const (
	//PNG is the Portable Network Graphics image file format (ISO/IEC 15948).
	//
	//Originally CAIRO_MIME_TYPE_PNG.
	PNG mime = "image/png"
	//JPEG is the Joint Photographic Experts Group (JPEG) image coding standard
	//(ISO/IEC 10918-1).
	//
	//Originally CAIRO_MIME_TYPE_JPEG.
	JPEG mime = "image/jpeg"
	//JP2 is the Joint Photographic Experts Group (JPEG) 2000 image coding standard
	//(ISO/IEC 15444-1).
	//
	//Originally CAIRO_MIME_TYPE_JP2.
	JP2 mime = "image/jp2"
)

These are the MIME types libcairo supports for embedding.

Variables

This section is empty.

Functions

func New

func New(mime mime, r io.Reader) (cairo.Pattern, error)

New creates a pattern of the image data in r of type mime.

The returned pattern is essentially a SurfacePattern but the underlying surface is irrecoverable as any modification will lead to corruption.

New will fail if there is not an image decoder for the relevant mime type installed with the image package. See the image package documentation for more information. It is up to you to ensure that the image data in r is of the mime type specified by mime.

Originally cairo_surface_set_mime_data.

func URL

func URL(URL *url.URL, r io.Reader) (cairo.Pattern, error)

URL creates a Pattern similar to New, except that, instead of storing the uncompressed image data, a url to the image is stored.

This is only useful on an SVG surface.

Originally cairo_surface_set_mime_data.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL