splash/SplashBitmap.cc | 76 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 16 deletions(-)
New commits: commit e2c319ba18ab473fd969db9519a9231be67538c3 Author: Albert Astals Cid <[email protected]> Date: Sat Aug 8 00:48:18 2009 +0200 Also implement mono so that -mono in pdftoppm -png works Totally not optimized diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc index 1364706..25a71a0 100644 --- a/splash/SplashBitmap.cc +++ b/splash/SplashBitmap.cc @@ -263,7 +263,7 @@ SplashError SplashBitmap::writePNGFile(FILE *f) { error(-1, "PNG support not compiled in"); return splashErrGeneric; #else - if (mode != splashModeRGB8 && mode != splashModeMono8) { + if (mode != splashModeRGB8 && mode != splashModeMono8 && mode != splashModeMono1) { error(-1, "unsupported SplashBitmap mode"); return splashErrGeneric; } @@ -315,6 +315,27 @@ SplashError SplashBitmap::writePNGFile(FILE *f) { } break; + case splashModeMono1: + { + png_byte *row = new png_byte[3 * width]; + for (int y = 0; y < height; y++) { + // Convert into a PNG row + for (int x = 0; x < width; x++) { + getPixel(x, y, &row[3*x]); + row[3*x+1] = row[3*x]; + row[3*x+2] = row[3*x]; + } + + if (!writer->writeRow(&row)) { + delete[] row; + delete writer; + return splashErrGeneric; + } + } + delete[] row; + } + break; + default: // can't happen break; commit c669e7f3ca421265e78161cc3fdecd2a0c7510c9 Author: Albert Astals Cid <[email protected]> Date: Sat Aug 8 00:38:50 2009 +0200 Support splashModeMono8 in writePNGFile Works though is non optimal diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc index 84328f2..1364706 100644 --- a/splash/SplashBitmap.cc +++ b/splash/SplashBitmap.cc @@ -263,39 +263,62 @@ SplashError SplashBitmap::writePNGFile(FILE *f) { error(-1, "PNG support not compiled in"); return splashErrGeneric; #else - if (mode != splashModeRGB8) { + if (mode != splashModeRGB8 && mode != splashModeMono8) { error(-1, "unsupported SplashBitmap mode"); return splashErrGeneric; } - SplashColorPtr row; - PNGWriter *writer = new PNGWriter(); if (!writer->init(f, width, height)) { delete writer; return splashErrGeneric; } - png_bytep *row_pointers = new png_bytep[height]; switch (mode) { - case splashModeRGB8: - row = data; - - for (int y = 0; y < height; ++y) { - row_pointers[y] = row; - row += rowSize; - } - if (!writer->writePointers(row_pointers)) { + case splashModeRGB8: + { + SplashColorPtr row; + png_bytep *row_pointers = new png_bytep[height]; + row = data; + + for (int y = 0; y < height; ++y) { + row_pointers[y] = row; + row += rowSize; + } + if (!writer->writePointers(row_pointers)) { + delete[] row_pointers; + delete writer; + return splashErrGeneric; + } delete[] row_pointers; - delete writer; - return splashErrGeneric; } break; - default: + + case splashModeMono8: + { + png_byte *row = new png_byte[3 * width]; + for (int y = 0; y < height; y++) { + // Convert into a PNG row + for (int x = 0; x < width; x++) { + row[3*x] = data[y * rowSize + x]; + row[3*x+1] = data[y * rowSize + x]; + row[3*x+2] = data[y * rowSize + x]; + } + + if (!writer->writeRow(&row)) { + delete[] row; + delete writer; + return splashErrGeneric; + } + } + delete[] row; + } + break; + + default: // can't happen break; } - delete[] row_pointers; if (writer->close()) { delete writer; _______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
