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" */
273 gfxline_t* line = gfxline_makerectangle(xmin, ymin, xmax, ymax);
274 dev->fillbitmap(dev, line, img, &m, 0);
277 memset(rgbbitmap->getAlphaPtr(), 0, rgbbitmap->getWidth()*rgbbitmap->getHeight());
278 memset(rgbbitmap->getDataPtr(), 0, rgbbitmap->getRowSize()*rgbbitmap->getHeight());
280 free(img->data);img->data=0;free(img);img=0;
285 void BitmapOutputDev::flushText()
287 msg("<verbose> Flushing text/polygons");
288 gfxdevice_record_flush(this->gfxoutput, this->dev);
293 void writeBitmap(SplashBitmap*bitmap, char*filename)
297 int width = bitmap->getWidth();
298 int height = bitmap->getHeight();
300 gfxcolor_t*data = (gfxcolor_t*)malloc(sizeof(gfxcolor_t)*width*height);
302 for(y=0;y<height;y++) {
303 gfxcolor_t*line = &data[y*width];
304 for(x=0;x<width;x++) {
306 bitmap->getPixel(x,y,c);
307 int a = bitmap->getAlpha(x,y);
314 writePNG(filename, (unsigned char*)data, width, height);
318 void writeAlpha(SplashBitmap*bitmap, char*filename)
322 int width = bitmap->getWidth();
323 int height = bitmap->getHeight();
325 gfxcolor_t*data = (gfxcolor_t*)malloc(sizeof(gfxcolor_t)*width*height);
327 for(y=0;y<height;y++) {
328 gfxcolor_t*line = &data[y*width];
329 for(x=0;x<width;x++) {
330 int a = bitmap->getAlpha(x,y);
337 writePNG(filename, (unsigned char*)data, width, height);
340 static int dbg_btm_counter=1;
342 static const char*STATE_NAME[] = {"parallel", "textabovebitmap", "bitmapabovetext"};
344 int checkAlphaSanity(SplashBitmap*boolbtm, SplashBitmap*alphabtm)
346 assert(boolbtm->getWidth() == alphabtm->getWidth());
347 assert(boolbtm->getHeight() == alphabtm->getHeight());
348 if(boolbtm->getMode()==splashModeMono1) {
352 int width = boolbtm->getWidth();
353 int height = boolbtm->getHeight();
357 for(y=0;y<height;y++) {
358 for(x=0;x<width;x++) {
359 int a1 = alphabtm->getAlpha(x,y);
360 int a2 = boolbtm->getAlpha(x,y);
366 double badness = bad/(double)(width*height);
368 msg("<error> Bitmaps don't correspond: %d out of %d pixels wrong (%.2f%%)", bad, width*height,
372 msg("<notice> %f", badness);
376 GBool BitmapOutputDev::checkNewText(int x1, int y1, int x2, int y2)
378 /* called once some new text was drawn on booltextdev, and
379 before the same thing is drawn on gfxdev */
381 msg("<trace> Testing new text data against current bitmap data, state=%s, counter=%d\n", STATE_NAME[layerstate], dbg_btm_counter);
386 sprintf(filename1, "state%dboolbitmap_afternewtext.png", dbg_btm_counter);
387 sprintf(filename2, "state%dbooltext_afternewtext.png", dbg_btm_counter);
388 sprintf(filename3, "state%dbitmap_afternewtext.png", dbg_btm_counter);
390 msg("<verbose> %s %s %s", filename1, filename2, filename3);
391 writeAlpha(boolpolybitmap, filename1);
392 writeAlpha(booltextbitmap, filename2);
393 writeBitmap(rgbdev->getBitmap(), filename3);
398 if(intersection(x1,y1,x2,y2)) {
399 if(layerstate==STATE_PARALLEL) {
400 /* the new text is above the bitmap. So record that fact,
401 and also clear the bitmap buffer, so we can check for
403 msg("<verbose> Text is above current bitmap/polygon data");
404 layerstate=STATE_TEXT_IS_ABOVE;
405 clearBoolPolyDev(x1,y1,x2,y2);
406 } else if(layerstate==STATE_BITMAP_IS_ABOVE) {
407 /* there's a bitmap above the (old) text. So we need
408 to flush out that text, and record that the *new*
409 text is now *above* the bitmap
411 msg("<verbose> Text is above current bitmap/polygon data (which is above some other text)");
413 layerstate=STATE_TEXT_IS_ABOVE;
414 /* clear both bool devices- the text device because
415 we just dumped out all the (old) text, and the
416 poly dev so we can check for new intersections */
417 clearBoolPolyDev(x1,y1,x2,y2);
418 /* FIXME this destroys the text pixels we just
419 drew to test for the intersection- however we need
420 those to check for the *new* intersections */
421 clearBoolTextDev(x1,y1,x2,y2);
424 /* we already know that the current text section is
425 above the current bitmap section- now just new
426 bitmap data *and* new text data was drawn, and
427 *again* it's above the current bitmap- so clear
428 the polygon bitmap again, so we can check for
430 msg("<verbose> Text is still above current bitmap/polygon data");
431 clearBoolPolyDev(x1,y1,x2,y2);
437 GBool BitmapOutputDev::checkNewBitmap(int x1, int y1, int x2, int y2)
439 /* similar to checkNewText() above, only in reverse */
440 msg("<trace> Testing new graphics data against current text data, state=%s, counter=%d\n", STATE_NAME[layerstate], dbg_btm_counter);
445 sprintf(filename1, "state%dboolbitmap_afternewgfx.png", dbg_btm_counter);
446 sprintf(filename2, "state%dbooltext_afternewgfx.png", dbg_btm_counter);
447 sprintf(filename3, "state%dbitmap_afternewgfx.png", dbg_btm_counter);
450 msg("<verbose> %s %s %s", filename1, filename2, filename3);
451 writeAlpha(boolpolybitmap, filename1);
452 writeAlpha(booltextbitmap, filename2);
453 writeBitmap(rgbdev->getBitmap(), filename3);
458 if(intersection(x1,y1,x2,y2)) {
459 if(layerstate==STATE_PARALLEL) {
460 msg("<verbose> Bitmap is above current text data");
461 layerstate=STATE_BITMAP_IS_ABOVE;
462 clearBoolTextDev(x1,y1,x2,y2);
463 } else if(layerstate==STATE_TEXT_IS_ABOVE) {
464 msg("<verbose> Bitmap is above current text data (which is above some bitmap)");
466 layerstate=STATE_BITMAP_IS_ABOVE;
467 clearBoolTextDev(x1,y1,x2,y2);
468 /* FIXME this destroys the polygon pixels we just
469 drew to test for the intersection- however we need
470 those to check for the *new* intersections */
471 clearBoolPolyDev(x1,y1,x2,y2);
474 msg("<verbose> Bitmap is still above current text data");
475 clearBoolTextDev(x1,y1,x2,y2);
481 //void checkNewText() {
482 // Guchar*alpha = rgbbitmap->getAlphaPtr();
483 // Guchar*charpixels = clip1bitmap->getDataPtr();
485 // for(yy=0;yy<height;yy++) {
486 // Guchar*aline = &alpha[yy*width];
487 // Guchar*cline = &charpixels[yy*width8];
488 // for(xx=0;xx<width;xx++) {
490 // int bytepos = xx>>3;
491 // /* TODO: is the bit order correct? */
492 // if(aline[xx] && (cline[bytepos]&(1<<bit)))
499 GBool BitmapOutputDev::clip0and1differ(int x1,int y1,int x2,int y2)
501 if(clip0bitmap->getMode()==splashModeMono1) {
508 if(x1>=clip0bitmap->getWidth())
510 if(x2>clip0bitmap->getWidth())
511 x2=clip0bitmap->getWidth();
519 if(y1>=clip0bitmap->getHeight())
521 if(y2>clip0bitmap->getHeight())
522 y2=clip0bitmap->getHeight();
524 SplashBitmap*clip0 = clip0bitmap;
525 SplashBitmap*clip1 = clip1bitmap;
526 int width8 = (clip0bitmap->getWidth()+7)/8;
527 int height = clip0bitmap->getHeight();
533 unsigned char*row1 = &clip0bitmap->getDataPtr()[width8*y+x18];
534 unsigned char*row2 = &clip1bitmap->getDataPtr()[width8*y+x28];
535 if(memcmp(row1, row2, x28-x18))
540 SplashBitmap*clip0 = clip0bitmap;
541 SplashBitmap*clip1 = clip1bitmap;
542 int width = clip0->getAlphaRowSize();
543 int height = clip0->getHeight();
544 return memcmp(clip0->getAlphaPtr(), clip1->getAlphaPtr(), width*height);
548 static void clearBooleanBitmap(SplashBitmap*btm, int x1, int y1, int x2, int y2)
552 x2 = btm->getWidth();
553 y2 = btm->getHeight();
555 if(btm->getMode()==splashModeMono1) {
556 int width8 = (btm->getWidth()+7)/8;
557 int width = btm->getWidth();
558 int height = btm->getHeight();
559 memset(btm->getDataPtr(), 0, width8*height);
561 int width = btm->getAlphaRowSize();
562 int height = btm->getHeight();
563 memset(btm->getAlphaPtr(), 0, width*height);
567 long long unsigned int compare64(long long unsigned int*data1, long long unsigned int*data2, int len)
569 long long unsigned int c;
572 c |= data1[t]&data2[t];
577 GBool BitmapOutputDev::intersection(int x1, int y1, int x2, int y2)
579 SplashBitmap*boolpoly = boolpolybitmap;
580 SplashBitmap*booltext = booltextbitmap;
582 if(boolpoly->getMode()==splashModeMono1) {
583 /* alternative implementation, using one bit per pixel-
584 would work if xpdf wouldn't try to dither everything */
586 Guchar*polypixels = boolpoly->getDataPtr();
587 Guchar*textpixels = booltext->getDataPtr();
589 int width8 = (width+7)/8;
590 int height = boolpoly->getHeight();
593 if(y1>=0 && y1<=y2 && y2<=height) {
594 polypixels+=y1*width8;
595 textpixels+=y1*width8;
601 int len = height*width8;
602 unsigned long long int c=0;
603 assert(sizeof(unsigned long long int)==8);
605 if(((int)polypixels&7) || ((int)textpixels&7)) {
606 //msg("<warning> Non-optimal alignment");
609 len /= sizeof(unsigned long long int);
610 c = compare64((unsigned long long int*)polypixels, (unsigned long long int*)textpixels, len);
611 int l1 = len*sizeof(unsigned long long int);
613 c |= (unsigned long long int)(polypixels[t]&textpixels[t]);
617 /* if graphic data and the characters overlap, they have common bits */
622 Guchar*polypixels = boolpoly->getAlphaPtr();
623 Guchar*textpixels = booltext->getAlphaPtr();
625 int width = boolpoly->getAlphaRowSize();
626 int height = boolpoly->getHeight();
629 int len = height*width;
631 if(len & (sizeof(unsigned int)-1)) {
634 if(polypixels[t]&&textpixels[t])
638 len /= sizeof(unsigned int);
640 if((((unsigned int*)polypixels)[t]) & (((unsigned int*)textpixels)[t]))
649 void BitmapOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
652 state->transform(crop_x1,crop_y1,&x1,&y1);
653 state->transform(crop_x2,crop_y2,&x2,&y2);
654 if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
655 if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
657 this->movex = -(int)x1 - user_movex;
658 this->movey = -(int)y1 - user_movey;
660 if(user_clipx1|user_clipy1|user_clipx2|user_clipy2) {
666 this->width = (int)(x2-x1);
667 this->height = (int)(y2-y1);
669 msg("<debug> startPage");
670 rgbdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
671 boolpolydev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
672 booltextdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
673 clip0dev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
674 clip1dev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
675 gfxdev->startPage(pageNum, state, crop_x1, crop_y1, crop_x2, crop_y2);
677 boolpolybitmap = boolpolydev->getBitmap();
678 booltextbitmap = booltextdev->getBitmap();
679 clip0bitmap = clip0dev->getBitmap();
680 clip1bitmap = clip1dev->getBitmap();
681 rgbbitmap = rgbdev->getBitmap();
683 flushText(); // write out the initial clipping rectangle
685 /* just in case any device did draw a white background rectangle
687 clearBoolTextDev(UNKNOWN_BOUNDING_BOX);
688 clearBoolPolyDev(UNKNOWN_BOUNDING_BOX);
690 this->layerstate = STATE_PARALLEL;
692 msg("<debug> startPage done");
695 void BitmapOutputDev::endPage()
697 msg("<verbose> endPage (BitmapOutputDev)");
699 /* notice: we're not fully done yet with this page- there might still be
700 a few calls to drawLink() yet to come */
702 void BitmapOutputDev::finishPage()
704 msg("<verbose> finishPage (BitmapOutputDev)");
707 if(layerstate == STATE_BITMAP_IS_ABOVE) {
715 /* splash will now destroy alpha, and paint the
716 background color into the "holes" in the bitmap */
717 boolpolydev->endPage();
718 booltextdev->endPage();
724 GBool BitmapOutputDev::upsideDown()
726 boolpolydev->upsideDown();
727 booltextdev->upsideDown();
728 clip0dev->upsideDown();
729 clip1dev->upsideDown();
730 return rgbdev->upsideDown();
733 GBool BitmapOutputDev::useDrawChar()
735 boolpolydev->useDrawChar();
736 booltextdev->useDrawChar();
737 clip0dev->useDrawChar();
738 clip1dev->useDrawChar();
739 return rgbdev->useDrawChar();
742 GBool BitmapOutputDev::useTilingPatternFill()
744 boolpolydev->useTilingPatternFill();
745 booltextdev->useTilingPatternFill();
746 clip0dev->useTilingPatternFill();
747 clip1dev->useTilingPatternFill();
748 return rgbdev->useTilingPatternFill();
751 GBool BitmapOutputDev::useShadedFills()
753 boolpolydev->useShadedFills();
754 booltextdev->useShadedFills();
755 clip0dev->useShadedFills();
756 clip1dev->useShadedFills();
757 return rgbdev->useShadedFills();
760 GBool BitmapOutputDev::useDrawForm()
762 boolpolydev->useDrawForm();
763 booltextdev->useDrawForm();
764 clip0dev->useDrawForm();
765 clip1dev->useDrawForm();
766 return rgbdev->useDrawForm();
769 GBool BitmapOutputDev::interpretType3Chars()
771 boolpolydev->interpretType3Chars();
772 booltextdev->interpretType3Chars();
773 clip0dev->interpretType3Chars();
774 clip1dev->interpretType3Chars();
775 return rgbdev->interpretType3Chars();
778 GBool BitmapOutputDev::needNonText()
780 boolpolydev->needNonText();
781 booltextdev->needNonText();
782 clip0dev->needNonText();
783 clip1dev->needNonText();
784 return rgbdev->needNonText();
786 /*GBool BitmapOutputDev::checkPageSlice(Page *page, double hDPI, double vDPI,
787 int rotate, GBool useMediaBox, GBool crop,
788 int sliceX, int sliceY, int sliceW, int sliceH,
789 GBool printing, Catalog *catalog,
790 GBool (*abortCheckCbk)(void *data),
791 void *abortCheckCbkData)
795 void BitmapOutputDev::setDefaultCTM(double *ctm)
797 boolpolydev->setDefaultCTM(ctm);
798 booltextdev->setDefaultCTM(ctm);
799 rgbdev->setDefaultCTM(ctm);
800 clip0dev->setDefaultCTM(ctm);
801 clip1dev->setDefaultCTM(ctm);
802 gfxdev->setDefaultCTM(ctm);
804 void BitmapOutputDev::saveState(GfxState *state)
806 boolpolydev->saveState(state);
807 booltextdev->saveState(state);
808 rgbdev->saveState(state);
809 clip0dev->saveState(state);
810 clip1dev->saveState(state);
812 /*ClipState*cstate = new ClipState();
813 cstate->next = this->clipstates;
814 this->clipstates = cstate;*/
816 void BitmapOutputDev::restoreState(GfxState *state)
818 boolpolydev->restoreState(state);
819 booltextdev->restoreState(state);
820 rgbdev->restoreState(state);
821 clip0dev->restoreState(state);
822 clip1dev->restoreState(state);
824 /*if(this->clipstates) {
825 ClipState*old = this->clipstates;
827 gfxdev->restoreState(state);
829 this->clipstates = this->clipstates->next;
832 msg("<error> invalid restoreState()");
835 void BitmapOutputDev::updateAll(GfxState *state)
837 boolpolydev->updateAll(state);
838 booltextdev->updateAll(state);
839 rgbdev->updateAll(state);
840 clip0dev->updateAll(state);
841 clip1dev->updateAll(state);
842 gfxdev->updateAll(state);
844 void BitmapOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32)
846 boolpolydev->updateCTM(state,m11,m12,m21,m22,m31,m32);
847 booltextdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
848 rgbdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
849 clip0dev->updateCTM(state,m11,m12,m21,m22,m31,m32);
850 clip1dev->updateCTM(state,m11,m12,m21,m22,m31,m32);
851 gfxdev->updateCTM(state,m11,m12,m21,m22,m31,m32);
853 void BitmapOutputDev::updateLineDash(GfxState *state)
855 boolpolydev->updateLineDash(state);
856 booltextdev->updateLineDash(state);
857 rgbdev->updateLineDash(state);
858 clip0dev->updateLineDash(state);
859 clip1dev->updateLineDash(state);
860 gfxdev->updateLineDash(state);
862 void BitmapOutputDev::updateFlatness(GfxState *state)
864 boolpolydev->updateFlatness(state);
865 booltextdev->updateFlatness(state);
866 rgbdev->updateFlatness(state);
867 clip0dev->updateFlatness(state);
868 clip1dev->updateFlatness(state);
869 gfxdev->updateFlatness(state);
871 void BitmapOutputDev::updateLineJoin(GfxState *state)
873 boolpolydev->updateLineJoin(state);
874 booltextdev->updateLineJoin(state);
875 rgbdev->updateLineJoin(state);
876 clip0dev->updateLineJoin(state);
877 clip1dev->updateLineJoin(state);
878 gfxdev->updateLineJoin(state);
880 void BitmapOutputDev::updateLineCap(GfxState *state)
882 boolpolydev->updateLineCap(state);
883 booltextdev->updateLineCap(state);
884 rgbdev->updateLineCap(state);
885 clip0dev->updateLineCap(state);
886 clip1dev->updateLineCap(state);
887 gfxdev->updateLineCap(state);
889 void BitmapOutputDev::updateMiterLimit(GfxState *state)
891 boolpolydev->updateMiterLimit(state);
892 booltextdev->updateMiterLimit(state);
893 rgbdev->updateMiterLimit(state);
894 clip0dev->updateMiterLimit(state);
895 clip1dev->updateMiterLimit(state);
896 gfxdev->updateMiterLimit(state);
898 void BitmapOutputDev::updateLineWidth(GfxState *state)
900 boolpolydev->updateLineWidth(state);
901 booltextdev->updateLineWidth(state);
902 rgbdev->updateLineWidth(state);
903 clip0dev->updateLineWidth(state);
904 clip1dev->updateLineWidth(state);
905 gfxdev->updateLineWidth(state);
907 void BitmapOutputDev::updateStrokeAdjust(GfxState *state)
909 boolpolydev->updateStrokeAdjust(state);
910 booltextdev->updateStrokeAdjust(state);
911 rgbdev->updateStrokeAdjust(state);
912 clip0dev->updateStrokeAdjust(state);
913 clip1dev->updateStrokeAdjust(state);
914 gfxdev->updateStrokeAdjust(state);
916 void BitmapOutputDev::updateFillColorSpace(GfxState *state)
918 boolpolydev->updateFillColorSpace(state);
919 booltextdev->updateFillColorSpace(state);
920 rgbdev->updateFillColorSpace(state);
921 clip0dev->updateFillColorSpace(state);
922 clip1dev->updateFillColorSpace(state);
923 gfxdev->updateFillColorSpace(state);
925 void BitmapOutputDev::updateStrokeColorSpace(GfxState *state)
927 boolpolydev->updateStrokeColorSpace(state);
928 booltextdev->updateStrokeColorSpace(state);
929 rgbdev->updateStrokeColorSpace(state);
930 clip0dev->updateStrokeColorSpace(state);
931 clip1dev->updateStrokeColorSpace(state);
932 gfxdev->updateStrokeColorSpace(state);
934 void BitmapOutputDev::updateFillColor(GfxState *state)
936 boolpolydev->updateFillColor(state);
937 booltextdev->updateFillColor(state);
938 rgbdev->updateFillColor(state);
939 clip0dev->updateFillColor(state);
940 clip1dev->updateFillColor(state);
941 gfxdev->updateFillColor(state);
943 void BitmapOutputDev::updateStrokeColor(GfxState *state)
945 boolpolydev->updateStrokeColor(state);
946 booltextdev->updateStrokeColor(state);
947 rgbdev->updateStrokeColor(state);
948 clip0dev->updateStrokeColor(state);
949 clip1dev->updateStrokeColor(state);
950 gfxdev->updateStrokeColor(state);
952 void BitmapOutputDev::updateBlendMode(GfxState *state)
954 boolpolydev->updateBlendMode(state);
955 booltextdev->updateBlendMode(state);
956 rgbdev->updateBlendMode(state);
957 clip0dev->updateBlendMode(state);
958 clip1dev->updateBlendMode(state);
959 gfxdev->updateBlendMode(state);
961 void BitmapOutputDev::updateFillOpacity(GfxState *state)
963 boolpolydev->updateFillOpacity(state);
964 booltextdev->updateFillOpacity(state);
965 rgbdev->updateFillOpacity(state);
966 clip0dev->updateFillOpacity(state);
967 clip1dev->updateFillOpacity(state);
968 gfxdev->updateFillOpacity(state);
970 void BitmapOutputDev::updateStrokeOpacity(GfxState *state)
972 boolpolydev->updateStrokeOpacity(state);
973 booltextdev->updateStrokeOpacity(state);
974 rgbdev->updateStrokeOpacity(state);
975 clip0dev->updateStrokeOpacity(state);
976 clip1dev->updateStrokeOpacity(state);
977 gfxdev->updateStrokeOpacity(state);
979 void BitmapOutputDev::updateFillOverprint(GfxState *state)
981 boolpolydev->updateFillOverprint(state);
982 booltextdev->updateFillOverprint(state);
983 rgbdev->updateFillOverprint(state);
984 clip0dev->updateFillOverprint(state);
985 clip1dev->updateFillOverprint(state);
986 gfxdev->updateFillOverprint(state);
988 void BitmapOutputDev::updateStrokeOverprint(GfxState *state)
990 boolpolydev->updateStrokeOverprint(state);
991 booltextdev->updateStrokeOverprint(state);
992 rgbdev->updateStrokeOverprint(state);
993 clip0dev->updateStrokeOverprint(state);
994 clip1dev->updateStrokeOverprint(state);
995 gfxdev->updateStrokeOverprint(state);
997 void BitmapOutputDev::updateTransfer(GfxState *state)
999 boolpolydev->updateTransfer(state);
1000 booltextdev->updateTransfer(state);
1001 rgbdev->updateTransfer(state);
1002 clip0dev->updateTransfer(state);
1003 clip1dev->updateTransfer(state);
1004 gfxdev->updateTransfer(state);
1007 void BitmapOutputDev::updateFont(GfxState *state)
1009 boolpolydev->updateFont(state);
1010 booltextdev->updateFont(state);
1011 rgbdev->updateFont(state);
1012 clip0dev->updateFont(state);
1013 clip1dev->updateFont(state);
1014 gfxdev->updateFont(state);
1016 void BitmapOutputDev::updateTextMat(GfxState *state)
1018 boolpolydev->updateTextMat(state);
1019 booltextdev->updateTextMat(state);
1020 rgbdev->updateTextMat(state);
1021 clip0dev->updateTextMat(state);
1022 clip1dev->updateTextMat(state);
1023 gfxdev->updateTextMat(state);
1025 void BitmapOutputDev::updateCharSpace(GfxState *state)
1027 boolpolydev->updateCharSpace(state);
1028 booltextdev->updateCharSpace(state);
1029 rgbdev->updateCharSpace(state);
1030 clip0dev->updateCharSpace(state);
1031 clip1dev->updateCharSpace(state);
1032 gfxdev->updateCharSpace(state);
1034 void BitmapOutputDev::updateRender(GfxState *state)
1036 boolpolydev->updateRender(state);
1037 booltextdev->updateRender(state);
1038 rgbdev->updateRender(state);
1039 clip0dev->updateRender(state);
1040 clip1dev->updateRender(state);
1041 gfxdev->updateRender(state);
1043 void BitmapOutputDev::updateRise(GfxState *state)
1045 boolpolydev->updateRise(state);
1046 booltextdev->updateRise(state);
1047 rgbdev->updateRise(state);
1048 clip0dev->updateRise(state);
1049 clip1dev->updateRise(state);
1050 gfxdev->updateRise(state);
1052 void BitmapOutputDev::updateWordSpace(GfxState *state)
1054 boolpolydev->updateWordSpace(state);
1055 booltextdev->updateWordSpace(state);
1056 rgbdev->updateWordSpace(state);
1057 clip0dev->updateWordSpace(state);
1058 clip1dev->updateWordSpace(state);
1059 gfxdev->updateWordSpace(state);
1061 void BitmapOutputDev::updateHorizScaling(GfxState *state)
1063 boolpolydev->updateHorizScaling(state);
1064 booltextdev->updateHorizScaling(state);
1065 rgbdev->updateHorizScaling(state);
1066 clip0dev->updateHorizScaling(state);
1067 clip1dev->updateHorizScaling(state);
1068 gfxdev->updateHorizScaling(state);
1070 void BitmapOutputDev::updateTextPos(GfxState *state)
1072 boolpolydev->updateTextPos(state);
1073 booltextdev->updateTextPos(state);
1074 rgbdev->updateTextPos(state);
1075 clip0dev->updateTextPos(state);
1076 clip1dev->updateTextPos(state);
1077 gfxdev->updateTextPos(state);
1079 void BitmapOutputDev::updateTextShift(GfxState *state, double shift)
1081 boolpolydev->updateTextShift(state, shift);
1082 booltextdev->updateTextShift(state, shift);
1083 rgbdev->updateTextShift(state, shift);
1084 clip0dev->updateTextShift(state, shift);
1085 clip1dev->updateTextShift(state, shift);
1086 gfxdev->updateTextShift(state, shift);
1089 void BitmapOutputDev::stroke(GfxState *state)
1091 msg("<debug> stroke");
1092 boolpolydev->stroke(state);
1093 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1094 rgbdev->stroke(state);
1096 void BitmapOutputDev::fill(GfxState *state)
1098 msg("<debug> fill");
1099 boolpolydev->fill(state);
1100 if(checkNewBitmap(UNKNOWN_BOUNDING_BOX)) {
1101 boolpolydev->fill(state);
1103 rgbdev->fill(state);
1105 void BitmapOutputDev::eoFill(GfxState *state)
1107 msg("<debug> eoFill");
1108 boolpolydev->eoFill(state);
1109 if(checkNewBitmap(UNKNOWN_BOUNDING_BOX)) {
1110 boolpolydev->eoFill(state);
1112 rgbdev->eoFill(state);
1114 #if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
1115 void BitmapOutputDev::tilingPatternFill(GfxState *state, Object *str,
1116 int paintType, Dict *resDict,
1117 double *mat, double *bbox,
1118 int x0, int y0, int x1, int y1,
1119 double xStep, double yStep)
1121 msg("<debug> tilingPatternFill");
1122 boolpolydev->tilingPatternFill(state, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1123 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1124 rgbdev->tilingPatternFill(state, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1127 void BitmapOutputDev::tilingPatternFill(GfxState *state, Gfx *gfx, Object *str,
1128 int paintType, Dict *resDict,
1129 double *mat, double *bbox,
1130 int x0, int y0, int x1, int y1,
1131 double xStep, double yStep)
1133 msg("<debug> tilingPatternFill");
1134 boolpolydev->tilingPatternFill(state, gfx, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1135 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1136 rgbdev->tilingPatternFill(state, gfx, str, paintType, resDict, mat, bbox, x0, y0, x1, y1, xStep, yStep);
1140 GBool BitmapOutputDev::functionShadedFill(GfxState *state, GfxFunctionShading *shading)
1142 msg("<debug> functionShadedFill");
1143 boolpolydev->functionShadedFill(state, shading);
1144 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1145 return rgbdev->functionShadedFill(state, shading);
1147 GBool BitmapOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading)
1149 msg("<debug> axialShadedFill");
1150 boolpolydev->axialShadedFill(state, shading);
1151 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1152 return rgbdev->axialShadedFill(state, shading);
1154 GBool BitmapOutputDev::radialShadedFill(GfxState *state, GfxRadialShading *shading)
1156 msg("<debug> radialShadedFill");
1157 boolpolydev->radialShadedFill(state, shading);
1158 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1159 return rgbdev->radialShadedFill(state, shading);
1162 SplashColor black = {0,0,0};
1163 SplashColor white = {255,255,255};
1165 void BitmapOutputDev::clip(GfxState *state)
1167 msg("<debug> clip");
1168 boolpolydev->clip(state);
1169 booltextdev->clip(state);
1170 rgbdev->clip(state);
1171 clip1dev->clip(state);
1173 void BitmapOutputDev::eoClip(GfxState *state)
1175 msg("<debug> eoClip");
1176 boolpolydev->eoClip(state);
1177 booltextdev->eoClip(state);
1178 rgbdev->eoClip(state);
1179 clip1dev->eoClip(state);
1181 void BitmapOutputDev::clipToStrokePath(GfxState *state)
1183 msg("<debug> clipToStrokePath");
1184 boolpolydev->clipToStrokePath(state);
1185 booltextdev->clipToStrokePath(state);
1186 rgbdev->clipToStrokePath(state);
1187 clip1dev->clipToStrokePath(state);
1190 void BitmapOutputDev::beginStringOp(GfxState *state)
1192 msg("<debug> beginStringOp");
1193 clip0dev->beginStringOp(state);
1194 clip1dev->beginStringOp(state);
1195 booltextdev->beginStringOp(state);
1196 gfxdev->beginStringOp(state);
1198 void BitmapOutputDev::endStringOp(GfxState *state)
1200 msg("<debug> endStringOp");
1201 clip0dev->endStringOp(state);
1202 clip1dev->endStringOp(state);
1203 booltextdev->endStringOp(state);
1204 checkNewText(UNKNOWN_BOUNDING_BOX);
1205 gfxdev->endStringOp(state);
1207 void BitmapOutputDev::beginString(GfxState *state, GString *s)
1209 msg("<debug> beginString");
1210 clip0dev->beginString(state, s);
1211 clip1dev->beginString(state, s);
1212 booltextdev->beginString(state, s);
1213 gfxdev->beginString(state, s);
1215 void BitmapOutputDev::endString(GfxState *state)
1217 msg("<debug> endString");
1218 clip0dev->endString(state);
1219 clip1dev->endString(state);
1220 booltextdev->endString(state);
1221 checkNewText(UNKNOWN_BOUNDING_BOX);
1222 gfxdev->endString(state);
1225 void BitmapOutputDev::clearClips()
1227 clearBooleanBitmap(clip0bitmap, 0, 0, 0, 0);
1228 clearBooleanBitmap(clip1bitmap, 0, 0, 0, 0);
1230 void BitmapOutputDev::clearBoolPolyDev(int x1, int y1, int x2, int y2)
1232 clearBooleanBitmap(boolpolybitmap, x1, y1, x2, y2);
1234 void BitmapOutputDev::clearBoolTextDev(int x1, int y1, int x2, int y2)
1236 clearBooleanBitmap(booltextbitmap, x1, y1, x2, y2);
1238 void BitmapOutputDev::drawChar(GfxState *state, double x, double y,
1239 double dx, double dy,
1240 double originX, double originY,
1241 CharCode code, int nBytes, Unicode *u, int uLen)
1243 msg("<debug> drawChar render=%d", state->getRender());
1245 if(state->getRender()&RENDER_CLIP) {
1246 //char is just a clipping boundary
1247 rgbdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1248 boolpolydev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1249 booltextdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1250 clip1dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1251 } else if(rgbbitmap != rgbdev->getBitmap()) {
1252 // we're doing softmasking or transparency grouping
1253 boolpolydev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1254 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1255 rgbdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1257 // we're drawing a regular char
1259 clip0dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1260 clip1dev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1262 /* calculate the bbox of this character */
1263 int x1 = (int)x, x2 = (int)x+1, y1 = (int)y, y2 = (int)y+1;
1264 SplashPath*path = clip0dev->getCurrentFont()->getGlyphPath(code);
1266 for(t=0;t<path->getLength();t++) {
1269 path->getPoint(t,&xx,&yy,&f);
1272 if(xx<x1) x1=(int)xx;
1273 if(yy<y1) y1=(int)yy;
1274 if(xx>x2) x2=(int)xx+1;
1275 if(yy>y2) y2=(int)yy+1;
1278 /* if this character is affected somehow by the various clippings (i.e., it looks
1279 different on a device without clipping), then draw it on the bitmap, not as
1281 if(clip0and1differ(x1,y1,x2,y2)) {
1282 msg("<verbose> Char %d is affected by clipping", code);
1283 boolpolydev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1284 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1285 rgbdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1286 if(config_extrafontdata) {
1287 int oldrender = state->getRender();
1288 state->setRender(3); //invisible
1289 gfxdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1290 state->setRender(oldrender);
1293 /* this char is not at all affected by clipping.
1294 Now just dump out the bitmap we're currently working on, if necessary. */
1295 booltextdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1296 checkNewText(x1,y1,x2,y2);
1297 /* use polygonal output device to do the actual text handling */
1298 gfxdev->drawChar(state, x, y, dx, dy, originX, originY, code, nBytes, u, uLen);
1302 void BitmapOutputDev::drawString(GfxState *state, GString *s)
1304 msg("<error> internal error: drawString not implemented");
1306 clip0dev->drawString(state, s);
1307 clip1dev->drawString(state, s);
1308 booltextdev->drawString(state, s);
1309 gfxdev->drawString(state, s);
1311 void BitmapOutputDev::endTextObject(GfxState *state)
1313 msg("<debug> endTextObject");
1314 rgbdev->endTextObject(state);
1315 clip0dev->endTextObject(state);
1316 clip1dev->endTextObject(state);
1317 booltextdev->endTextObject(state);
1318 /* TODO: do this only if rendermode!=0 */
1319 checkNewText(UNKNOWN_BOUNDING_BOX);
1320 gfxdev->endTextObject(state);
1323 /* TODO: these four operations below *should* do nothing, as type3
1324 chars are drawn using operations like fill() */
1325 GBool BitmapOutputDev::beginType3Char(GfxState *state, double x, double y,
1326 double dx, double dy,
1327 CharCode code, Unicode *u, int uLen)
1329 msg("<debug> beginType3Char");
1330 /* call gfxdev so that it can generate "invisible" characters
1331 on top of the actual graphic content, for text extraction */
1332 return gfxdev->beginType3Char(state, x, y, dx, dy, code, u, uLen);
1334 void BitmapOutputDev::type3D0(GfxState *state, double wx, double wy)
1336 msg("<debug> type3D0");
1337 return gfxdev->type3D0(state, wx, wy);
1339 void BitmapOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury)
1341 msg("<debug> type3D1");
1342 return gfxdev->type3D1(state, wx, wy, llx, lly, urx, ury);
1344 void BitmapOutputDev::endType3Char(GfxState *state)
1346 msg("<debug> endType3Char");
1347 gfxdev->endType3Char(state);
1350 class CopyStream: public Object
1354 MemStream*memstream;
1356 CopyStream(Stream*str, int len)
1361 buf = (char*)malloc(len);
1363 for (t=0; t<len; t++)
1364 buf[t] = str->getChar();
1367 this->dict = str->getDict();
1368 this->memstream = new MemStream(buf, 0, len, this);
1372 ::free(this->buf);this->buf = 0;
1373 delete this->memstream;
1375 Dict* getDict() {return dict;}
1376 Stream* getStream() {return this->memstream;};
1379 void BitmapOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
1380 int width, int height, GBool invert,
1383 msg("<debug> drawImageMask streamkind=%d", str->getKind());
1384 CopyStream*cpystr = 0;
1386 cpystr = new CopyStream(str, height * ((width + 7) / 8));
1387 str = cpystr->getStream();
1389 boolpolydev->drawImageMask(state, ref, str, width, height, invert, inlineImg);
1390 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1391 rgbdev->drawImageMask(state, ref, str, width, height, invert, inlineImg);
1395 void BitmapOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
1396 int width, int height, GfxImageColorMap *colorMap,
1397 int *maskColors, GBool inlineImg)
1399 msg("<debug> drawImage streamkind=%d", str->getKind());
1400 CopyStream*cpystr = 0;
1402 cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8));
1403 str = cpystr->getStream();
1405 boolpolydev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg);
1406 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1407 rgbdev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg);
1411 void BitmapOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
1412 int width, int height,
1413 GfxImageColorMap *colorMap,
1414 Stream *maskStr, int maskWidth, int maskHeight,
1417 msg("<debug> drawMaskedImage streamkind=%d", str->getKind());
1418 boolpolydev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert);
1419 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1420 rgbdev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert);
1422 void BitmapOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
1423 int width, int height,
1424 GfxImageColorMap *colorMap,
1426 int maskWidth, int maskHeight,
1427 GfxImageColorMap *maskColorMap)
1429 msg("<debug> drawSoftMaskedImage %dx%d (%dx%d) streamkind=%d", width, height, maskWidth, maskHeight, str->getKind());
1430 boolpolydev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap);
1431 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1432 rgbdev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap);
1434 void BitmapOutputDev::drawForm(Ref id)
1436 msg("<debug> drawForm");
1437 boolpolydev->drawForm(id);
1438 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1439 rgbdev->drawForm(id);
1442 void BitmapOutputDev::processLink(Link *link, Catalog *catalog)
1444 msg("<debug> processLink");
1445 gfxdev->processLink(link, catalog);
1448 void BitmapOutputDev::beginTransparencyGroup(GfxState *state, double *bbox,
1449 GfxColorSpace *blendingColorSpace,
1450 GBool isolated, GBool knockout,
1453 msg("<debug> beginTransparencyGroup");
1454 #if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
1455 GfxState*state1 = state->copy();
1456 GfxState*state2 = state->copy();
1458 state1->setPath(state->getPath()->copy());
1460 state2->setPath(state->getPath()->copy());
1462 GfxState*state1 = state->copy(gTrue);
1463 GfxState*state2 = state->copy(gTrue);
1465 boolpolydev->beginTransparencyGroup(state1, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
1466 rgbdev->beginTransparencyGroup(state2, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
1467 clip1dev->beginTransparencyGroup(state, bbox, blendingColorSpace, isolated, knockout, forSoftMask);
1471 void BitmapOutputDev::endTransparencyGroup(GfxState *state)
1473 msg("<debug> endTransparencyGroup");
1474 #if (xpdfMajorVersion*10000 + xpdfMinorVersion*100 + xpdfUpdateVersion) < 30207
1475 GfxState*state1 = state->copy();
1476 GfxState*state2 = state->copy();
1478 state1->setPath(state->getPath()->copy());
1480 state2->setPath(state->getPath()->copy());
1482 GfxState*state1 = state->copy(gTrue);
1483 GfxState*state2 = state->copy(gTrue);
1485 boolpolydev->endTransparencyGroup(state1);
1486 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1487 rgbdev->endTransparencyGroup(state2);
1490 clip1dev->endTransparencyGroup(state);
1492 void BitmapOutputDev::paintTransparencyGroup(GfxState *state, double *bbox)
1494 msg("<debug> paintTransparencyGroup");
1495 boolpolydev->paintTransparencyGroup(state,bbox);
1496 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1497 rgbdev->paintTransparencyGroup(state,bbox);
1498 clip1dev->paintTransparencyGroup(state,bbox);
1500 void BitmapOutputDev::setSoftMask(GfxState *state, double *bbox, GBool alpha, Function *transferFunc, GfxColor *backdropColor)
1502 msg("<debug> setSoftMask");
1503 boolpolydev->setSoftMask(state, bbox, alpha, transferFunc, backdropColor);
1504 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1505 rgbdev->setSoftMask(state, bbox, alpha, transferFunc, backdropColor);
1506 clip1dev->setSoftMask(state, bbox, alpha, transferFunc, backdropColor);
1508 void BitmapOutputDev::clearSoftMask(GfxState *state)
1510 msg("<debug> clearSoftMask");
1511 boolpolydev->clearSoftMask(state);
1512 checkNewBitmap(UNKNOWN_BOUNDING_BOX);
1513 rgbdev->clearSoftMask(state);
1514 clip1dev->clearSoftMask(state);