void PsImageText8( DrawablePtr pDrawable, GCPtr pGC, int x, int y, int count, char *string) { if( pDrawable->type==DRAWABLE_PIXMAP ) { DisplayElmPtr elm; PixmapPtr pix = (PixmapPtr)pDrawable; PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; DisplayListPtr disp; GCPtr gc; if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; disp = PsGetFreeDisplayBlock(priv); elm = &disp->elms[disp->nelms]; elm->type = TextI8Cmd; elm->gc = gc; elm->c.text8.x = x; elm->c.text8.y = y; elm->c.text8.count = count; elm->c.text8.string = (char *)xalloc(count); memcpy(elm->c.text8.string, string, count); disp->nelms += 1; } else { int iso; int siz; float mtx[4]; char *fnam; PsOutPtr psOut; ColormapPtr cMap; if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; PsOut_Offset(psOut, pDrawable->x, pDrawable->y); PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); fnam = PsGetPSFontName(pGC->font); if( !fnam ) return; siz = PsGetFontSize(pGC->font, mtx); iso = PsIsISOLatin1Encoding(pGC->font); if( !siz ) PsOut_TextAttrsMtx(psOut, fnam, mtx, iso); else PsOut_TextAttrs(psOut, fnam, siz, iso); PsOut_Text(psOut, x, y, string, count, PsGetPixelColor(cMap, pGC->bgPixel)); } }
void PsPolyLine( DrawablePtr pDrawable, GCPtr pGC, int mode, int nPoints, xPoint *pPoints) { if( pDrawable->type==DRAWABLE_PIXMAP ) { DisplayElmPtr elm; PixmapPtr pix = (PixmapPtr)pDrawable; PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; DisplayListPtr disp; GCPtr gc; if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; disp = PsGetFreeDisplayBlock(priv); elm = &disp->elms[disp->nelms]; elm->type = PolyLineCmd; elm->gc = gc; elm->c.polyPts.mode = mode; elm->c.polyPts.nPoints = nPoints; elm->c.polyPts.pPoints = (xPoint *)xalloc(nPoints*sizeof(xPoint)); memcpy(elm->c.polyPts.pPoints, pPoints, nPoints*sizeof(xPoint)); disp->nelms += 1; } else { int i; PsOutPtr psOut; PsPointPtr pts; ColormapPtr cMap; if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; PsOut_Offset(psOut, pDrawable->x, pDrawable->y); PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); PsLineAttrs(psOut, pGC, cMap); pts = (PsPointPtr)xalloc(sizeof(PsPointRec)*nPoints); if( mode==CoordModeOrigin ) { for( i=0 ; i<nPoints ; i++ ) { pts[i].x = pPoints[i].x; pts[i].y = pPoints[i].y; } } else { pts[0].x = pPoints[0].x; pts[0].y = pPoints[0].y; for( i=1 ; i<nPoints ; i++ ) { pts[i].x = pts[i-1].x+pPoints[i].x; pts[i].y = pts[i-1].y+pPoints[i].y; } } PsOut_Lines(psOut, nPoints, pts); xfree(pts); } }
void PsPolySegment( DrawablePtr pDrawable, GCPtr pGC, int nSegments, xSegment *pSegments) { if( pDrawable->type==DRAWABLE_PIXMAP ) { DisplayElmPtr elm; PixmapPtr pix = (PixmapPtr)pDrawable; PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; DisplayListPtr disp; GCPtr gc; if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; disp = PsGetFreeDisplayBlock(priv); elm = &disp->elms[disp->nelms]; elm->type = PolySegmentCmd; elm->gc = gc; elm->c.segments.nSegments = nSegments; elm->c.segments.pSegments = (xSegment *)xalloc(nSegments*sizeof(xSegment)); memcpy(elm->c.segments.pSegments, pSegments, nSegments*sizeof(xSegment)); disp->nelms += 1; } else { int i; PsOutPtr psOut; PsPointRec pts[2]; ColormapPtr cMap; if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; PsOut_Offset(psOut, pDrawable->x, pDrawable->y); PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); PsLineAttrs(psOut, pGC, cMap); for( i=0 ; i<nSegments ; i++ ) { pts[0].x = pSegments[i].x1; pts[0].y = pSegments[i].y1; pts[1].x = pSegments[i].x2; pts[1].y = pSegments[i].y2; PsOut_Lines(psOut, 2, pts); } } }
void PsPolyArc( DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc *pArcs) { if( pDrawable->type==DRAWABLE_PIXMAP ) { DisplayElmPtr elm; PixmapPtr pix = (PixmapPtr)pDrawable; PsPixmapPrivPtr priv = (PsPixmapPrivPtr)pix->devPrivate.ptr; DisplayListPtr disp; GCPtr gc; if ((gc = PsCreateAndCopyGC(pDrawable, pGC)) == NULL) return; disp = PsGetFreeDisplayBlock(priv); elm = &disp->elms[disp->nelms]; elm->type = PolyArcCmd; elm->gc = gc; elm->c.arcs.nArcs = nArcs; elm->c.arcs.pArcs = (xArc *)xalloc(nArcs*sizeof(xArc)); memcpy(elm->c.arcs.pArcs, pArcs, nArcs*sizeof(xArc)); disp->nelms += 1; } else { int i; PsOutPtr psOut; ColormapPtr cMap; if( PsUpdateDrawableGC(pGC, pDrawable, &psOut, &cMap)==FALSE ) return; PsOut_Offset(psOut, pDrawable->x, pDrawable->y); PsOut_Color(psOut, PsGetPixelColor(cMap, pGC->fgPixel)); PsLineAttrs(psOut, pGC, cMap); for( i=0 ; i<nArcs ; i++ ) { PsOut_DrawArc(psOut, (int)pArcs[i].x, (int)pArcs[i].y, (int)pArcs[i].width, (int)pArcs[i].height, (float)pArcs[i].angle1/64., (float)pArcs[i].angle2/64.); } } }
void PsLineAttrs( PsOutPtr psOut, GCPtr pGC, ColormapPtr cMap) { int i; int nDsh; int dshOff; int *dsh; PsCapEnum cap; PsJoinEnum join; switch(pGC->capStyle) { case CapButt: cap = PsCButt; break; case CapRound: cap = PsCRound; break; case CapProjecting: cap = PsCSquare; break; default: cap = PsCButt; break; } switch(pGC->joinStyle) { case JoinMiter: join = PsJMiter; break; case JoinRound: join = PsJRound; break; case JoinBevel: join = PsJBevel; break; default: join = PsJBevel; break; } if( pGC->lineStyle==LineSolid ) { nDsh = dshOff = 0; dsh = (int *)0; } else { nDsh = pGC->numInDashList; dshOff = pGC->dashOffset; if( !nDsh ) dsh = (int *)0; else { dsh = (int *)xalloc(sizeof(int)*nDsh); for( i=0 ; i<nDsh ; i++ ) dsh[i] = (int)pGC->dash[i]&0xFF; } } if( pGC->lineStyle!=LineDoubleDash ) PsOut_LineAttrs(psOut, (int)pGC->lineWidth, cap, join, nDsh, dsh, dshOff, -1); else PsOut_LineAttrs(psOut, (int)pGC->lineWidth, cap, join, nDsh, dsh, dshOff, PsGetPixelColor(cMap, pGC->bgPixel)); if( nDsh && dsh ) xfree(dsh); }