// wxPostScriptDC
//-------------------------------------------------------------------------------
+float wxPostScriptDC::ms_PSScaleFactor = 10.0;
+
+void wxPostScriptDC::SetResolution(int ppi)
+{
+ ms_PSScaleFactor = (float)ppi / 72.0;
+}
+
+int wxPostScriptDC::GetResolution()
+{
+ return (int)(ms_PSScaleFactor * 72.0);
+}
+
+
+
wxPostScriptDC::wxPostScriptDC ()
{
m_pstream = (FILE*) NULL;
if (!image.Ok()) return;
+ wxCoord w = image.GetWidth();
+ wxCoord h = image.GetHeight();
+
wxCoord ww = XLOG2DEVREL(image.GetWidth());
wxCoord hh = YLOG2DEVREL(image.GetHeight());
- image = image.Scale( ww, hh );
-
- if (!image.Ok()) return;
-
wxCoord xx = XLOG2DEV(x);
wxCoord yy = YLOG2DEV(y + bitmap.GetHeight());
"[%d 0 0 %d 0 %d]\n"
"{currentfile pix readhexstring pop}\n"
"false 3 colorimage\n",
- ww, ww, xx, yy, ww, hh, ww, hh, ww, -hh, hh );
+ w, w, xx, yy, ww, hh, w, h, w, -h, h );
+
- for (int j = 0; j < hh; j++)
+ for (int j = 0; j < h; j++)
{
- for (int i = 0; i < ww; i++)
+ for (int i = 0; i < w; i++)
{
char buffer[5];
LocalDecToHex( image.GetRed(i,j), buffer );
fprintf( m_pstream, " findfont\n" );
sprintf( buffer, "%f scalefont setfont\n", YLOG2DEVREL(m_font.GetPointSize() * 1000) / 1000.0F);
- for (int i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
- fprintf( m_pstream, buffer );
// this is a hack - we must scale font size (in pts) according to m_scaleY but
// YLOG2DEVREL works with wxCoord type (int or longint). Se we first convert font size
// to 1/1000th of pt and then back.
+ for (int i = 0; i < 100; i++)
+ if (buffer[i] == ',') buffer[i] = '.';
+ fprintf( m_pstream, buffer );
}
void wxPostScriptDC::SetPen( const wxPen& pen )
sprintf( buffer, "%f setlinewidth\n", XLOG2DEVREL(1000 * m_pen.GetWidth()) / 1000.0f );
#endif
for (int i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
}
double redPS = (double)(red) / 255.0;
double bluePS = (double)(blue) / 255.0;
double greenPS = (double)(green) / 255.0;
-
+
char buffer[100];
sprintf( buffer,
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
m_underlineThickness,
XLOG2DEV(x + text_w), YLOG2DEV(uy) );
for (i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
}
"%.8f %.8f %.8f setrgbcolor\n",
redPS, greenPS, bluePS );
for (int i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
m_currentRed = red;
// FIXME only correct for 90 degrees
fprintf(m_pstream, "%d %d moveto\n",
- XLOG2DEV((wxCoord)(x + size)), YLOG2DEV(by) );
-
+ XLOG2DEV((wxCoord)(x + size)), YLOG2DEV((wxCoord)by) );
+
char buffer[100];
sprintf(buffer, "%.8f rotate\n", angle);
int i;
for (i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf(m_pstream, buffer);
/* I don't know how to write char to a stream, so I use a mini string */
}
fprintf( m_pstream, ") show\n" );
-
+
sprintf( buffer, "%.8f rotate\n", -angle );
for (i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
if (m_font.GetUnderlined())
m_underlineThickness,
XLOG2DEV(x + w), YLOG2DEV(uy) );
for (i = 0; i < 100; i++)
- if (buffer[i] == ',') buffer[i] = '.';
+ if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
}
h = tmp;
}
- if (width) *width = w;
- if (height) *height = h;
+ if (width) *width = (int)(w * ms_PSScaleFactor);
+ if (height) *height = (int)(h * ms_PSScaleFactor);
}
void wxPostScriptDC::DoGetSizeMM(int *width, int *height) const
// Resolution in pixels per logical inch
wxSize wxPostScriptDC::GetPPI(void) const
{
- return wxSize(72, 72);
+ return wxSize((int)(72 * ms_PSScaleFactor),
+ (int)(72 * ms_PSScaleFactor));
}
}
char buffer[100];
- sprintf( buffer, "%.8f %.8f scale\n", scale_x, scale_y );
+ sprintf( buffer, "%.8f %.8f scale\n", scale_x / ms_PSScaleFactor,
+ scale_y / ms_PSScaleFactor);
for (int i = 0; i < 100; i++)
if (buffer[i] == ',') buffer[i] = '.';
fprintf( m_pstream, buffer );
-
+
fprintf( m_pstream, "%d %d translate\n", translate_x, translate_y );
}
wxCoord wxPostScriptDC::GetCharHeight() const
{
if (m_font.Ok())
- return m_font.GetPointSize();
+ return m_font.GetPointSize();
else
return 12;
}
// VS: dirty, but is there any better solution?
double *pt;
pt = (double*) &m_underlinePosition;
- *pt = YLOG2DEVREL(UnderlinePosition * fontToUse->GetPointSize()) / 1000.0f;
+ *pt = YLOG2DEVREL((wxCoord)(UnderlinePosition * fontToUse->GetPointSize())) / 1000.0f;
pt = (double*) &m_underlineThickness;
- *pt = YLOG2DEVREL(UnderlineThickness * fontToUse->GetPointSize()) / 1000.0f;
+ *pt = YLOG2DEVREL((wxCoord)(UnderlineThickness * fontToUse->GetPointSize())) / 1000.0f;
}
SetPrinterCommand(data.GetPrinterCommand());
SetPrintPreviewCommand(data.GetPreviewCommand());
SetPrinterOptions(data.GetPrinterOptions());
- SetPrinterTranslation(data.GetPrinterTranslateX(), data.GetPrinterTranslateY());
+ SetPrinterTranslation((wxCoord)data.GetPrinterTranslateX(),
+ (wxCoord)data.GetPrinterTranslateY());
SetPrinterScaling(data.GetPrinterScaleX(), data.GetPrinterScaleY());
SetPrinterOrientation(data.GetOrientation());
SetPrinterMode((int) data.GetPrintMode());