kopia lustrzana https://github.com/njcrawford/EmbroideryReader
Add some basic checks on printer resolution to try to debug issue #11
rodzic
8798fcb80c
commit
fe2e9a7446
|
@ -527,9 +527,24 @@ namespace embroideryReader
|
||||||
{
|
{
|
||||||
if (design != null)
|
if (design != null)
|
||||||
{
|
{
|
||||||
float inchesPerMM = 0.03937007874015748031496062992126f;
|
int xDpi = e.PageSettings.PrinterResolution.X;
|
||||||
e.Graphics.ScaleTransform((float)(e.PageSettings.PrinterResolution.X * inchesPerMM * 0.01f), (float)(e.PageSettings.PrinterResolution.Y * inchesPerMM * 0.01f));
|
int yDpi = e.PageSettings.PrinterResolution.Y;
|
||||||
using (Bitmap tempDrawArea = design.designToBitmap((float)settings.threadThickness, settings.filterStiches, settings.filterStitchesThreshold, e.PageSettings.PrinterResolution.X * inchesPerMM * 0.2f))
|
// Basic checks on printer resolution
|
||||||
|
if(xDpi < 20 || xDpi > 10000)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("Printer X DPI claims to be '" + xDpi + "', expected range 20 - 10000");
|
||||||
|
}
|
||||||
|
if (yDpi < 20 || yDpi > 10000)
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException("Printer Y DPI claims to be '" + yDpi + "', expected range 20 - 10000");
|
||||||
|
}
|
||||||
|
|
||||||
|
const double inchesPerMM = 0.03937007874015748031496062992126f;
|
||||||
|
double graphicsXScaleFactor = xDpi * inchesPerMM * 0.01;
|
||||||
|
double graphicsYScaleFactor = yDpi * inchesPerMM * 0.01;
|
||||||
|
double designScaleFactor = xDpi * inchesPerMM * 0.2f;
|
||||||
|
e.Graphics.ScaleTransform((float)graphicsXScaleFactor, (float)graphicsYScaleFactor);
|
||||||
|
using (Bitmap tempDrawArea = design.designToBitmap((float)settings.threadThickness, settings.filterStiches, settings.filterStitchesThreshold, (float)designScaleFactor))
|
||||||
{
|
{
|
||||||
e.Graphics.DrawImage(tempDrawArea, 30, 30);
|
e.Graphics.DrawImage(tempDrawArea, 30, 30);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue