3 Output Device which creates a bitmap.
5 Swftools is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 Swftools is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with swftools; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 #include "BitmapOutputDev.h"
25 #include "GFXOutputDev.h"
26 #include "SplashBitmap.h"
27 #include "SplashPattern.h"
31 #include "../devices/record.h"
33 #define UNKNOWN_BOUNDING_BOX 0,0,0,0
35 static SplashColor splash_white = {255,255,255};
36 static SplashColor splash_black = {0,0,0};
38 ClipState::ClipState()
45 BitmapOutputDev::BitmapOutputDev(InfoOutputDev*info, PDFDoc*doc)
49 this->xref = doc->getXRef();
51 /* color graphic output device, for creating bitmaps */
52 this->rgbdev = new SplashOutputDev(splashModeRGB8, 1, gFalse, splash_white, gTrue, gTrue);
54 /* color mode for binary bitmaps */
55 SplashColorMode colorMode = splashModeMono8;
57 /* two devices for testing things against clipping: one clips, the other doesn't */
58 this->clip0dev = new SplashOutputDev(colorMode, 1, gFalse, splash_black, gTrue, gFalse);
59 this->clip1dev = new SplashOutputDev(colorMode, 1, gFalse, splash_black, gTrue, gFalse);
61 /* device indicating where polygonal pixels were drawn */
62 this->boolpolydev = new SplashOutputDev(colorMode, 1, gFalse, splash_black, gTrue, gFalse);
63 /* device indicating where text pixels were drawn */
64 this->booltextdev = new SplashOutputDev(colorMode, 1, gFalse, splash_black, gTrue, gFalse);
66 /* device for handling texts and links */
67 this->gfxdev = new GFXOutputDev(info, this->doc);
69 this->rgbdev->startDoc(this->xref);
70 this->boolpolydev->startDoc(this->xref);
71 this->booltextdev->startDoc(this->xref);
72 this->clip0dev->startDoc(this->xref);
73 this->clip1dev->startDoc(this->xref);
75 this->gfxoutput = (gfxdevice_t*)malloc(sizeof(gfxdevice_t));
76 gfxdevice_record_init(this->gfxoutput);
78 this->gfxdev->setDevice(this->gfxoutput);
80 this->config_extrafontdata = 0;
83 //this->clipstates = 0;
85 BitmapOutputDev::~BitmapOutputDev()
88 gfxresult_t*r = this->gfxoutput->finish(this->gfxoutput);
90 free(this->gfxoutput);this->gfxoutput = 0;
93 delete this->bboxpath;this->bboxpath = 0;
96 delete this->rgbdev;this->rgbdev = 0;
99 delete this->gfxdev;this->gfxdev= 0;
101 if(this->boolpolydev) {
102 delete this->boolpolydev;this->boolpolydev = 0;
104 if(this->booltextdev) {
105 delete this->booltextdev;this->booltextdev = 0;
108 delete this->clip0dev;this->clip0dev = 0;
111 delete this->clip1dev;this->clip1dev = 0;
113 //if(this->clipbitmap) {
114 // delete this->clipbitmap;this->clipbitmap = 0;
116 //if(this->clipdev) {
117 // delete this->clipdev;this->clipdev = 0;
122 GBool BitmapOutputDev::getVectorAntialias()
124 return this->rgbdev->getVectorAntialias();
126 void BitmapOutputDev::setVectorAntialias(GBool vaa)
128 this->rgbdev->setVectorAntialias(vaa);
130 void BitmapOutputDev::setDevice(gfxdevice_t*dev)
134 void BitmapOutputDev::setMove(int x,int y)
136 this->gfxdev->setMove(x,y);
137 this->user_movex = x;
138 this->user_movey = y;
140 void BitmapOutputDev::setClip(int x1,int y1,int x2,int y2)
142 this->gfxdev->setClip(x1,y1,x2,y2);
143 this->user_clipx1 = x1;
144 this->user_clipy1 = y1;
145 this->user_clipx2 = x2;
146 this->user_clipy2 = y2;
148 void BitmapOutputDev::setParameter(const char*key, const char*value)
150 if(!strcmp(key, "extrafontdata")) {
151 this->config_extrafontdata = atoi(value);
153 this->gfxdev->setParameter(key, value);
155 void BitmapOutputDev::preparePage(int pdfpage, int outputpage)
159 static void getBitmapBBox(Guchar*alpha, int width, int height, int*xmin, int*ymin, int*xmax, int*ymax)
165 for(y=0;y<height;y++) {
166 Guchar*a = &alpha[y*width];
167 for(x=0;x<width;x++) {
170 int left = x; //first occupied pixel from left
171 int right = x+1; //last non-occupied pixel from right
180 if(left<*xmin) *xmin = left;
181 if(right>*xmax) *xmax = right;
184 if(*xmin>=*xmax || *ymin>=*ymax) {
192 void BitmapOutputDev::flushBitmap()
194 int width = rgbdev->getBitmapWidth();
195 int height = rgbdev->getBitmapHeight();
197 SplashColorPtr rgb = rgbbitmap->getDataPtr();
198 Guchar*alpha = rgbbitmap->getAlphaPtr();
199 Guchar*alpha2 = boolpolybitmap->getAlphaPtr();
201 int xmin,ymin,xmax,ymax;
202 getBitmapBBox(alpha, width, height, &xmin,&ymin,&xmax,&ymax);
204 /* clip against (-movex, -movey, -movex+width, -movey+height) */
205 if(xmin < -this->movex) xmin = -this->movex;
206 if(ymin < -this->movey) ymin = -this->movey;
207 if(xmax > -this->movex + width) xmax = -this->movex+this->width;
208 if(ymax > -this->movey + height) ymax = -this->movey+this->height;
210 msg("<verbose> Flushing bitmap (bbox: %d,%d,%d,%d)", xmin,ymin,xmax,ymax);
212 if((xmax-xmin)<=0 || (ymax-ymin)<=0) // no bitmap, nothing to do
215 if(sizeof(SplashColor)!=3) {
216 msg("<error> sizeof(SplashColor)!=3");
223 int rangex = xmax-xmin;
224 int rangey = ymax-ymin;
225 gfximage_t*img = (gfximage_t*)malloc(sizeof(gfximage_t));
226 img->data = (gfxcolor_t*)malloc(rangex * rangey * 4);
228 img->height = rangey;
230 for(y=0;y<rangey;y++) {
231 SplashColorPtr in=&rgb[((y+ymin)*width+xmin)*sizeof(SplashColor)];
232 gfxcolor_t*out = &img->data[y*rangex];
233 Guchar*ain = &alpha[(y+ymin)*width+xmin];
234 Guchar*ain2 = &alpha2[(y+ymin)*width+xmin];
235 if(this->emptypage) {
236 for(x=0;x<rangex;x++) {
237 /* the first bitmap on the page doesn't need to have an alpha channel-
238 blend against a white background*/
239 out[x].r = (in[x*3+0]*ain[x])/255 + 255-ain[x];
240 out[x].g = (in[x*3+1]*ain[x])/255 + 255-ain[x];
241 out[x].b = (in[x*3+2]*ain[x])/255 + 255-ain[x];
245 for(x=0;x<rangex;x++) {
248 out[x].r = 0;out[x].g = 0;out[x].b = 0;out[x].a = 0;
251 /* according to endPage()/compositeBackground() in xpdf/SplashOutputDev.cc, we
252 have to premultiply alpha (mix background and pixel according to the alpha channel).
254 out[x].r = (in[x*3+0]*ain[x])/255;
255 out[x].g = (in[x*3+1]*ain[x])/255;
256 out[x].b = (in[x*3+2]*ain[x])/255;
261 /* transform bitmap rectangle to "device space" */
275 gfxline_t* line = gfxline_makerectangle(xmin, ymin, xmax, ymax);
276 dev->fillbitmap(dev, line, img, &m, 0);
279 memset(rgbbitmap->getAlphaPtr(), 0, rgbbitmap->getWidth()*rgbbitmap->getHeight());
280 memset(rgbbitmap->getDataPtr(), 0, rgbbitmap->getRowSize()*rgbbitmap->getHeight());
282 free(img->data);img->data=0;free(img);img=0;
287 void BitmapOutputDev::flushText()
289 msg("<verbose> Flushing text/polygons");
290 gfxdevice_record_flush(this->gfxoutput, this->dev);
295 void writeBitmap(SplashBitmap*bitmap, char*filename)
299 int width = bitmap->getWidth();
300 int height = bitmap->getHeight();
302 gfxcolor_t*data = (gfxcolor_t*)malloc(sizeof(gfxcolor_t)*width*height);
304 for(y=0;y<height;y++) {
305 gfxcolor_t*line = &data[y*width];
306 for(x=0;x<width;x++) {
308 bitmap->getPixel(x,y,c);
309 int a = bitmap->getAlpha(x,y);
316 writePNG(filename, (unsigned char*)data, width, height);
320 void writeAlpha(SplashBitmap*bitmap, char*filename)
324 int width = bitmap->getWidth();
325 int height = bitmap->getHeight();
327 gfxcolor_t*data = (gfxcolor_t*)malloc(sizeof(gfxcolor_t)*width*height);
329 for(y=0;y<height;y++) {
330 gfxcolor_t*line = &data[y*width];
331 for(x=0;x<width;x++) {
332 int a = bitmap->getAlpha(x,y);
339 writePNG(filename, (unsigned char*)data, width, height);
342 static int dbg_btm_counter=1;
344 static const char*STATE_NAME[] = {"parallel", "textabovebitmap", "bitmapabovetext"};
346 int checkAlphaSanity(SplashBitmap*boolbtm, SplashBitmap*alphabtm)
348 assert(boolbtm->getWidth() == alphabtm->getWidth());
349 assert(boolbtm->getHeight() == alphabtm->getHeight());
350 if(boolbtm->getMode()==splashModeMono1) {
354 int width = boolbtm->getWidth();
355 int height = boolbtm->getHeight();
359 for(y=0;y<height;y++) {
360 for(x=0;x<width;x++) {
361 int a1 = alphabtm->getAlpha(x,y);
362 int a2 = boolbtm->getAlpha(x,y);
368 double badness = bad/(double)(width*height);
370 msg("<error> Bitmaps don't correspond: %d out of %d pixels wrong (%.2f%%)", bad, width*height,
374 msg("<notice> %f", badness);
378 GBool BitmapOutputDev::checkNewText(int x1, int y1, int x2, int y2)
380 /* called once some new text was drawn on booltextdev, and
381 before the same thing is drawn on gfxdev */
383 msg("<trace> Testing new text data against current bitmap data, state=%s, counter=%d\n", STATE_NAME[layerstate], dbg_btm_counter);
388 sprintf(filename1, "state%dboolbitmap_afternewtext.png", dbg_btm_counter);
389 sprintf(filename2, "state%dbooltext_afternewtext.png", dbg_btm_counter);
390 sprintf(filename3, "state%dbitmap_afternewtext.png", dbg_btm_counter);
392 msg("<verbose> %s %s %s", filename1, filename2, filename3);
393 writeAlpha(boolpolybitmap, filename1);
394 writeAlpha(booltextbitmap, filename2);
395 writeBitmap(rgbdev->getBitmap(), filename3);
400 if(intersection(x1,y1,x2,y2)) {
401 if(layerstate==STATE_PARALLEL) {
402 /* the new text is above the bitmap. So record that fact,
403 and also clear the bitmap buffer, so we can check for
405 msg("<verbose> Text is above current bitmap/polygon data");
406 layerstate=STATE_TEXT_IS_ABOVE;
407 clearBoolPolyDev(x1,y1,x2,y2);
408 } else if(layerstate==STATE_BITMAP_IS_ABOVE) {
409 /* there's a bitmap above the (old) text. So we need
410 to flush out that text, and record that the *new*
411 text is now *above* the bitmap
413 msg("<verbose> Text is above current bitmap/polygon data (which is above some other text)");
415 layerstate=STATE_TEXT_IS_ABOVE;
416 /* clear both bool devices- the text device because
417 we just dumped out all the (old) text, and the
418 poly dev so we can check for new intersections */
419 clearBoolPolyDev(x1,y1,x2,y2);
420 /* FIXME this destroys the text pixels we just
421 drew to test for the intersection- however we need
422 those to check for the *new* intersections */
423 clearBoolTextDev(x1,y1,x2,y2);
426 /* we already know that the current text section is
427 above the current bitmap section- now just new
428 bitmap data *and* new text data was drawn, and
429 *again* it's above the current bitmap- so clear
430 the polygon bitmap again, so we can check for
432 msg("<verbose> Text is still above current bitmap/polygon data");
433 clearBoolPolyDev(x1,y1,x2,y2);
439 GBool BitmapOutputDev::checkNewBitmap(int x1, int y1, int x2, int y2)
441 /* similar to checkNewText() above, only in reverse */
442 msg("<trace> Testing new graphics data against current text data, state=%s, counter=%d\n", STATE_NAME[layerstate], dbg_btm_counter);
447 sprintf(filename1, "state%dboolbitmap_afternewgfx.png", dbg_btm_counter);
448 sprintf(filename2, "state%dbooltext_afternewgfx.png", dbg_btm_counter);
449 sprintf(filename3, "state%dbitmap_afternewgfx.png", dbg_btm_counter);
452 msg("<verbose> %s %s %s", filename1, filename2, filename3);
453 writeAlpha(boolpolybitmap, filename1);
454 writeAlpha(booltextbitmap, filename2);
455 writeBitmap(rgbdev->getBitmap(), filename3);
460 if(intersection(x1,y1,x2,y2)) {
461 if(layerstate==STATE_PARALLEL) {
462 msg("<verbose> Bitmap is above current text data");
463 layerstate=STATE_BITMAP_IS_ABOVE;
464 clearBoolTextDev(x1,y1,x2,y2);
465 } else if(layerstate==STATE_TEXT_IS_ABOVE) {
466 msg("<verbose> Bitmap is above current text data (which is above some bitmap)");
468 layerstate=STATE_BITMAP_IS_ABOVE;
469 clearBoolTextDev(x1,y1,x2,y2);
470 /* FIXME this destroys the polygon pixels we just
471 drew to test for the intersection- however we need
472 those to check for the *new* intersections */
473 clearBoolPolyDev(x1,y1,x2,y2);
476 msg("<verbose> Bitmap is still above current text data");
477 clearBoolTextDev(x1,y1,x2,y2);
483 //void checkNewText() {
484 // Guchar*alpha = rgbbitmap->getAlphaPtr();
485 // Guchar*charpixels = clip1bitmap->getDataPtr();
487 // for(yy=0;yy<height;yy++) {
488 // Guchar*aline = &alpha[yy*width];
489 // Guchar*cline = &charpixels[yy*width8];
490 // for(xx=0;xx<width;xx++) {
492 // int bytepos = xx>>3;
493 // /* TODO: is the bit order correct? */
494 // if(aline[xx] && (cline[bytepos]&(1<<bit)))
501 GBool BitmapOutputDev::clip0and1differ(int x1,int y1,int x2,int y2)
503 if(clip0bitmap->getMode()==splashModeMono1) {
510 if(x1>=clip0bitmap->getWidth())
512 if(x2>clip0bitmap->getWidth())
513 x2=clip0bitmap->getWidth();
521 if(y1>=clip0bitmap->getHeight())
523 if(y2>clip0bitmap->getHeight())
524 y2=clip0bitmap->getHeight();
526 SplashBitmap*clip0 = clip0bitmap;
527 SplashBitmap*clip1 = clip1bitmap;
528 int width8 = (clip0bitmap->getWidth()+7)/8;
529 int height = clip0bitmap->getHeight();
535 unsigned char*row1 = &clip0bitmap->getDataPtr()[width8*y+x18];
536 unsigned char*row2 = &clip1bitmap->getDataPtr()[width8*y+x28];
537 if(memcmp(row1, row2, x28-x18))
542 SplashBitmap*clip0 = clip0bitmap;
543 SplashBitmap*clip1 = clip1bitmap;
544 int width = clip0->getAlphaRowSize();
545 int height = clip0->getHeight();
546 return memcmp(clip0->getAlphaPtr(), clip1->getAlphaPtr(), width*height);
550 static void clearBooleanBitmap(SplashBitmap*btm, int x1, int y1, int x2, int y2)
554 x2 = btm->getWidth();
555 y2 = btm->getHeight();
557 if(btm->getMode()==splashModeMono1) {
558 int width8 = (btm->getWidth()+7)/8;
559 int width = btm->getWidth();
560 int height = btm->getHeight();
561 memset(btm->getDataPtr(), 0, width8*height);
563 int width = btm->getAlphaRowSize();
564 int height = btm->getHeight();
565 memset(btm->getAlphaPtr(), 0, width*height);
569 long long unsigned int compare64(long long unsigned int*data1, long long unsigned int*data2, int len)
571 long long unsigned int c;
574 c |= data1[t]&data2[t];
579 GBool BitmapOutputDev::intersection(int x1, int y1, int x2, int y2)
581 SplashBitmap*boolpoly = boolpolybitmap;
582 SplashBitmap*booltext = booltextbitmap;
584 if(boolpoly->getMode()==splashModeMono1) {
585 /* alternative implementation, using one bit per pixel-
586 would work if xpdf wouldn't try to dither everything */
588 Guchar*polypixels = boolpoly->getDataPtr();
589 Guchar*textpixels = booltext->getDataPtr();
591 int width8 = (width+7)/8;
592 int height = boolpoly->getHeight();
595 if(y1>=0 && y1<=y2 && y2<=height) {
596 polypixels+=y1*width8;
597 textpixels+=y1*width8;
603 int len = height*width8;
604 unsigned long long int c=0;
605 assert(sizeof(unsigned long long int)==8);
607 if(((int)polypixels&7) || ((int)textpixels&7)) {
608 //msg("<warning> Non-optimal alignment");
611 len /= sizeof(unsigned long long int);
612 c = compare64((unsigned long long int*)polypixels, (unsigned long long int*)textpixels, len);
613 int l1 = len*sizeof(unsigned long long int);
615 c |= (unsigned long long int)(polypixels[t]&textpixels[t]);
619 /* if graphic data and the characters overlap, they have common bits */
624 Guchar*polypixels = boolpoly->getAlphaPtr();
625 Guchar*textpixels = booltext->getAlphaPtr();
627 int width = boolpoly->getAlphaRowSize();
628 int height = boolpoly->getHeight();
631 int len = height*width;
633 if(len & (sizeof(unsigned int)-1)) {
636 if(polypixels[t]&&textpixels[t])
640 len /= sizeof(unsigned int);
642 if((((unsigned int*)polypixels)[t]) & (((unsigned int*)textpixels)[t]))
651 void BitmapOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
654 state->transform(crop_x1,crop_y1,&x1,&y1);
655 state->transform(crop_x2,crop_y2,&x2,&y2);
656 if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
657 if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
659 this->movex = -(int)x1 - user_movex;
660 this->movey = -(int)y1 - user_movey;
662 if(user_clipx1|user_clipy1|user_clipx2|user_clipy2) {
668 this->width = (int)(x2-x1);
669 this->height = (int)(y2-y1);
671 msg("<debug> startPage");
672 rgbdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
673 boolpolydev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
674 booltextdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
675 clip0dev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
676 clip1dev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
677 gfxdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
679 boolpolybitmap = boolpolydev->getBitmap();
680 booltextbitmap = booltextdev->getBitmap();
681 clip0bitmap = clip0dev->getBitmap();
682 clip1bitmap = clip1dev->getBitmap();
683 rgbbitmap = rgbdev->getBitmap();
685 flushText(); // write out the initial clipping rectangle
687 /* just in case any device did draw a white background rectangle
689 clearBoolTextDev(UNKNOWN_BOUNDING_BOX);
690 clearBoolPolyDev(UNKNOWN_BOUNDING_BOX);
692 this->layerstate = STATE_PARALLEL;
694 msg("<debug> startPage done");
697 void BitmapOutputDev::endPage()
699 msg("<verbose> endPage (BitmapOutputDev)");
701 /* notice: we're not fully done yet with this page- there might still be
702 a few calls to drawLink() yet to come */
704 void BitmapOutputDev::finishPage()
706 msg("<verbose> finishPage (BitmapOutputDev)");
709 if(layerstate == STATE_BITMAP_IS_ABOVE) {
717 /* splash will now destroy alpha, and paint the
718 background color into the "holes" in the bitmap */
719 boolpolydev->endPage();
720 booltextdev->endPage();
726 GBool BitmapOutputDev::upsideDown()
728 boolpolydev->upsideDown();
729 booltextdev->upsideDown();
730 clip0dev->upsideDown();
731 clip1dev->upsideDown();
732 return rgbdev->upsideDown();
735 GBool BitmapOutputDev::useDrawChar()
737 boolpolydev->useDrawChar();
738 booltextdev->useDrawChar();
739 clip0dev->useDrawChar();
740 clip1dev->useDrawChar();
741 return rgbdev->useDrawChar();
744 GBool BitmapOutputDev::useTilingPatternFill()
746 boolpolydev->useTilingPatternFill();
747 booltextdev->useTilingPatternFill();
748 clip0dev->useTilingPatternFill();
749 clip1dev->useTilingPatternFill();
750 return rgbdev->useTilingPatternFill();
753 GBool BitmapOutputDev::useShadedFills()
755 boolpolydev->useShadedFills();
756 booltextdev->useShadedFills();
757 clip0dev->useShadedFills();
758 clip1dev->useShadedFills();
759 return rgbdev->useShadedFills();
762 GBool BitmapOutputDev::useDrawForm()
764 boolpolydev->useDrawForm();
765 booltextdev->useDrawForm();
766 clip0dev->useDrawForm();
767 clip1dev->useDrawForm();
768 return rgbdev->useDrawForm();
771 GBool BitmapOutputDev::interpretType3Chars()
773 boolpolydev->interpretType3Chars();
774 booltextdev->interpretType3Chars();
775 clip0dev->interpretType3Chars();
776 clip1dev->interpretType3Chars();
777 return rgbdev->interpretType3Chars();
780 GBool BitmapOutputDev::needNonText()
782 boolpolydev->needNonText();
783 booltextdev->needNonText();
784 clip0dev->needNonText();
785 clip1dev->needNonText();
786 return rgbdev->needNonText();
788 /*GBool BitmapOutputDev::checkPageSlice(Page *page, double hDPI, double vDPI,
789 int rotate, GBool useMediaBox, GBool crop,
790 int sliceX, int sliceY, int sliceW, int sliceH,
791 GBool printing, Catalog *catalog,
792 GBool (*abortCheckCbk)(void *data),
793 void *abortCheckCbkData)
797 void BitmapOutputDev::setDefaultCTM(double *ctm)
799 boolpolydev->setDefaultCTM(ctm);
800 booltextdev->setDefaultCTM(ctm);
801 rgbdev->setDefaultCTM(ctm);
802 clip0dev->setDefaultCTM(ctm);
803 clip1dev->setDefaultCTM(ctm);
804 gfxdev->setDefaultCTM(ctm);
806 void BitmapOutputDev::saveState(GfxState *state)
808 boolpolydev->saveState(state);
809 booltextdev->saveState(state);
810 rgbdev->saveState(state);
811 clip0dev->saveState(state);
812 clip1dev->saveState(state);
814 /*ClipState*cstate = new ClipState();
815 cstate->next = this->clipstates;
816 this->clipstates = cstate;*/
818 void BitmapOutputDev::restoreState(GfxState *state)
820 boolpolydev->restoreState(state);
821 booltextdev->restoreState(state);
822 rgbdev->restoreState(state);
823 clip0dev->restoreState(state);
824 clip1dev->restoreState(state);
826 /*if(this->clipstates) {
827 ClipState*old = this->clipstates;
829 gfxdev->restoreState(state);
831 this->clipstates = this->clipstates->next;
834 msg("<error> invalid restoreState()");
837 void BitmapOutputDev::updateAll(GfxState *state)
839 boolpolydev->updateAll(state);
840 booltextdev->updateAll(state);
841 rgbdev->updateAll(state);
842 clip0dev->updateAll(state);
843 clip1dev->updateAll(state);
844 gfxdev->updateAll(state);
846 void BitmapOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32)
848 boolpolydev->updateCTM(state,m11,m12,m21,m22,m31,m32);
849 booltextdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
850 rgbdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
851 clip0dev->updateCTM(state,m11,m12,m21,m22,m31,m32);
852 clip1dev->updateCTM(state,m11,m12,m21,m22,m31,m32);
853 gfxdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
855 void BitmapOutputDev::updateLineDash(GfxState *state)
857 boolpolydev->updateLineDash(state);
858 booltextdev->updateLineDash(state);
859 rgbdev->updateLineDash(state);
860 clip0dev->updateLineDash(state);
861 clip1dev->updateLineDash(state);
862 gfxdev->updateLineDash(state);
864 void BitmapOutputDev::updateFlatness(GfxState *state)
866 boolpolydev->updateFlatness(state);
867 booltextdev->updateFlatness(state);
868 rgbdev->updateFlatness(state);
869 clip0dev->updateFlatness(state);
870 clip1dev->updateFlatness(state);
871 gfxdev->updateFlatness(state);
873 void BitmapOutputDev::updateLineJoin(GfxState *state)
875 boolpolydev->updateLineJoin(state);
876 booltextdev->updateLineJoin(state);
877 rgbdev->updateLineJoin(state);
878 clip0dev->updateLineJoin(state);
879 clip1dev->updateLineJoin(state);
880 gfxdev->updateLineJoin(state);
882 void BitmapOutputDev::updateLineCap(GfxState *state)
884 boolpolydev->updateLineCap(state);
885 booltextdev->updateLineCap(state);
886 rgbdev->updateLineCap(state);
887 clip0dev->updateLineCap(state);
888 clip1dev->updateLineCap(state);
889 gfxdev->updateLineCap(state);
891 void BitmapOutputDev::updateMiterLimit(GfxState *state)
893 boolpolydev->updateMiterLimit(state);
894 booltextdev->updateMiterLimit(state);
895 rgbdev->updateMiterLimit(state);
896 clip0dev->updateMiterLimit(state);
897 clip1dev->updateMiterLimit(state);
898 gfxdev->updateMiterLimit(state);
900 void BitmapOutputDev::updateLineWidth(GfxState *state)
902 boolpolydev->updateLineWidth(state);
903 booltextdev->updateLineWidth(state);
904 rgbdev->updateLineWidth(state);
905 clip0dev->updateLineWidth(state);
906 clip1dev->updateLineWidth(state);
907 gfxdev->updateLineWidth(state);
909 void BitmapOutputDev::updateStrokeAdjust(GfxState *state)
911 boolpolydev->updateStrokeAdjust(state);
912 booltextdev->updateStrokeAdjust(state);
913 rgbdev->updateStrokeAdjust(state);
914 clip0dev->updateStrokeAdjust(state);
915 clip1dev->updateStrokeAdjust(state);
916 gfxdev->updateStrokeAdjust(state);
918 void BitmapOutputDev::updateFillColorSpace(GfxState *state)
920 boolpolydev->updateFillColorSpace(state);
921 booltextdev->updateFillColorSpace(state);
922 rgbdev->updateFillColorSpace(state);
923 clip0dev->updateFillColorSpace(state);
924 clip1dev->updateFillColorSpace(state);
925 gfxdev->updateFillColorSpace(state);
927 void BitmapOutputDev::updateStrokeColorSpace(GfxState *state)
929 boolpolydev->updateStrokeColorSpace(state);
930 booltextdev->updateStrokeColorSpace(state);
931 rgbdev->updateStrokeColorSpace(state);
932 clip0dev->updateStrokeColorSpace(state);
933 clip1dev->updateStrokeColorSpace(state);
934 gfxdev->updateStrokeColorSpace(state);
936 void BitmapOutputDev::updateFillColor(GfxState *state)
938 boolpolydev->updateFillColor(state);
939 booltextdev->updateFillColor(state);
940 rgbdev->updateFillColor(state);
941 clip0dev->updateFillColor(state);
942 clip1dev->updateFillColor(state);
943 gfxdev->updateFillColor(state);
945 void BitmapOutputDev::updateStrokeColor(GfxState *state)
947 boolpolydev->updateStrokeColor(state);
948 booltextdev->updateStrokeColor(state);
949 rgbdev->updateStrokeColor(state);
950 clip0dev->updateStrokeColor(state);
951 clip1dev->updateStrokeColor(state);
952 gfxdev->updateStrokeColor(state);
954 void BitmapOutputDev::updateBlendMode(GfxState *state)
956 boolpolydev->updateBlendMode(state);
957 booltextdev->updateBlendMode(state);
958 rgbdev->updateBlendMode(state);
959 clip0dev->updateBlendMode(state);
960 clip1dev->updateBlendMode(state);
961 gfxdev->updateBlendMode(state);
963 void BitmapOutputDev::updateFillOpacity(GfxState *state)
965 boolpolydev->updateFillOpacity(state);
966 booltextdev->updateFillOpacity(state);
967 rgbdev->updateFillOpacity(state);
968 clip0dev->updateFillOpacity(state);
969 clip1dev->updateFillOpacity(state);
970 gfxdev->updateFillOpacity(state);
972 void BitmapOutputDev::updateStrokeOpacity(GfxState *state)
974 boolpolydev->updateStrokeOpacity(state);
975 booltextdev->updateStrokeOpacity(state);
976 rgbdev->updateStrokeOpacity(state);
977 clip0dev->updateStrokeOpacity(state);
978 clip1dev->updateStrokeOpacity(state);
979 gfxdev->updateStrokeOpacity(state);
981 void BitmapOutputDev::updateFillOverprint(GfxState *state)
983 boolpolydev->updateFillOverprint(state);
984 booltextdev->updateFillOverprint(state);
985 rgbdev->updateFillOverprint(state);
986 clip0dev->updateFillOverprint(state);
987 clip1dev->updateFillOverprint(state);
988 gfxdev->updateFillOverprint(state);
990 void BitmapOutputDev::updateStrokeOverprint(GfxState *state)
992 boolpolydev->updateStrokeOverprint(state);
993 booltextdev->updateStrokeOverprint(state);
994 rgbdev->updateStrokeOverprint(state);
995 clip0dev->updateStrokeOverprint(state);
996 clip1dev->updateStrokeOverprint(state);
997 gfxdev->updateStrokeOverprint(state);
999 void BitmapOutputDev::updateTransfer(GfxState *state)
1001 boolpolydev->updateTransfer(state);
1002 booltextdev->updateTransfer(state);
1003 rgbdev->updateTransfer(state);
1004 clip0dev->updateTransfer(state);
1005 clip1dev->updateTransfer(state);
1006 gfxdev->updateTransfer(state);
1009 void BitmapOutputDev::updateFont(GfxState *state)
1011 boolpolydev->updateFont(state);
1012 booltextdev->updateFont(state);
1013 rgbdev->updateFont(state);
1014 clip0dev->updateFont(state);
1015 clip1dev->updateFont(state);
1016 gfxdev->updateFont(state);
1018 void BitmapOutputDev::updateTextMat(GfxState *state)
1020 boolpolydev->updateTextMat(state);
1021 booltextdev->updateTextMat(state);
1022 rgbdev->updateTextMat(state);
1023 clip0dev->updateTextMat(state);
1024 clip1dev->updateTextMat(state);
1025 gfxdev->updateTextMat(state);
1027 void BitmapOutputDev::updateCharSpace(GfxState *state)
1029 boolpolydev->updateCharSpace(state);
1030 booltextdev->updateCharSpace(state);
1031 rgbdev->updateCharSpace(state);
1032 clip0dev->updateCharSpace(state);
1033 clip1dev->updateCharSpace(state);
1034 gfxdev->updateCharSpace(state);
1036 void BitmapOutputDev::updateRender(GfxState *state)
1038 boolpolydev->updateRender(state);
1039 booltextdev->updateRender(state);
1040 rgbdev->updateRender(state);
1041 clip0dev->updateRender(state);
1042 clip1dev->updateRender(state);
1043 gfxdev->updateRender(state);
1045 void BitmapOutputDev::updateRise(GfxState *state)
1047 boolpolydev->updateRise(state);
1048 booltextdev->updateRise(state);
1049 rgbdev->updateRise(state);
1050 clip0dev->updateRise(state);
1051 clip1dev->updateRise(state);
1052 gfxdev->updateRise(state);
1054 void BitmapOutputDev::updateWordSpace(GfxState *state)
1056 boolpolydev->updateWordSpace(state);
1057 booltextdev->updateWordSpace(state);
1058 rgbdev->updateWordSpace(state);
1059 clip0dev->updateWordSpace(state);
1060 clip1dev->updateWordSpace(state);
1061 gfxdev->updateWordSpace(state);
1063 void BitmapOutputDev::updateHorizScaling(GfxState *state)
1065 boolpolydev->updateHorizScaling(state);
1066 booltextdev->updateHorizScaling(state);
1067 rgbdev->updateHorizScaling(state);
1068 clip0dev->updateHorizScaling(state);
1069 clip1dev->updateHorizScaling(state);
1070 gfxdev->updateHorizScaling(state);
1072 void BitmapOutputDev::updateTextPos(GfxState *state)
1074 boolpolydev->updateTextPos(state);
1075 booltextdev->updateTextPos(state);
1076 rgbdev->updateTextPos(state);
1077 clip0dev->updateTextPos(state);
1078 clip1dev->updateTextPos(state);
1079 gfxdev->updateTextPos(state);
1081 void BitmapOutputDev::updateTextShift(GfxState *state, double shift)
1083 boolpolydev->updateTextShift(state, shift);
1084 booltextdev->updateTextShift(state, shift);
1085 rgbdev->updateTextShift(state, shift);
1086 clip0dev->updateTextShift(state, shift);
1087 clip1dev->updateTextShift(state, shift);
1088 gfxdev->updateTextShift(state, shift);
1091 void BitmapOutputDev::stroke(GfxState *state)
1093 msg("<debug> stroke");
1094 boolpolydev->stroke(state);
1095 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1096 rgbdev->stroke(state);
1098 void BitmapOutputDev::fill(GfxState *state)
1100 msg("<debug> fill");
1101 boolpolydev->fill(state);
1102 if(checkNewBitmap(UNKNOWN_BOUNDING_BOX)) {
1103 boolpolydev->fill(state);
1105 rgbdev->fill(state);
1107 void BitmapOutputDev::eoFill(GfxState *state)
1109 msg("<debug> eoFill");
1110 boolpolydev->eoFill(state);
1111 if(checkNewBitmap(UNKNOWN_BOUNDING_BOX)) {
1112 boolpolydev->eoFill(state);
1114 rgbdev->eoFill(state);
1116 #if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
1117 void BitmapOutputDev::tilingPatternFill(GfxState *state, Object *str,
1118 int paintType, Dict *resDict,
1119 double *mat, double *bbox,
1120 int x0, int y0, int x1, int y1,
1121 double xStep, double yStep)
1123 msg("<debug> tilingPatternFill");
1124 boolpolydev->tilingPatternFill(state, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1125 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1126 rgbdev->tilingPatternFill(state, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1129 void BitmapOutputDev::tilingPatternFill(GfxState *state, Gfx *gfx, Object *str,
1130 int paintType, Dict *resDict,
1131 double *mat, double *bbox,
1132 int x0, int y0, int x1, int y1,
1133 double xStep, double yStep)
1135 msg("<debug> tilingPatternFill");
1136 boolpolydev->tilingPatternFill(state, gfx, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1137 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1138 rgbdev->tilingPatternFill(state, gfx, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1142 GBool BitmapOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *shading)
1144 msg("<debug> functionShadedFill");
1145 boolpolydev->functionShadedFill(state, shading);
1146 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1147 return rgbdev->functionShadedFill(state, shading);
1149 GBool BitmapOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading)
1151 msg("<debug> axialShadedFill");
1152 boolpolydev->axialShadedFill(state, shading);
1153 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1154 return rgbdev->axialShadedFill(state, shading);
1156 GBool BitmapOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading)
1158 msg("<debug> radialShadedFill");
1159 boolpolydev->radialShadedFill(state, shading);
1160 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1161 return rgbdev->radialShadedFill(state, shading);
1164 SplashColor black = {0,0,0};
1165 SplashColor white = {255,255,255};
1167 void BitmapOutputDev::clip(GfxState *state)
1169 msg("<debug> clip");
1170 boolpolydev->clip(state);
1171 booltextdev->clip(state);
1172 rgbdev->clip(state);
1173 clip1dev->clip(state);
1175 void BitmapOutputDev::eoClip(GfxState *state)
1177 msg("<debug> eoClip");
1178 boolpolydev->eoClip(state);
1179 booltextdev->eoClip(state);
1180 rgbdev->eoClip(state);
1181 clip1dev->eoClip(state);
1183 void BitmapOutputDev::clipToStrokePath(GfxState *state)
1185 msg("<debug> clipToStrokePath");
1186 boolpolydev->clipToStrokePath(state);
1187 booltextdev->clipToStrokePath(state);
1188 rgbdev->clipToStrokePath(state);
1189 clip1dev->clipToStrokePath(state);
1192 void BitmapOutputDev::beginStringOp(GfxState *state)
1194 msg("<debug> beginStringOp");
1195 clip0dev->beginStringOp(state);
1196 clip1dev->beginStringOp(state);
1197 booltextdev->beginStringOp(state);
1198 gfxdev->beginStringOp(state);
1200 void BitmapOutputDev::endStringOp(GfxState *state)
1202 msg("<debug> endStringOp");
1203 clip0dev->endStringOp(state);
1204 clip1dev->endStringOp(state);
1205 booltextdev->endStringOp(state);
1206 checkNewText(UNKNOWN_BOUNDING_BOX);
1207 gfxdev->endStringOp(state);
1209 void BitmapOutputDev::beginString(GfxState *state, GString *s)
1211 msg("<debug> beginString");
1212 clip0dev->beginString(state, s);
1213 clip1dev->beginString(state, s);
1214 booltextdev->beginString(state, s);
1215 gfxdev->beginString(state, s);
1217 void BitmapOutputDev::endString(GfxState *state)
1219 msg("<debug> endString");
1220 clip0dev->endString(state);
1221 clip1dev->endString(state);
1222 booltextdev->endString(state);
1223 checkNewText(UNKNOWN_BOUNDING_BOX);
1224 gfxdev->endString(state);
1227 void BitmapOutputDev::clearClips()
1229 clearBooleanBitmap(clip0bitmap, 0, 0, 0, 0);
1230 clearBooleanBitmap(clip1bitmap, 0, 0, 0, 0);
1232 void BitmapOutputDev::clearBoolPolyDev(int x1, int y1, int x2, int y2)
1234 clearBooleanBitmap(boolpolybitmap, x1, y1, x2, y2);
1236 void BitmapOutputDev::clearBoolTextDev(int x1, int y1, int x2, int y2)
1238 clearBooleanBitmap(booltextbitmap, x1, y1, x2, y2);
1240 void BitmapOutputDev::drawChar(GfxState *state, double x, double y,
1241 double dx, double dy,
1242 double originX, double originY,
1243 CharCode code, int nBytes, Unicode *u, int uLen)
1245 msg("<debug> drawChar render=%d", state->getRender());
1247 if(state->getRender()&RENDER_CLIP) {
1248 //char is just a clipping boundary
1249 rgbdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1250 boolpolydev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1251 booltextdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1252 clip1dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1253 } else if(rgbbitmap != rgbdev->getBitmap()) {
1254 // we're doing softmasking or transparency grouping
1255 boolpolydev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1256 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1257 rgbdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1259 // we're drawing a regular char
1261 clip0dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1262 clip1dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1264 /* calculate the bbox of this character */
1265 int x1 = (int)x, x2 = (int)x+1, y1 = (int)y, y2 = (int)y+1;
1266 SplashPath*path = clip0dev->getCurrentFont()->getGlyphPath(code);
1269 msg("<error> couldn't create outline for char %d", code);
1273 for(t=0;t<path->getLength();t++) {
1276 path->getPoint(t,&xx,&yy,&f);
1279 if(xx<x1) x1=(int)xx;
1280 if(yy<y1) y1=(int)yy;
1281 if(xx>x2) x2=(int)xx+1;
1282 if(yy>y2) y2=(int)yy+1;
1285 /* if this character is affected somehow by the various clippings (i.e., it looks
1286 different on a device without clipping), then draw it on the bitmap, not as
1288 if(clip0and1differ(x1,y1,x2,y2)) {
1289 msg("<verbose> Char %d is affected by clipping", code);
1290 boolpolydev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1291 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1292 rgbdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1293 if(config_extrafontdata) {
1294 int oldrender = state->getRender();
1295 state->setRender(3); //invisible
1296 gfxdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1297 state->setRender(oldrender);
1300 /* this char is not at all affected by clipping.
1301 Now just dump out the bitmap we're currently working on, if necessary. */
1302 booltextdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1303 checkNewText(x1,y1,x2,y2);
1304 /* use polygonal output device to do the actual text handling */
1305 gfxdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1309 void BitmapOutputDev::drawString(GfxState *state, GString *s)
1311 msg("<error> internal error: drawString not implemented");
1313 clip0dev->drawString(state, s);
1314 clip1dev->drawString(state, s);
1315 booltextdev->drawString(state, s);
1316 gfxdev->drawString(state, s);
1318 void BitmapOutputDev::endTextObject(GfxState *state)
1320 msg("<debug> endTextObject");
1321 rgbdev->endTextObject(state);
1322 clip0dev->endTextObject(state);
1323 clip1dev->endTextObject(state);
1324 booltextdev->endTextObject(state);
1325 /* TODO: do this only if rendermode!=0 */
1326 checkNewText(UNKNOWN_BOUNDING_BOX);
1327 gfxdev->endTextObject(state);
1330 /* TODO: these four operations below *should* do nothing, as type3
1331 chars are drawn using operations like fill() */
1332 GBool BitmapOutputDev::beginType3Char(GfxState *state, double x, double y,
1333 double dx, double dy,
1334 CharCode code, Unicode *u, int uLen)
1336 msg("<debug> beginType3Char");
1337 /* call gfxdev so that it can generate "invisible" characters
1338 on top of the actual graphic content, for text extraction */
1339 return gfxdev->beginType3Char(state, x, y, dx, dy, code, u, uLen);
1341 void BitmapOutputDev::type3D0(GfxState *state, double wx, double wy)
1343 msg("<debug> type3D0");
1344 return gfxdev->type3D0(state, wx, wy);
1346 void BitmapOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury)
1348 msg("<debug> type3D1");
1349 return gfxdev->type3D1(state, wx, wy, llx, lly, urx, ury);
1351 void BitmapOutputDev::endType3Char(GfxState *state)
1353 msg("<debug> endType3Char");
1354 gfxdev->endType3Char(state);
1357 class CopyStream: public Object
1361 MemStream*memstream;
1363 CopyStream(Stream*str, int len)
1368 buf = (char*)malloc(len);
1370 for (t=0; t<len; t++)
1371 buf[t] = str->getChar();
1374 this->dict = str->getDict();
1375 this->memstream = new MemStream(buf, 0, len, this);
1379 ::free(this->buf);this->buf = 0;
1380 delete this->memstream;
1382 Dict* getDict() {return dict;}
1383 Stream* getStream() {return this->memstream;};
1386 void BitmapOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
1387 int width, int height, GBool invert,
1390 msg("<debug> drawImageMask streamkind=%d", str->getKind());
1391 CopyStream*cpystr = 0;
1393 cpystr = new CopyStream(str, height * ((width + 7) / 8));
1394 str = cpystr->getStream();
1396 boolpolydev->drawImageMask(state, ref, str, width, height, invert, inlineImg);
1397 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1398 rgbdev->drawImageMask(state, ref, str, width, height, invert, inlineImg);
1402 void BitmapOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
1403 int width, int height, GfxImageColorMap *colorMap,
1404 int *maskColors, GBool inlineImg)
1406 msg("<debug> drawImage streamkind=%d", str->getKind());
1407 CopyStream*cpystr = 0;
1409 cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8));
1410 str = cpystr->getStream();
1412 boolpolydev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg);
1413 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1414 rgbdev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg);
1418 void BitmapOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
1419 int width, int height,
1420 GfxImageColorMap *colorMap,
1421 Stream *maskStr, int maskWidth, int maskHeight,
1424 msg("<debug> drawMaskedImage streamkind=%d", str->getKind());
1425 boolpolydev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert);
1426 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1427 rgbdev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert);
1429 void BitmapOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
1430 int width, int height,
1431 GfxImageColorMap *colorMap,
1433 int maskWidth, int maskHeight,
1434 GfxImageColorMap *maskColorMap)
1436 msg("<debug> drawSoftMaskedImage %dx%d (%dx%d) streamkind=%d", width, height, maskWidth, maskHeight, str->getKind());
1437 boolpolydev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap);
1438 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1439 rgbdev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap);
1441 void BitmapOutputDev::drawForm(Ref id)
1443 msg("<debug> drawForm");
1444 boolpolydev->drawForm(id);
1445 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1446 rgbdev->drawForm(id);
1449 void BitmapOutputDev::processLink(Link *link, Catalog *catalog)
1451 msg("<debug> processLink");
1452 gfxdev->processLink(link, catalog);
1455 void BitmapOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
1456 GfxColorSpace *blendingColorSpace,
1457 GBool isolated, GBool knockout,
1460 msg("<debug> beginTransparencyGroup");
1461 #if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
1462 GfxState*state1 = state->copy();
1463 GfxState*state2 = state->copy();
1465 state1->setPath(state->getPath()->copy());
1467 state2->setPath(state->getPath()->copy());
1469 GfxState*state1 = state->copy(gTrue);
1470 GfxState*state2 = state->copy(gTrue);
1472 boolpolydev->beginTransparencyGroup(state1, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
1473 rgbdev->beginTransparencyGroup(state2, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
1474 clip1dev->beginTransparencyGroup(state, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
1478 void BitmapOutputDev::endTransparencyGroup(GfxState *state)
1480 msg("<debug> endTransparencyGroup");
1481 #if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
1482 GfxState*state1 = state->copy();
1483 GfxState*state2 = state->copy();
1485 state1->setPath(state->getPath()->copy());
1487 state2->setPath(state->getPath()->copy());
1489 GfxState*state1 = state->copy(gTrue);
1490 GfxState*state2 = state->copy(gTrue);
1492 boolpolydev->endTransparencyGroup(state1);
1493 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1494 rgbdev->endTransparencyGroup(state2);
1497 clip1dev->endTransparencyGroup(state);
1499 void BitmapOutputDev::paintTransparencyGroup(GfxState *state, double *bbox)
1501 msg("<debug> paintTransparencyGroup");
1502 boolpolydev->paintTransparencyGroup(state,bbox);
1503 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1504 rgbdev->paintTransparencyGroup(state,bbox);
1505 clip1dev->paintTransparencyGroup(state,bbox);
1507 void BitmapOutputDev::setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor)
1509 msg("<debug> setSoftMask");
1510 boolpolydev->setSoftMask(state, bbox, alpha, transferFunc, backdropColor);
1511 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1512 rgbdev->setSoftMask(state, bbox, alpha, transferFunc, backdropColor);
1513 clip1dev->setSoftMask(state, bbox, alpha, transferFunc, backdropColor);
1515 void BitmapOutputDev::clearSoftMask(GfxState *state)
1517 msg("<debug> clearSoftMask");
1518 boolpolydev->clearSoftMask(state);
1519 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1520 rgbdev->clearSoftMask(state);
1521 clip1dev->clearSoftMask(state);