From 6c85243ff859071be4fd2a3847b0fc2086206d31 Mon Sep 17 00:00:00 2001 From: Martin Kretzschmar Date: Mon, 17 May 2004 19:37:57 +0000 Subject: Imported Xpdf 3.00 and fixed build. * ANNOUNCE: * CHANGES: * Makefile.am: * README: * aconf-win32.h: * configure.in: * dj_make.bat: * doc/pdffonts.1: * doc/pdffonts.cat: * doc/pdffonts.hlp: * doc/pdfimages.1: * doc/pdfimages.cat: * doc/pdfimages.hlp: * doc/pdfinfo.1: * doc/pdfinfo.cat: * doc/pdfinfo.hlp: * doc/pdftopbm.1: * doc/pdftopbm.cat: * doc/pdftopbm.hlp: * doc/pdftops.1: * doc/pdftops.cat: * doc/pdftops.hlp: * doc/pdftotext.1: * doc/pdftotext.cat: * doc/pdftotext.hlp: * doc/xpdf.1: * doc/xpdf.cat: * doc/xpdf.hlp: * doc/xpdfrc.5: * doc/xpdfrc.cat: * doc/xpdfrc.hlp: * fofi/Makefile.in: * goo/GHash.cc: * goo/GHash.h: * ms_make.bat: * splash/Makefile.in: * xpdf/DisplayFontTable.h: * xpdf/ErrorCodes.h: * xpdf/FTFont.cc: * xpdf/FTFont.h: * xpdf/FontFile.cc: * xpdf/FontFile.h: * xpdf/Function.h: * xpdf/GPOutputDev.cc: * xpdf/Gfx.cc: * xpdf/Gfx.h: * xpdf/GfxFont.cc: * xpdf/GfxFont.h: * xpdf/GfxState.cc: * xpdf/GfxState.h: * xpdf/GlobalParams.cc: * xpdf/GlobalParams.h: * xpdf/Makefile.am: * xpdf/Object.cc: * xpdf/Object.h: * xpdf/Outline.cc: * xpdf/OutputDev.cc: * xpdf/OutputDev.h: * xpdf/PBMOutputDev.cc: * xpdf/PBMOutputDev.h: * xpdf/PDFDoc.cc: * xpdf/PDFDoc.h: * xpdf/PSOutputDev.cc: * xpdf/PSOutputDev.h: * xpdf/Page.cc: * xpdf/Page.h: * xpdf/Parser.cc: * xpdf/SFont.cc: * xpdf/SFont.h: * xpdf/Stream.cc: * xpdf/Stream.h: * xpdf/T1Font.cc: * xpdf/T1Font.h: * xpdf/TTFont.cc: * xpdf/TTFont.h: * xpdf/TextOutputDev.cc: * xpdf/TextOutputDev.h: * xpdf/XOutputDev.cc: * xpdf/XOutputDev.h: * xpdf/XPixmapOutputDev.cc: * xpdf/XPixmapOutputDev.h: * xpdf/XRef.cc: * xpdf/XRef.h: * xpdf/config.h: * xpdf/gpdf-control.cc: * xpdf/pdffonts.cc: * xpdf/pdfimages.cc: * xpdf/pdfinfo.cc: * xpdf/pdftopbm.cc: * xpdf/pdftops.cc: * xpdf/pdftotext.cc: * xpdf/tests/Makefile.am: * xpdf/vms_make.com: * xpdf/xpdf.cc: Imported Xpdf 3.00 and fixed build. --- (limited to 'pdf/xpdf/PBMOutputDev.cc') diff --git a/pdf/xpdf/PBMOutputDev.cc b/pdf/xpdf/PBMOutputDev.cc deleted file mode 100644 index dde860a..0000000 --- a/pdf/xpdf/PBMOutputDev.cc +++ /dev/null @@ -1,162 +0,0 @@ -//======================================================================== -// -// PBMOutputDev.cc -// -// Copyright 1998-2003 Glyph & Cog, LLC -// -//======================================================================== - -#include - -#ifdef USE_GCC_PRAGMAS -#pragma implementation -#endif - -#include -#include -#include -#include -#include "gmem.h" -#include "GString.h" -#include "Object.h" -#include "Stream.h" -#include "GfxState.h" -#include "GfxFont.h" -#include "Error.h" -#include "PBMOutputDev.h" - -//------------------------------------------------------------------------ - -PBMOutputDev *PBMOutputDev::makePBMOutputDev(char *displayName, - char *fileRootA) { - Display *displayA; - Pixmap pixmapA; - Window dummyWinA; - int screenA; - int invertA; - unsigned long black, white; - PBMOutputDev *out; - - if (!(displayA = XOpenDisplay(displayName))) { - fprintf(stderr, "Couldn't open display '%s'\n", displayName); - exit(1); - } - screenA = DefaultScreen(displayA); - - black = BlackPixel(displayA, screenA); - white = WhitePixel(displayA, screenA); - if ((black & 1) == (white & 1)) { - fprintf(stderr, "Weird black/white pixel colors\n"); - XCloseDisplay(displayA); - return NULL; - } - invertA = (white & 1) == 1 ? 0xff : 0x00; - - dummyWinA = XCreateSimpleWindow(displayA, RootWindow(displayA, screenA), - 0, 0, 1, 1, 0, - black, white); - pixmapA = XCreatePixmap(displayA, dummyWinA, 1, 1, 1); - out = new PBMOutputDev(displayA, screenA, pixmapA, dummyWinA, - invertA, fileRootA); - return out; -} - -void PBMOutputDev::killPBMOutputDev(PBMOutputDev *out) { - Display *displayA; - Pixmap pixmapA; - Window dummyWinA; - - displayA = out->display; - pixmapA = out->pixmap; - dummyWinA = out->dummyWin; - - delete out; - - // these have to be done *after* the XOutputDev (parent of the - // PBMOutputDev) is deleted, since XOutputDev::~XOutputDev() needs - // them - XFreePixmap(displayA, pixmapA); - XDestroyWindow(displayA, dummyWinA); - XCloseDisplay(displayA); -} - -PBMOutputDev::PBMOutputDev(Display *displayA, int screenA, - Pixmap pixmapA, Window dummyWinA, - int invertA, char *fileRootA): - XOutputDev(displayA, screenA, - DefaultVisual(displayA, screenA), - DefaultColormap(displayA, screenA), - gFalse, - WhitePixel(displayA, DefaultScreen(displayA)), - gFalse, 1, 1) -{ - display = displayA; - screen = screenA; - pixmap = pixmapA; - dummyWin = dummyWinA; - invert = invertA; - fileRoot = fileRootA; - fileName = (char *)gmalloc(strlen(fileRoot) + 20); -} - -PBMOutputDev::~PBMOutputDev() { - gfree(fileName); -} - -void PBMOutputDev::startPage(int pageNum, GfxState *state) { - curPage = pageNum; - width = (int)(state->getPageWidth() + 0.5); - height = (int)(state->getPageHeight() + 0.5); - XFreePixmap(display, pixmap); - pixmap = XCreatePixmap(display, dummyWin, width, height, 1); - setPixmap(pixmap, width, height); - XOutputDev::startPage(pageNum, state); -} - -void PBMOutputDev::endPage() { - XImage *image; - FILE *f; - int p; - int x, y, i; - - image = XCreateImage(display, DefaultVisual(display, screen), - 1, ZPixmap, 0, NULL, width, height, 8, 0); - image->data = (char *)gmalloc(height * image->bytes_per_line); - XGetSubImage(display, pixmap, 0, 0, width, height, 1, ZPixmap, - image, 0, 0); - - sprintf(fileName, "%s-%06d.pbm", fileRoot, curPage); - if (!(f = fopen(fileName, "wb"))) { - fprintf(stderr, "Couldn't open output file '%s'\n", fileName); - goto err; - } - fprintf(f, "P4\n"); - fprintf(f, "%d %d\n", width, height); - - for (y = 0; y < height; ++y) { - for (x = 0; x+8 <= width; x += 8) { - p = 0; - for (i = 0; i < 8; ++i) - p = (p << 1) + (XGetPixel(image, x+i, y) & 1); - p ^= invert; - fputc((char)p, f); - } - if (width & 7) { - p = 0; - for (i = 0; i < (width & 7); ++i) - p = (p << 1) + (XGetPixel(image, x+i, y) & 1); - p <<= 8 - (width & 7); - p ^= invert; - fputc((char)p, f); - } - } - - fclose(f); - - err: - gfree(image->data); - image->data = NULL; - XDestroyImage(image); - - XOutputDev::endPage(); -} -- cgit v0.9.1