void BitmapOutputDev::flushBitmap()
{
- int width = rgbdev->getBitmapWidth();
- int height = rgbdev->getBitmapHeight();
+ int bitmap_width = rgbdev->getBitmapWidth();
+ int bitmap_height = rgbdev->getBitmapHeight();
if(sizeof(SplashColor)!=3) {
msg("<error> sizeof(SplashColor)!=3");
Guchar*alpha = rgbbitmap->getAlphaPtr();
Guchar*alpha2 = stalepolybitmap->getDataPtr();
- int width8 = (stalepolybitmap->getWidth()+7)/8;
+ int bitmap_width8 = (stalepolybitmap->getWidth()+7)/8;
/*char filename[80];
sprintf(filename, "flush%d_mask.png", dbg_btm_counter);
sprintf(filename, "flush%d_bitmap.png", dbg_btm_counter);
writeBitmap(rgbbitmap, filename);*/
- ibbox_t* boxes = get_bitmap_bboxes((unsigned char*)alpha, width, height);
- ibbox_t*b;
+ ibbox_t pagebox = {-movex, -movey, -movex + this->width, -movey + this->height, 0};
+ ibbox_t bitmapbox = {0, 0, bitmap_width, bitmap_height, 0};
+ ibbox_t c = ibbox_clip(&bitmapbox, &pagebox);
+ ibbox_t* boxes = get_bitmap_bboxes((unsigned char*)(alpha+c.ymin*bitmap_width+c.xmin), c.xmax - c.xmin, c.ymax - c.ymin, bitmap_width);
+ ibbox_t*b;
for(b=boxes;b;b=b->next) {
- int xmin = b->xmin;
- int ymin = b->ymin;
- int xmax = b->xmax;
- int ymax = b->ymax;
+ int xmin = b->xmin - this->movex;
+ int ymin = b->ymin - this->movey;
+ int xmax = b->xmax - this->movex;
+ int ymax = b->ymax - this->movey;
/* clip against (-movex, -movey, -movex+width, -movey+height) */
img->height = rangey;
int x,y;
for(y=0;y<rangey;y++) {
- SplashColorPtr in=&rgb[((y+ymin)*width+xmin)*sizeof(SplashColor)];
+ SplashColorPtr in=&rgb[((y+ymin)*bitmap_width+xmin)*sizeof(SplashColor)];
gfxcolor_t*out = &img->data[y*rangex];
- Guchar*ain = &alpha[(y+ymin)*width+xmin];
- Guchar*ain2 = &alpha2[(y+ymin)*width8];
+ Guchar*ain = &alpha[(y+ymin)*bitmap_width+xmin];
+ Guchar*ain2 = &alpha2[(y+ymin)*bitmap_width8];
if(this->emptypage) {
for(x=0;x<rangex;x++) {
/* the first bitmap on the page doesn't need to have an alpha channel-
}
}
+GBool BitmapOutputDev::checkPageSlice(Page *page, double hDPI, double vDPI,
+ int rotate, GBool useMediaBox, GBool crop,
+ int sliceX, int sliceY, int sliceW, int sliceH,
+ GBool printing, Catalog *catalog,
+ GBool (*abortCheckCbk)(void *data),
+ void *abortCheckCbkData)
+{
+ this->setPage(page);
+ gfxdev->setPage(page);
+ return gTrue;
+}
-void BitmapOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
+void BitmapOutputDev::startPage(int pageNum, GfxState *state)
{
+ PDFRectangle *r = this->page->getCropBox();
double x1,y1,x2,y2;
- state->transform(crop_x1,crop_y1,&x1,&y1);
- state->transform(crop_x2,crop_y2,&x2,&y2);
+ state->transform(r->x1,r->y1,&x1,&y1);
+ state->transform(r->x2,r->y2,&x2,&y2);
if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
this->width = (int)(x2-x1);
this->height = (int)(y2-y1);
- rgbdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
- boolpolydev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
- booltextdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
- clip0dev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
- clip1dev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
- gfxdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
+ rgbdev->startPage(pageNum, state);
+ boolpolydev->startPage(pageNum, state);
+ booltextdev->startPage(pageNum, state);
+ clip0dev->startPage(pageNum, state);
+ clip1dev->startPage(pageNum, state);
+ gfxdev->startPage(pageNum, state);
boolpolybitmap = boolpolydev->getBitmap();
stalepolybitmap = new SplashBitmap(boolpolybitmap->getWidth(), boolpolybitmap->getHeight(), 1, boolpolybitmap->getMode(), 0);
clip1dev->needNonText();
return rgbdev->needNonText();
}
-/*GBool BitmapOutputDev::checkPageSlice(Page *page, double hDPI, double vDPI,
- int rotate, GBool useMediaBox, GBool crop,
- int sliceX, int sliceY, int sliceW, int sliceH,
- GBool printing, Catalog *catalog,
- GBool (*abortCheckCbk)(void *data),
- void *abortCheckCbkData)
-{
- return gTrue;
-}*/
void BitmapOutputDev::setDefaultCTM(double *ctm)
{
boolpolydev->setDefaultCTM(ctm);
for (i = oldLen; i < mapLen; ++i) {
map[i] = 0;
}
---- xpdf/CoreOutputDev.cc.orig 2010-05-18 11:22:18.000000000 -0700
-+++ xpdf/CoreOutputDev.cc 2010-05-18 11:22:18.000000000 -0700
-@@ -57,5 +57,5 @@
-
- void CoreOutputDev::clear() {
- startDoc(NULL);
-- startPage(0, NULL);
-+ startPage(0, NULL, 0,0,0,0);
- }
--- xpdf/Decrypt.cc.orig 2010-05-18 11:22:18.000000000 -0700
+++ xpdf/Decrypt.cc 2010-05-18 11:22:18.000000000 -0700
@@ -596,6 +596,7 @@
}
--- xpdf/Gfx.cc.orig 2010-05-18 11:22:18.000000000 -0700
+++ xpdf/Gfx.cc 2010-05-18 11:22:18.000000000 -0700
-@@ -454,7 +454,11 @@
- fontChanged = gFalse;
- clip = clipNone;
- ignoreUndef = 0;
-- out->startPage(pageNum, state);
-+ if(cropBox) {
-+ out->startPage(pageNum, state, cropBox->x1,cropBox->y1,cropBox->x2,cropBox->y2);
-+ } else {
-+ out->startPage(pageNum, state, 0,0,0,0);
-+ }
- out->setDefaultCTM(state->getCTM());
- out->updateAll(state);
- for (i = 0; i < 6; ++i) {
@@ -465,6 +469,7 @@
abortCheckCbkData = abortCheckCbkDataA;
--- xpdf/GfxFont.cc.orig 2010-05-18 11:22:18.000000000 -0700
+++ xpdf/GfxFont.cc 2010-05-18 11:22:18.000000000 -0700
+ @@ -194,7 +194,7 @@
+ embFontID = obj2.getRef();
+ if (type != fontType1) {
+ error(-1, "Mismatch between font type and embedded font file");
+ - type = fontType1;
+ + type = isCIDFont() ? fontCIDType0 : fontType1;
+ }
+ }
+ obj2.free();
@@ -919,6 +919,10 @@
return 1;
}
class GString;
class GfxState;
-@@ -94,7 +95,7 @@
- { return gTrue; }
-
- // Start a page.
-- virtual void startPage(int pageNum, GfxState *state) {}
-+ virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {}
-
- // End a page.
- virtual void endPage() {}
--- xpdf/SplashFTFont.cc.orig 2010-05-18 11:22:18.000000000 -0700
+++ xpdf/SplashFTFont.cc 2010-05-18 11:22:18.000000000 -0700
@@ -46,6 +46,7 @@
#include <math.h>
#include "gfile.h"
#include "GlobalParams.h"
-@@ -702,7 +703,7 @@
- nT3Fonts = 0;
- }
-
--void SplashOutputDev::startPage(int pageNum, GfxState *state) {
-+void SplashOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
- int w, h;
- double *ctm;
- SplashCoord mat[6];
@@ -2646,9 +2647,9 @@
softMask = new SplashBitmap(bitmap->getWidth(), bitmap->getHeight(),
tBitmap->getPixel(x, y, color);
--- xpdf/SplashOutputDev.h.orig 2010-05-18 11:22:18.000000000 -0700
+++ xpdf/SplashOutputDev.h 2010-05-18 11:22:18.000000000 -0700
-@@ -70,7 +70,7 @@
- //----- initialization and control
-
- // Start a page.
-- virtual void startPage(int pageNum, GfxState *state);
-+ virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
-
- // End a page.
- virtual void endPage();
@@ -196,6 +196,9 @@
virtual void setVectorAntialias(GBool vaa);
#endif
};
//------------------------------------------------------------------------
---- xpdf/TextOutputDev.cc.orig 2010-05-18 11:22:18.000000000 -0700
-+++ xpdf/TextOutputDev.cc 2010-05-18 11:22:18.000000000 -0700
-@@ -3877,7 +3877,7 @@
- }
- }
-
--void TextOutputDev::startPage(int pageNum, GfxState *state) {
-+void TextOutputDev::startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2) {
- text->startPage(state);
- }
-
--- xpdf/TextOutputDev.h.orig 2010-05-18 11:22:18.000000000 -0700
+++ xpdf/TextOutputDev.h 2010-05-18 11:22:18.000000000 -0700
@@ -170,6 +170,7 @@
};
//------------------------------------------------------------------------
-@@ -578,7 +579,7 @@
- //----- initialization and control
-
- // Start a page.
-- virtual void startPage(int pageNum, GfxState *state);
-+ virtual void startPage(int pageNum, GfxState *state, double x1,double y1,double x2,double y2);
-
- // End a page.
- virtual void endPage();
--- xpdf/gfile.cc.orig 2010-05-18 11:22:18.000000000 -0700
+++ xpdf/gfile.cc 2010-05-18 11:22:18.000000000 -0700
@@ -439,6 +439,52 @@