Cairo-Dock  3.4.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cairo-dock-surface-factory.h File Reference

Macros

#define CAIRO_DOCK_ORIENTATION_MASK
 mask to get the orientation from a CairoDockLoadImageModifier.
 
#define cairo_dock_create_surface_for_square_icon(cImagePath, fImageSize)
 
#define cairo_dock_create_surface_from_text(cText, pLabelDescription, iTextWidthPtr, iTextHeightPtr)
 

Enumerations

enum  CairoDockLoadImageModifier {
  CAIRO_DOCK_FILL_SPACE,
  CAIRO_DOCK_KEEP_RATIO,
  CAIRO_DOCK_DONT_ZOOM_IN,
  CAIRO_DOCK_ORIENTATION_HFLIP,
  CAIRO_DOCK_ORIENTATION_ROT_180,
  CAIRO_DOCK_ORIENTATION_VFLIP,
  CAIRO_DOCK_ORIENTATION_ROT_90_HFLIP,
  CAIRO_DOCK_ORIENTATION_ROT_90,
  CAIRO_DOCK_ORIENTATION_ROT_90_VFLIP,
  CAIRO_DOCK_ORIENTATION_ROT_270,
  CAIRO_DOCK_ANIMATED_IMAGE
}
 Types of image loading modifiers. More...
 

Functions

cairo_surface_t * cairo_dock_create_surface_from_xicon_buffer (gulong *pXIconBuffer, int iBufferNbElements, int iWidth, int iHeight)
 
cairo_surface_t * cairo_dock_create_surface_from_pixbuf (GdkPixbuf *pixbuf, double fMaxScale, int iWidthConstraint, int iHeightConstraint, CairoDockLoadImageModifier iLoadingModifier, double *fImageWidth, double *fImageHeight, double *fZoomX, double *fZoomY)
 
cairo_surface_t * cairo_dock_create_blank_surface (int iWidth, int iHeight)
 
cairo_surface_t * cairo_dock_create_surface_from_image (const gchar *cImagePath, double fMaxScale, int iWidthConstraint, int iHeightConstraint, CairoDockLoadImageModifier iLoadingModifier, double *fImageWidth, double *fImageHeight, double *fZoomX, double *fZoomY)
 
cairo_surface_t * cairo_dock_create_surface_from_image_simple (const gchar *cImageFile, double fImageWidth, double fImageHeight)
 
cairo_surface_t * cairo_dock_create_surface_from_icon (const gchar *cImagePath, double fImageWidth, double fImageHeight)
 
cairo_surface_t * cairo_dock_create_surface_from_pattern (const gchar *cImageFile, double fImageWidth, double fImageHeight, double fAlpha)
 
cairo_surface_t * cairo_dock_rotate_surface (cairo_surface_t *pSurface, double fImageWidth, double fImageHeight, double fRotationAngle)
 
cairo_surface_t * cairo_dock_create_surface_from_text_full (const gchar *cText, GldiTextDescription *pLabelDescription, double fMaxScale, int iMaxWidth, int *iTextWidth, int *iTextHeight)
 
cairo_surface_t * cairo_dock_duplicate_surface (cairo_surface_t *pSurface, double fWidth, double fHeight, double fDesiredWidth, double fDesiredHeight)
 

Detailed Description

This class contains functions to load any image/X buffer/GdkPixbuf/text into a cairo-surface. The loading of an image can be modified by a mask, to take into account the ratio, zoom, orientation, etc.

The general way to load an image is by using cairo_dock_create_surface_from_image.

If you just want to load an image at a given size, use cairo_dock_create_surface_from_image_simple, or cairo_dock_create_surface_from_icon.

To load a text into a surface, describe your text look with a _GldiTextDescription, and pass it to cairo_dock_create_surface_from_text.

Note: if you also need to load the image into a texture, it's easier to use the higher level ImageBuffer API (see cairo_dock_create_image_buffer).

Macro Definition Documentation

#define cairo_dock_create_surface_for_square_icon (   cImagePath,
  fImageSize 
)

Create a square surface from any image, at a given size. If the image is given by its sole name, it is searched inside the icons themes known by Cairo-Dock.

Parameters
cImagePathpath or name of an image.
fImageSizethe desired surface size.
Returns
the newly allocated surface.
#define cairo_dock_create_surface_from_text (   cText,
  pLabelDescription,
  iTextWidthPtr,
  iTextHeightPtr 
)

Create a surface representing a text, according to a given text description.

Parameters
cTextthe text.
pLabelDescriptiondescription of the text rendering.
iTextWidthPtrwill be filled the width of the resulting surface.
iTextHeightPtrwill be filled the height of the resulting surface.
Returns
the newly allocated surface.

Enumeration Type Documentation

Types of image loading modifiers.

Enumerator
CAIRO_DOCK_FILL_SPACE 

fill the space, with transparency if necessary.

CAIRO_DOCK_KEEP_RATIO 

keep the ratio of the original image.

CAIRO_DOCK_DONT_ZOOM_IN 

don't zoom in the image if the final surface is larger than the original image.

CAIRO_DOCK_ORIENTATION_HFLIP 

orientation horizontal flip

CAIRO_DOCK_ORIENTATION_ROT_180 

orientation 180° rotation

CAIRO_DOCK_ORIENTATION_VFLIP 

orientation vertical flip

CAIRO_DOCK_ORIENTATION_ROT_90_HFLIP 

orientation 90° rotation + horizontal flip

CAIRO_DOCK_ORIENTATION_ROT_90 

orientation 90° rotation

CAIRO_DOCK_ORIENTATION_ROT_90_VFLIP 

orientation 90° rotation + vertical flip

CAIRO_DOCK_ORIENTATION_ROT_270 

orientation 270° rotation

CAIRO_DOCK_ANIMATED_IMAGE 

load the image as a strip if possible.

Function Documentation

cairo_surface_t* cairo_dock_create_surface_from_xicon_buffer ( gulong *  pXIconBuffer,
int  iBufferNbElements,
int  iWidth,
int  iHeight 
)

Create a surface from raw data of an X icon. The biggest icon possible is taken. The ratio is kept, and the surface will fill the space with transparency if necessary.

Parameters
pXIconBufferraw data of the icon.
iBufferNbElementsnumber of elements in the buffer.
iWidthwill be filled with the resulting width of the surface.
iHeightwill be filled with the resulting height of the surface.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_create_surface_from_pixbuf ( GdkPixbuf *  pixbuf,
double  fMaxScale,
int  iWidthConstraint,
int  iHeightConstraint,
CairoDockLoadImageModifier  iLoadingModifier,
double *  fImageWidth,
double *  fImageHeight,
double *  fZoomX,
double *  fZoomY 
)

Create a surface from a GdkPixbuf.

Parameters
pixbufthe pixbuf.
fMaxScalemaximum zoom of the icon.
iWidthConstraintconstraint on the width, or 0 to not constraint it.
iHeightConstraintconstraint on the height, or 0 to not constraint it.
iLoadingModifiera mask of different loading modifiers.
fImageWidthwill be filled with the resulting width of the surface (hors zoom).
fImageHeightwill be filled with the resulting height of the surface (hors zoom).
fZoomXif non NULL, will be filled with the zoom that has been applied on width.
fZoomYif non NULL, will be filled with the zoom that has been applied on width.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_create_blank_surface ( int  iWidth,
int  iHeight 
)

Create an empty surface (transparent) of a given size. In OpenGL mode, this surface can act as a buffer to generate a texture.

Parameters
iWidthwidth of the surface.
iHeightheight of the surface.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_create_surface_from_image ( const gchar *  cImagePath,
double  fMaxScale,
int  iWidthConstraint,
int  iHeightConstraint,
CairoDockLoadImageModifier  iLoadingModifier,
double *  fImageWidth,
double *  fImageHeight,
double *  fZoomX,
double *  fZoomY 
)

Create a surface from any image.

Parameters
cImagePathcomplete path to the image.
fMaxScalemaximum zoom of the icon.
iWidthConstraintconstraint on the width, or 0 to not constraint it.
iHeightConstraintconstraint on the height, or 0 to not constraint it.
iLoadingModifiera mask of different loading modifiers.
fImageWidthwill be filled with the resulting width of the surface (hors zoom).
fImageHeightwill be filled with the resulting height of the surface (hors zoom).
fZoomXif non NULL, will be filled with the zoom that has been applied on width.
fZoomYif non NULL, will be filled with the zoom that has been applied on width.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_create_surface_from_image_simple ( const gchar *  cImageFile,
double  fImageWidth,
double  fImageHeight 
)

Create a surface from any image, at a given size. If the image is given by its sole name, it is searched inside the current theme root folder.

Parameters
cImageFilepath or name of an image.
fImageWidththe desired surface width.
fImageHeightthe desired surface height.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_create_surface_from_icon ( const gchar *  cImagePath,
double  fImageWidth,
double  fImageHeight 
)

Create a surface from any image, at a given size. If the image is given by its sole name, it is searched inside the icons themes known by Cairo-Dock.

Parameters
cImagePathpath or name of an image.
fImageWidththe desired surface width.
fImageHeightthe desired surface height.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_create_surface_from_pattern ( const gchar *  cImageFile,
double  fImageWidth,
double  fImageHeight,
double  fAlpha 
)

Create a surface at a given size, and fill it with a pattern. If the pattern image is given by its sole name, it is searched inside the current theme root folder.

Parameters
cImageFilepath or name of an image that will be repeated to fill the surface.
fImageWidththe desired surface width.
fImageHeightthe desired surface height.
fAlphatransparency of the pattern (1 means opaque).
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_rotate_surface ( cairo_surface_t *  pSurface,
double  fImageWidth,
double  fImageHeight,
double  fRotationAngle 
)

Create a surface by rotating another. Only works for 1/4 of rounds.

Parameters
pSurfacesurface to rotate.
fImageWidththe width of the surface.
fImageHeightthe height of the surface.
fRotationAnglerotation angle to apply, in radians.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_create_surface_from_text_full ( const gchar *  cText,
GldiTextDescription pLabelDescription,
double  fMaxScale,
int  iMaxWidth,
int *  iTextWidth,
int *  iTextHeight 
)

Create a surface representing a text, according to a given text description.

Parameters
cTextthe text.
pLabelDescriptiondescription of the text rendering.
fMaxScalemaximum zoom of the text.
iMaxWidthmaximum authorized width for the surface; it will be zoomed in to fits this limit. 0 for no limit.
iTextWidthwill be filled the width of the resulting surface.
iTextHeightwill be filled the height of the resulting surface.
Returns
the newly allocated surface.
cairo_surface_t* cairo_dock_duplicate_surface ( cairo_surface_t *  pSurface,
double  fWidth,
double  fHeight,
double  fDesiredWidth,
double  fDesiredHeight 
)

Create a surface identical to another, possibly resizing it.

Parameters
pSurfacesurface to duplicate.
fWidththe width of the surface.
fHeightthe height of the surface.
fDesiredWidthdesired width of the copy (0 to keep the same size).
fDesiredHeightdesired height of the copy (0 to keep the same size).
Returns
the newly allocated surface.