📄 client.c
字号:
* GrSetGCFont: * @gc: the ID of the graphics context to set the font of * @font: the ID of the font * * Sets the font to be used for text drawing in the specified graphics * context to the specified font ID. */voidGrSetGCFont(GR_GC_ID gc, GR_FONT_ID font){ nxSetGCFontReq *req; req = AllocReq(SetGCFont); req->gcid = gc; req->fontid = font;}/** * GrLine: * @id: the ID of the drawable to draw the line on * @gc: the ID of the graphics context to use when drawing the line * @x1: the X coordinate of the start of the line relative to the drawable * @y1: the Y coordinate of the start of the line relative to the drawable * @x2: the X coordinate of the end of the line relative to the drawable * @y2: the Y coordinate of the end of the line relative to the drawable * * Draws a line using the specified graphics context on the specified drawable * from (x1, y1) to (x2, y2), with coordinates given relative to the drawable. */void GrLine(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x1, GR_COORD y1, GR_COORD x2, GR_COORD y2){ nxLineReq *req; req = AllocReq(Line); req->drawid = id; req->gcid = gc; req->x1 = x1; req->y1 = y1; req->x2 = x2; req->y2 = y2;}/** * GrRect: * @id: the ID of the drawable to draw the rectangle on * @gc: the ID of the graphics context to use when drawing the rectangle * @x: the X coordinate of the rectangle relative to the drawable * @y: the Y coordinate of the rectangle relative to the drawable * @width: the width of the rectangle * @height: the height of the rectangle * * Draw the boundary of a rectangle of the specified dimensions and position * on the specified drawable using the specified graphics context. */void GrRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height){ nxRectReq *req; req = AllocReq(Rect); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->width = width; req->height = height;}/** * GrFillRect: * @id: the ID of the drawable to draw the rectangle on * @gc: the ID of the graphics context to use when drawing the rectangle * @x: the X coordinate of the rectangle relative to the drawable * @y: the Y coordinate of the rectangle relative to the drawable * @width: the width of the rectangle * @height: the height of the rectangle * * Draw a filled rectangle of the specified dimensions and position on the * specified drawable using the specified graphics context. */void GrFillRect(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height){ nxFillRectReq *req; req = AllocReq(FillRect); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->width = width; req->height = height;}/** * GrEllipse: * @id: the ID of the drawable to draw the ellipse on * @gc: the ID of the graphics context to use when drawing the ellipse * @x: the X coordinate to draw the ellipse at relative to the drawable * @y: the Y coordinate to draw the ellipse at relative to the drawable * @rx: the radius of the ellipse on the X axis * @ry: the radius of the ellipse on the Y axis * * Draws the boundary of ellipse at the specified position using the specified * dimensions and graphics context on the specified drawable. */void GrEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx, GR_SIZE ry){ nxEllipseReq *req; req = AllocReq(Ellipse); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->rx = rx; req->ry = ry;}/** * GrFillEllipse: * @id: the ID of the drawable to draw the filled ellipse on * @gc: the ID of the graphics context to use when drawing the ellipse * @x: the X coordinate to draw the ellipse at relative to the drawable * @y: the Y coordinate to draw the ellipse at relative to the drawable * @rx: the radius of the ellipse on the X axis * @ry: the radius of the ellipse on the Y axis * * Draws a filled ellipse at the specified position using the specified * dimensions and graphics context on the specified drawable. */void GrFillEllipse(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx, GR_SIZE ry){ nxFillEllipseReq *req; req = AllocReq(FillEllipse); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->rx = rx; req->ry = ry;}/** * GrArc: * @id: the ID of the drawable to draw the arc on * @gc: the graphics context to use when drawing the arc * @x: the X coordinate to draw the arc at relative to the drawable * @y: the Y coordinate to draw the arc at relative to the drawable * @rx: the radius of the arc on the X axis * @ry: the radius of the arc on the Y axis * @ax: the X coordinate of the start of the arc relative to the drawable * @ay: the Y coordinate of the start of the arc relative to the drawable * @bx: the X coordinate of the end of the arc relative to the drawable * @by: the Y coordinate of the end of the arc relative to the drawable * @type: the fill style to use when drawing the arc * * Draws an arc with the specified dimensions at the specified position * on the specified drawable using the specified graphics context. * The type specifies the fill type. Possible values include GR_ARC and * GR_PIE. */void GrArc(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx, GR_SIZE ry, GR_COORD ax, GR_COORD ay, GR_COORD bx, GR_COORD by, int type){ nxArcReq *req; req = AllocReq(Arc); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->rx = rx; req->ry = ry; req->ax = ax; req->ay = ay; req->bx = bx; req->by = by; req->type = type;}/** * GrArcAngle: * @id: the ID of the drawable to draw the arc on * @gc: the graphics context to use when drawing the arc * @x: the X coordinate to draw the arc at relative to the drawable * @y: the Y coordinate to draw the arc at relative to the drawable * @rx: the radius of the arc on the X axis * @ry: the radius of the arc on the Y axis * @angle1: the angle of the start of the arc * @angle2: the angle of the end of the arc * @type: the fill style to use when drawing the arc * * Draws an arc with the specified dimensions at the specified position * on the specified drawable using the specified graphics context. * The type specifies the fill type. Possible values include GR_ARC and * GR_PIE. This function requires floating point support, and is slightly * slower than the GrArc() function which does not require floating point. */voidGrArcAngle(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE rx, GR_SIZE ry, GR_COORD angle1, GR_COORD angle2, int type){ nxArcAngleReq *req; req = AllocReq(ArcAngle); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->rx = rx; req->ry = ry; req->angle1 = angle1; req->angle2 = angle2; req->type = type;}/** * GrBitmap: * @id: the ID of the drawable to draw the bitmap onto * @gc: the ID of the graphics context to use when drawing the bitmap * @x: the X coordinate to draw the bitmap at relative to the drawable * @y: the Y coordinate to draw the bitmap at relative to the drawable * @width: the width of the bitmap * @height: the height of the bitmap * @bitmaptable: pointer to the bitmap data * * Draws the monochrome bitmap data provided in the bitmaptable argument * at the specified position on the specified drawable using the specified * graphics context. Note that the bitmap data should be an array of aligned * 16 bit words. The usebackground flag in the graphics context specifies * whether to draw the background colour wherever a bit value is zero. */void GrBitmap(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, GR_BITMAP *bitmaptable){ nxBitmapReq *req; long bitmapsize; bitmapsize = (long)GR_BITMAP_SIZE(width, height) * sizeof(GR_BITMAP); req = AllocReqExtra(Bitmap, bitmapsize); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->width = width; req->height = height; memcpy(GetReqData(req), bitmaptable, bitmapsize);}/** * GrDrawImageBits: * @id: the ID of the drawable to draw the image onto * @gc: the ID of the graphics context to use when drawing the image * @x: the X coordinate to draw the image at relative to the drawable * @y: the Y coordinate to draw the image at relative to the drawable * @pimage: pointer to the image structure * * Draws the image contained in the specified image structure onto the * specified drawable at the specified coordinates using the specified * graphics context. */voidGrDrawImageBits(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_IMAGE_HDR *pimage){ nxDrawImageBitsReq *req; int imagesize; int palsize; char *addr; imagesize = pimage->pitch * pimage->height; palsize = pimage->palsize * sizeof(MWPALENTRY); req = AllocReqExtra(DrawImageBits, imagesize + palsize); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; /* fill MWIMAGEHDR items passed externally*/ req->width = pimage->width; req->height = pimage->height; req->planes = pimage->planes; req->bpp = pimage->bpp; req->pitch = pimage->pitch; req->bytesperpixel = pimage->bytesperpixel; req->compression = pimage->compression; req->palsize = pimage->palsize; req->transcolor = pimage->transcolor; addr = GetReqData(req); memcpy(addr, pimage->imagebits, imagesize); memcpy(addr+imagesize, pimage->palette, palsize);}/** * GrDrawImageFromFile: * @id: the ID of the drawable to draw the image onto * @gc: the ID of the graphics context to use when drawing the image * @x: the X coordinate to draw the image at relative to the drawable * @y: the Y coordinate to draw the image at relative to the drawable * @width: the maximum image width * @height: the maximum image height * @path: string containing the filename of the image to load * @flags: flags specific to the particular image loader * * Loads the specified image file and draws it at the specified position * on the specified drawable using the specified graphics context. The * width and height values specify the size of the image to draw- if the * actual image is a different size, it will be scaled to fit. The image type * is automatically detected using the magic numbers in the image header (ie. * the filename extension is irrelevant). The currently supported image types * include GIF, JPEG, Windows BMP, PNG, XPM, and both ascii and binary * variants of PBM, PGM, and PPM. However the image types supported by a * particular server depend on which image types were enabled in the server * configuration at build time. */voidGrDrawImageFromFile(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, char* path, int flags){ nxDrawImageFromFileReq *req; req = AllocReqExtra(DrawImageFromFile, strlen(path)+1); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->width = width; req->height = height; req->flags = flags; memcpy(GetReqData(req), path, strlen(path)+1);}/** * GrLoadImageFromFile: * @path: string containing the filename of the image to load * @flags: flags specific to the particular image loader * @Returns: ID of the image buffer the image was loaded into * * Loads the specified image file into a newly created server image buffer * and returns the ID of the buffer. The image type is automatically detected * using the magic numbers in the image header (ie. the filename extension is * irrelevant). The currently supported image types include GIF, JPEG, Windows * BMP, PNG, XPM, and both ascii and binary variants of PBM, PGM, and PPM. * However the image types supported by a particular server depend on which * image types were enabled in the server configuration at build time. */GR_IMAGE_IDGrLoadImageFromFile(char *path, int flags){ nxLoadImageFromFileReq *req; GR_IMAGE_ID imageid; req = AllocReqExtra(LoadImageFromFile, strlen(path)+1); req->flags = flags; memcpy(GetReqData(req), path, strlen(path)+1); if(GrTypedReadBlock(&imageid, sizeof(imageid), GrNumLoadImageFromFile) == -1) return 0; return imageid;}/** * GrDrawImageToFit: * @id: the ID of the drawable to draw the image onto * @gc: the ID of the graphics context to use when drawing the image * @x: the X coordinate to draw the image at relative to the drawable * @y: the Y coordinate to draw the image at relative to the drawable * @width: the maximum image width * @height: the maximum image height * @imageid: the ID of the image buffer containing the image to display * * Draws the image from the specified image buffer at the specified position * on the specified drawable using the specified graphics context. The * width and height values specify the size of the image to draw- if the * actual image is a different size, it will be scaled to fit. */ voidGrDrawImageToFit(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, GR_IMAGE_ID imageid){ nxDrawImageToFitReq *req; req = AllocReq(DrawImageToFit); req->drawid = id; req->gcid = gc; req->x = x; req->y = y; req->width = width; req->height = height; req->imageid = imageid;}/** * GrFreeImage: * @id: ID of the image buffer to free * * Destroys the specified image buffer and reclaims the memory used by it. */voidGrFreeImage(GR_IMAGE_ID id){ nxFreeImageReq *req; req = AllocReq(FreeImage); req->id = id;}/** * GrGetImageInfo: * @id: ID of an image buffer * @iip: pointer to a GR_IMAGE_INFO structure * * Fills in the specified image information structure with the details of the * specified image buffer. */voidGrGetImageInfo(GR_IMAGE_ID id, GR_IMAGE_INFO *iip){ nxGetImageInfoReq *req; req = AllocReq(GetImageInfo); req->id = id; GrTypedReadBlock(iip, sizeof(GR_IMAGE_INFO), GrNumGetImageInfo);}static int sendImageBuffer(void *buffer, int size) { int bufid; int bufsize = size; void *bufptr = buffer; nxImageBufferAllocReq *alloc; nxImageBufferSendReq *send; /* Step 1 - Allocate a buffer on the other side */ alloc = AllocReq(ImageBufferAlloc); alloc->size = size; GrTypedReadBlock(&bufid, sizeof(bufid), GrNumImageBufferAlloc); if (bufid < 0) return(0); /* step 2 - Send the buffer across */ while(bufsize > 0) { int chunk = (MAXREQUESTSZ - sizeof(nxImageBufferSendReq)); if (chunk > bufsize) chunk=bufsize; send = AllocReqExtra(ImageBufferSend, chunk); send->buffer_id = bufid; send->size = chunk; memcpy(GetReqData(send), bufptr, chunk); bufptr += chunk; bufsize -= chunk; } return(bufid);}GR_IMAGE_ID GrLoadImageFromBuffer(void *buffer, int size, int flags) { int bufid; nxLoadImageFromBufferReq *req; GR_IMAGE_ID imageid; /* Step 1 - Send the buffer to the other side */ bufid = sendImageBuffer(buffer, size); if (!bufid) return(0); /* Step 2 - Send the command to load the image */ /* Note - This will free the buffer automagically */ req = AllocReq(LoadImageFromBuffer); req->flags = flags; req->buffer = bufid; if(GrTypedReadBlock(&imageid, sizeof(imageid), GrNumLoadImageFromBuffer) == -1) return(0); else return(imageid);}void GrDrawImageFromBuffer(GR_DRAW_ID id, GR_GC_ID gc, GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height, void *buffer, int
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -