home *** CD-ROM | disk | FTP | other *** search
- /*
- pmapdecl.h
-
- % declarations for pixel maps
-
- OWL 1.1
- Copyright (c) 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 2/04/89 ted: Moved device-specific stuff into dig level (dpmap_Control)
- 2/23/88 ted: Added pmap_Copy.
- 5/09/89 ted Changed Alloc/Free terms to Open/Close.
- 7/05/89 ted Added pmap_IoInit macros and related stuff.
- 7/12/89 ted Converted '_func' prototypes from typedef to macro.
- 8/08/89 ted Added bmap stuff.
- */
- /* -------------------------------------------------------------------------- */
- /* Bitmap stuff */
- #define bmap_GetArraySize(w,h) ((h) * (((w) + 7) / 8))
- #define bmap_GetSize(w,h) (bmap_GetArraySize(w, h) + 2*sizeof(odim))
- #define bmap_GetLineBytes(bm) (((bm)->width + 7) / 8)
- #define bmap_GetLine(bm,l) ((bm)->array + (l) * bmap_GetLineBytes(bm))
-
- #define bmap_struct(w, h) \
- struct {odim width; odim height; byte array[bmap_GetArraySize(w, h)];}
-
- typedef bmap_struct(1,1) *bmap_type;
- /* -------------------------------------------------------------------------- */
-
- typedef struct pmap_struct {
- odim width; /* width of pixmap in pixels */
- odim height; /* height of pixmap in pixels */
- boolean onboard; /* to request pixmap in display memory */
- boolean onscreen; /* if onboard, to request pixmap in visible display */
- opcoord xpos, ypos; /* if onscreen, position of requested pixmap on screen */
- VOID *xdata; /* pointer to implementation-specific data */
- } *pmap_type;
-
- typedef struct pmap_struct pmapreq_struct;
-
- typedef struct {
- pmap_type pmap;
- opixval color;
- } pmapclearreq_struct;
-
- typedef struct {
- pmap_type spmap;
- pmap_type dpmap;
- } pmapcopyreq_struct;
-
- #define pmapioreq_func(fname) int fname(_arg3(int msg, VOID *indata, VOID *outdata))
- typedef pmapioreq_func ((*pmapioreq_fptr));
- /* -------------------------------------------------------------------------- */
- /* pmap.c */
- extern pmap_type pmap_OpenOnboard(_arg6(odim width, odim height,
- boolean onboard, boolean onscreen, opcoord xpos, opcoord ypos));
- extern void pmap_Clear(_arg2(pmap_type pmap, opixval color));
- extern void pmap_Copy(_arg2(pmap_type dpmap, pmap_type spmap));
-
- /* pmapload.c */
- extern pmap_type pmap_LoadBfile(_arg3(VOID *bfile, char *name, ocolmap_type crange));
- extern pmap_type pmap_Load(_arg2(FILE *fd, ocolmap_type crange));
- extern boolean pmap_SaveBfile(_arg4(VOID *bfile, char *name, pmap_type pmap, ocolmap_type crange));
- extern boolean pmap_Save(_arg3(FILE *fd, pmap_type pmap, ocolmap_type crange));
- extern void pmap_IoInitFunc(_arg1(pmapioreq_fptr iofunc));
- extern pmapioreq_func (pmap_IoNullReq);
- /* -------------------------------------------------------------------------- */
-
- #define pmap_Open(width, height) pmap_OpenOnboard(width, height, FALSE, FALSE, 0, 0)
- #define pmap_Close(pmap) pmap_Control(PC_CLOSEPMAP, pmap, NULL)
-
- #define pmap_GetWidth(pmap) ((pmap)->width)
- #define pmap_GetHeight(pmap) ((pmap)->height)
-
- #define pmap_clippoint(pmap,xp,yp) \
- opwh_clippoint(pmap_GetWidth(pmap), pmap_GetHeight(pmap), (xp), (yp))
- #define pmap_clipbox(pmap,boxp) \
- opwh_clipbox(pmap_GetWidth(pmap), pmap_GetHeight(pmap), (boxp))
-
- /* This pmap_Ok macro assumes that a valid pixel map will:
- - have its boolean variable values either 0 or 1.
- - have its xpos set non-negative.
- - have its xpos non-zero if onboard is FALSE
- */
- #define pmap_Ok(pm) ((pm) != NULL && \
- ((unsigned)(pm)->onboard) <= 1 && \
- ((unsigned)(pm)->onscreen) <= 1 && \
- ( ((pm)->onboard == FALSE) ? ((pm)->xpos > 0) : ((pm)->xpos >= 0) ))
-
- #define pmap_IoInit() pmap_IoInitFunc(def_PmapIoReq)
- /* -------------------------------------------------------------------------- */
-
-