作者EarlEco.bbs@ptt.cc (Earl) 看板: mud
標題Re: ●種因業報誰能免
時間批踢踢實業 (2008/06/24 Tue 20:19:12)
: 噓 elchack:掰...... 06/24 16:47
: 噓 EarlEco:我才不會忘記你的呢! 06/24 18:08
: → camerdy:?? 06/24 18:39
/*----------------------------------------------------------*/
/* Colourmap creation sample programme: X11 interface */
/*----------------------------------------------------------*/
#include <karma.h>
#include <karma_kcmap.h>
#include <karma_xc.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#define DEFAULT_COLOURMAP_NAME "Greyscale1"
#define MAX_COLOURS (unsigned int) 200
Kcolourmap setup_cmap (dpy, window)
/* This routine will create a Kcolourmap object from an X11 display.
The X display must be given by dpy .
The X window must be given by window .
The routine returns a Kcolourmap object.
*/
Display *display;
Window window;
{
/* Declare variables */
Kdisplay dpy_handle;
XWindowAttributes window_attributes;
Kcolourmap cmap;
/* Get X colourmap ID */
XGetWindowAttributes (display, win, &window_attributes);
/* Initialise colourmap system */
dpy_handle = xc_get_dpy_handle (display, window_attributes.colormap);
/* Create Kcolourmap object */
cmap = kcmap_va_create (DEFAULT_COLOURMAP_NAME, MAX_COLOURS, TRUE,
dpy_handle, xc_alloc_colours, xc_free_colours,
xc_store_colours, xc_get_location,
KCMAP_ATT_END);
return (cmap);
} /* End Function setup_cmap */
Example 2
This example shows how to initialise the colourmap system for a VX display,
and then create a colourmap.
/*----------------------------------------------------------*/
/* Colourmap creation sample programme: VX interface */
/*----------------------------------------------------------*/
#include <karma.h>
#include <karma_kcmap.h>
#include <karma_vc.h>
#define DEFAULT_COLOURMAP_NAME "Greyscale1"
#define MAX_COLOURS (unsigned int) 200
Kcolourmap setup_cmap ()
/* This routine will create a Kcolourmap object from a VX display.
The routine returns a Kcolourmap object.
*/
{
/* Declare variables */
Kdisplay dpy_handle;
Kcolourmap cmap;
/* Initialise colourmap system */
dpy_handle = vc_get_dpy_handle ();
/* Create Kcolourmap object */
cmap = kcmap_va_create (DEFAULT_COLOURMAP_NAME, MAX_COLOURS, TRUE,
dpy_handle, vc_alloc_colours, vc_free_colours,
vc_store_colours, vc_get_location,
KCMAP_ATT_END);
return (cmap);
} /* End Function setup_cmap */
Example 3
This example shows how to save a colourmap to a file.
/*----------------------------------------------------------*/
/* Colourmap save routine: */
/*----------------------------------------------------------*/
#include <karma.h>
#include <karma_kcmap.h>
#include <karma_ds.h>
flag write_cmap (cmap, file)
/* This routine will write a Kcolourmap object to a file.
The colourmap must be given by cmap .
The filename must be pointed to by file .
The routine returns TRUE on success, else it returns FALSE.
*/
Kcolourmap cmap;
char *file;
{
flag ok;
multi_array *multi_desc;
multi_desc = ds_alloc_multi (1);
if ( !kcmap_copy_to_struct (cmap, multi_desc->headers,
multi_desc->data) ) return (FALSE);
ok = dsxfr_put_multi (multi_desc, file);
multi_desc->headers[0] = NULL;
multi_desc->data[0] = NULL;
ds_dealloc_multi (multi_desc);
return (ok);
} /* End Function write_cmap */
--
阿古,卡照和達印今天怎麼沒來學校的拉!!
阿古:「卡照和達印今天跟他阿爸喝小米酒的拉!!!」
卡照:「阿古,達印和阿女烏在電線桿抖來抖去的拉!!」
阿古:「是不是他們吃東西拉肚子的拉??」
阿古:「他們被電線桿電到的拉,連裙子都掉下來的拉!!」
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.84.178.122