+
+class CopyStream: public Object
+{
+ Dict*dict;
+ char*buf;
+ MemStream*memstream;
+ public:
+ CopyStream(Stream*str, int len)
+ {
+ buf = 0;
+ str->reset();
+ if(len) {
+ buf = (char*)malloc(len);
+ int t;
+ for (t=0; t<len; t++)
+ buf[t] = str->getChar();
+ }
+ str->close();
+ this->dict = str->getDict();
+ this->memstream = new MemStream(buf, 0, len, this);
+ }
+ ~CopyStream()
+ {
+ ::free(this->buf);this->buf = 0;
+ delete this->memstream;
+ }
+ Dict* getDict() {return dict;}
+ Stream* getStream() {return this->memstream;};
+};
+
+gfxbbox_t BitmapOutputDev::getImageBBox(GfxState*state)
+{
+ gfxbbox_t bbox;
+ double x,y;
+ state->transform(0, 1, &x, &y);
+ bbox.xmin=bbox.xmax = x;
+ bbox.ymin=bbox.ymax = x;
+ state->transform(0, 0, &x, &y);
+ bbox.xmin=min(bbox.xmin,x);
+ bbox.ymin=min(bbox.ymin,y);
+ bbox.xmax=max(bbox.xmin,x);
+ bbox.ymax=max(bbox.ymin,y);
+ state->transform(1, 0, &x, &y);
+ bbox.xmin=min(bbox.xmin,x);
+ bbox.ymin=min(bbox.ymin,y);
+ bbox.xmax=max(bbox.xmin,x);
+ bbox.ymax=max(bbox.ymin,y);
+ state->transform(1, 1, &x, &y);
+ bbox.xmin=min(bbox.xmin,x);
+ bbox.ymin=min(bbox.ymin,y);
+ bbox.xmax=max(bbox.xmin,x);
+ bbox.ymax=max(bbox.ymin,y);
+ return bbox;
+}