SR Research Support Site
Macros | Functions
Utility function to save bitmaps

Macros

#define BX_AVERAGE   0
 
#define BX_DARKEN   1
 
#define BX_LIGHTEN   2
 
#define BX_MAXCONTRAST   4
 
#define BX_NODITHER   8
 
#define BX_GRAYSCALE   16
 
#define BX_TXFILE   32
 
#define BX_DOTRANSFER   256
 
#define SV_NOREPLACE   1
 
#define SV_MAKEPATH   2
 

Functions

int el_bitmap_save_and_backdrop (EYEBITMAP *hbm, INT16 xs, INT16 ys, INT16 width, INT16 height, const char *fname, const char *path, INT16 sv_options, INT16 xd, INT16 yd, UINT16 xferoptions)
 
int el_bitmap_to_backdrop (EYEBITMAP *hbm, INT16 xs, INT16 ys, INT16 width, INT16 height, INT16 xd, INT16 yd, UINT16 xferoptions)
 
int el_bitmap_save (EYEBITMAP *hbm, INT16 xs, INT16 ys, INT16 width, INT16 height, char *fname, char *path, INT16 sv_options)
 
int set_write_image_hook (int(*hookfn)(char *outfilename, int format, EYEBITMAP *bitmap), int options)
 

Detailed Description

Macro Definition Documentation

#define BX_AVERAGE   0

Average combined pixels

#define BX_DARKEN   1

Choose darkest (keep thin dark lines)

#define BX_DOTRANSFER   256

Send bitmap to host

#define BX_GRAYSCALE   16

Gray scale

#define BX_LIGHTEN   2

Choose darkest (keep thin white lines)

#define BX_MAXCONTRAST   4

Stretch contrast to black->white

#define BX_NODITHER   8

No dither, just quantize

#define BX_TXFILE   32

Transfer and draw to host using tcp

#define SV_MAKEPATH   2

make destination path if does not already exists

#define SV_NOREPLACE   1

do not replace if the file already exists

Function Documentation

int el_bitmap_save ( EYEBITMAP hbm,
INT16  xs,
INT16  ys,
INT16  width,
INT16  height,
char *  fname,
char *  path,
INT16  sv_options 
)

This function saves the entire bitmap or selected part of a bitmap in an image file (with an extension of .png, .bmp, .jpg, or .tif). It creates the specified file if this file does not exist.

Parameters
hbmBitmap to save or transfer or both.
xsX position.
ysY position.
widthWidth.
heightHeight.
fnameFile name to save as. The extension decides the format of the file.
pathThe directory to which the file will be written.
sv_optionsIf the file exists, it replaces the file unless SV_NOREPLACE is specified.
Remarks
This function relies on the writeImageHook set by call to set_write_image_hook() to write the images in different formats. By default, if eyelink_core_graphics library is used, gd library is used to write the images and if eyelink_gdi_graphics is used FreeImage library is used to write the images. If neither one of them is used, call to this function does not write the images unless, set_write_image_hook() is used to set the writeImageHook.
This function should not be called when timing is critical, as this might take very long to return.
int el_bitmap_save_and_backdrop ( EYEBITMAP hbm,
INT16  xs,
INT16  ys,
INT16  width,
INT16  height,
const char *  fname,
const char *  path,
INT16  sv_options,
INT16  xd,
INT16  yd,
UINT16  xferoptions 
)

This function saves the entire bitmap as a .BMP, .JPG, .PNG, or .TIF file, and transfers the image to tracker as backdrop for gaze cursors.

Parameters
hbmBitmap to save or transfer or both.
xsX position.
ysY position.
widthWidth.
heightHeight.
fnameFile name to save as. The extension decides the format of the file.
pathThe directory to which the file will be written.
sv_optionsIf the file exists, it replaces the file unless SV_NOREPLACE is specified.
xdX position.
ydY position.
xferoptionsTransfer options set with bitwise OR of the following constants, determines how bitmap is processed:
  • BX_AVERAGE Averaging combined pixels
  • BX_DARKEN Choosing darkest and keep thin dark lines.
  • BX_LIGHTEN Choosing darkest and keep thin white lines and control how bitmap size is reduced to fit tracker display.
  • BX_MAXCONTRAST Maximizes contrast for clearest image.
  • BX_NODITHER Disables the dithering of the image.
  • BX_GREYSCALE Converts the image to grayscale (grayscale works best for EyeLink I, text, etc.).
See also
el_bitmap_to_backdrop(), el_bitmap_save(), sdl_bitmap_to_backdrop(), sdl_bitmap_save(),sdl_bitmap_save_and_backdrop, gdi_bitmap_to_backdrop(), gdi_bitmap_save(),gdi_bitmap_save_and_backdrop, bitmap_save(), and bitmap_to_backdrop() for more information.
Remarks
This function relies on the writeImageHook set by call to set_write_image_hook() to write the images in different formats. By default, if eyelink_core_graphics library is used, gd library is used to write the images and if eyelink_gdi_graphics is used FreeImage library is used to write the images. If neither one of them is used, call to this function does not write the images unless, set_write_image_hook() is used to set the writeImageHook.
This function should not be called when timing is critical, as this might take very long to return.
int el_bitmap_to_backdrop ( EYEBITMAP hbm,
INT16  xs,
INT16  ys,
INT16  width,
INT16  height,
INT16  xd,
INT16  yd,
UINT16  xferoptions 
)

This function transfers the bitmap to the tracker PC as backdrop for gaze cursors.

Parameters
hbmBitmap to save or transfer or both.
xsX position.
ysY position.
widthWidth.
heightHeight.
xdX position.
ydY position.
xferoptionsTransfer options set with bitwise OR of the following constants, determines how bitmap is processed:
  • BX_AVERAGE Averaging combined pixels
  • BX_DARKEN Choosing darkest and keep thin dark lines.
  • BX_LIGHTEN Choosing darkest and keep thin white lines and control how bitmap size is reduced to fit tracker display.
  • BX_MAXCONTRAST Maximizes contrast for clearest image.
  • BX_NODITHER Disables the dithering of the image.
  • BX_GREYSCALE Converts the image to grayscale (grayscale works best for EyeLink I, text, etc.).
See also
sdl_bitmap_to_backdrop(), el_bitmap_save_and_backdrop(), sdl_bitmap_save_and_backdrop(), gdi_bitmap_to_backdrop(), gdi_bitmap_save_and_backdrop(), and bitmap_to_backdrop() for more information.
Remarks
This function should not be called when timing is critical, as this might take very long to return.
int set_write_image_hook ( int(*)(char *outfilename, int format, EYEBITMAP *bitmap)  hookfn,
int  options 
)

Use this function to set function pointer, so that the call to el_bitmap_save and el_bitmap_save_and_backdrop will use the passed in function to write the image to disk.


Copyright ©2002-2023, SR Research Ltd.