X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fpdf%2FBitmapOutputDev.cc;h=c9bcbb2686ea3ad984f9d5033a7d11217f780a31;hp=adc31653d41a95a807b6e60af03eecd255c9d2b7;hb=4374572fb79cbe25bdd1498802605db5dfc908a6;hpb=c3cacee02d5a26355bccc9865dc213e47eeb5370 diff --git a/lib/pdf/BitmapOutputDev.cc b/lib/pdf/BitmapOutputDev.cc index adc3165..c9bcbb2 100644 --- a/lib/pdf/BitmapOutputDev.cc +++ b/lib/pdf/BitmapOutputDev.cc @@ -216,8 +216,8 @@ void BitmapOutputDev::flushBitmap() /* clip against (-movex, -movey, -movex+width, -movey+height) */ if(xmin < -this->movex) xmin = -this->movex; if(ymin < -this->movey) ymin = -this->movey; - if(xmax > -this->movex + width) xmax = -this->movex+this->width; - if(ymax > -this->movey + height) ymax = -this->movey+this->height; + if(xmax > -this->movex + this->width) xmax = -this->movex+this->width; + if(ymax > -this->movey + this->height) ymax = -this->movey+this->height; msg(" Flushing bitmap (bbox: %d,%d,%d,%d)", xmin,ymin,xmax,ymax); @@ -454,16 +454,49 @@ static void update_bitmap(SplashBitmap*bitmap, SplashBitmap*update, int x1, int if(!fixBBox(&x1, &y1, &x2, &y2, bitmap->getWidth(), bitmap->getHeight())) return; - Guchar*b = bitmap->getDataPtr() + y1*width8; - Guchar*u = update->getDataPtr() + y1*width8; + Guchar*b = bitmap->getDataPtr() + y1*width8 + x1/8; + Guchar*u = update->getDataPtr() + y1*width8 + x1/8; + int yspan = y2-y1; + int xspan = (x2+7)/8 - x1/8; int size = (y2-y1)*width8; if(overwrite) { - memcpy(b, u, size); + int y; + for(y=0;ywidth = (int)(x2-x1); this->height = (int)(y2-y1); - msg(" startPage"); 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); @@ -826,6 +858,8 @@ void BitmapOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, do booltextbitmap = booltextdev->getBitmap(); staletextbitmap = new SplashBitmap(booltextbitmap->getWidth(), booltextbitmap->getHeight(), 1, booltextbitmap->getMode(), 0); assert(staletextbitmap->getRowSize() == booltextbitmap->getRowSize()); + + msg(" startPage %dx%d (%dx%d)", this->width, this->height, booltextbitmap->getWidth(), booltextbitmap->getHeight()); clip0bitmap = clip0dev->getBitmap(); clip1bitmap = clip1dev->getBitmap(); @@ -1611,17 +1645,15 @@ void BitmapOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, GBool inlineImg) { msg(" drawImageMask streamkind=%d", str->getKind()); - CopyStream*cpystr = 0; - if(inlineImg) { - cpystr = new CopyStream(str, height * ((width + 7) / 8)); - str = cpystr->getStream(); - } + + CopyStream*cpystr = new CopyStream(str, height * ((width + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawImageMask(state, ref, str, width, height, invert, inlineImg); gfxbbox_t bbox = getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawImageMask(state, ref, str, width, height, invert, inlineImg); - if(cpystr) - delete cpystr; + delete cpystr; dbg_newdata("imagemask"); } void BitmapOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, @@ -1629,17 +1661,15 @@ void BitmapOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int *maskColors, GBool inlineImg) { msg(" drawImage streamkind=%d", str->getKind()); - CopyStream*cpystr = 0; - if(inlineImg) { - cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); - str = cpystr->getStream(); - } + + CopyStream*cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg); gfxbbox_t bbox=getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawImage(state, ref, str, width, height, colorMap, maskColors, inlineImg); - if(cpystr) - delete cpystr; + delete cpystr; dbg_newdata("image"); } void BitmapOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, @@ -1649,10 +1679,15 @@ void BitmapOutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str, GBool maskInvert) { msg(" drawMaskedImage streamkind=%d", str->getKind()); + + CopyStream*cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert); gfxbbox_t bbox=getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskInvert); + delete cpystr; dbg_newdata("maskedimage"); } void BitmapOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, @@ -1663,10 +1698,15 @@ void BitmapOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream * GfxImageColorMap *maskColorMap) { msg(" drawSoftMaskedImage %dx%d (%dx%d) streamkind=%d", width, height, maskWidth, maskHeight, str->getKind()); + + CopyStream*cpystr = new CopyStream(str, height * ((width * colorMap->getNumPixelComps() * colorMap->getBits() + 7) / 8)); + str = cpystr->getStream(); + boolpolydev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap); gfxbbox_t bbox=getImageBBox(state); checkNewBitmap(bbox.xmin, bbox.ymin, ceil(bbox.xmax), ceil(bbox.ymax)); rgbdev->drawSoftMaskedImage(state, ref, str, width, height, colorMap, maskStr, maskWidth, maskHeight, maskColorMap); + delete cpystr; dbg_newdata("softmaskimage"); } void BitmapOutputDev::drawForm(Ref id)