struct vGfx *vgOpenPostScript(int width, int height, char *fileName) /* Open up something that will someday be a PostScript file. */ { struct vGfx *vg = vgHalfInit(width, height); vg->data = pscmOpen(width, height, fileName); vg->close = (vg_close)pscmClose; vg->dot = (vg_dot)pscmDot; vg->box = (vg_box)pscmBox; vg->line = (vg_line)pscmLine; vg->text = (vg_text)pscmText; vg->textRight = (vg_textRight)pscmTextRight; vg->textCentered = (vg_textCentered)pscmTextCentered; vg->findColorIx = (vg_findColorIx)pscmFindColorIx; vg->colorIxToRgb = (vg_colorIxToRgb)pscmColorIxToRgb; vg->setClip = (vg_setClip)pscmSetClip; vg->unclip = (vg_unclip)pscmUnclip; vg->verticalSmear = (vg_verticalSmear)pscmVerticalSmear; vg->fillUnder = (vg_fillUnder)pscmFillUnder; vg->drawPoly = (vg_drawPoly)pscmDrawPoly; vg->setHint = (vg_setHint)pscmSetHint; vg->getHint = (vg_getHint)pscmGetHint; vg->getFontPixelHeight = (vg_getFontPixelHeight)pscmGetFontPixelHeight; vg->getFontStringWidth = (vg_getFontStringWidth)pscmGetFontStringWidth; vg->setWriteMode = (vg_setWriteMode)pscmSetWriteMode; return vg; }
struct vGfx *vgOpenPng(int width, int height, char *fileName, boolean useTransparency) /* Open up something that will write out a PNG file upon vgClose. * If useTransparency, then the first color in memgfx's colormap/palette is * assumed to be the image background color, and pixels of that color * are made transparent. */ { struct memPng *png; struct memGfx *mg; struct vGfx *vg; /* Set up virtual graphics with memory methods. */ vg = vgHalfInit(width, height); vgMgMethods(vg); vg->close = (vg_close)memPngClose; /* Get our mg + fileName structure. We're forcing * inheritence from mg essentially. */ AllocVar(png); png->fileName = cloneString(fileName); png->useTransparency = useTransparency; /* Fill in the mg part of this structure with normal memGfx. */ mg = mgNew(width, height); if (png->useTransparency) mgClearPixelsTrans(mg); else mgClearPixels(mg); png->mg = *mg; freez(&mg); /* We don't need this copy any more. */ vg->data = png; return vg; }
struct vGfx *vgOpenGif(int width, int height, char *fileName, boolean useTransparency) /* Open up something that will someday be a PostScript file. */ { struct memGif *gif; struct memGfx *mg; struct vGfx *vg; /* Set up virtual graphics with memory methods. */ vg = vgHalfInit(width, height); vgMgMethods(vg); vg->close = (vg_close)memGifClose; /* Get our mg + fileName structure. We're forcing * inheritence from mg essentially. */ AllocVar(gif); gif->fileName = cloneString(fileName); gif->useTransparency = useTransparency; /* Fill in the mg part of this structure with normal memGfx. */ mg = mgNew(width, height); mgClearPixels(mg); gif->mg = *mg; freez(&mg); /* We don't need this copy any more. */ vg->data = gif; return vg; }