- wxMemoryDC memDC;
- memDC.SelectObject( bitmap );
- Blit( x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, useMask );
+ wxCHECK_RET( m_ok && m_pstream, "invalid postscript dc" );
+
+ if (!bitmap.Ok()) return;
+
+ wxImage image( bitmap );
+
+ if (!image.Ok()) return;
+
+ int ww = XLOG2DEVREL(image.GetWidth());
+ int hh = YLOG2DEVREL(image.GetHeight());
+
+ image = image.Scale( ww, hh );
+
+ if (!image.Ok()) return;
+
+ int xx = XLOG2DEV(x);
+ int yy = YLOG2DEV(y + bitmap.GetHeight());
+
+ *m_pstream << "/origstate save def\n"
+ << "20 dict begin\n"
+ << "/pix " << ww << " string def\n"
+ << "/grays " << ww << " string def\n"
+ << "/npixels 0 def\n"
+ << "/rgbindx 0 def\n"
+ << xx << " " << yy << " translate\n"
+ << ww << " " << hh << " scale\n"
+ << ww << " " << hh << " 8\n"
+ << "[" << ww << " 0 0 " << (-hh) << " 0 " << hh << "]\n"
+ << "{currentfile pix readhexstring pop}\n"
+ << "false 3 colorimage\n";
+
+ for (int j = 0; j < hh; j++)
+ {
+ for (int i = 0; i < ww; i++)
+ {
+ char buffer[5];
+ buffer[2] = 0;
+ wxDecToHex( image.GetRed(i,j), buffer );
+ *m_pstream << buffer;
+ wxDecToHex( image.GetGreen(i,j), buffer );
+ *m_pstream << buffer;
+ wxDecToHex( image.GetBlue(i,j), buffer );
+ *m_pstream << buffer;
+ }
+ *m_pstream << "\n";
+ }
+
+ *m_pstream << "end\n";
+ *m_pstream << "origstate restore\n";
+