Size GetPixelsPerMeter(const Draw& draw) { if(draw.Dots()) return Size(DOTS_PER_METER_INT, DOTS_PER_METER_INT); else return iscale(draw.GetPagePixels(), Size(1000, 1000), max(draw.GetPageMMs(), Size(1, 1))); }
void DrawImageBandRLE(Draw& w, int x, int y, const Image& m, int minp) { int xi = 0; int cx = m.GetWidth(); int ccy = m.GetHeight(); Buffer<bool> todo(cx, true); #ifdef BENCHMARK_RLE sTotal += cx; #endif while(xi < cx) { int xi0 = xi; while(w.Dots() && IsWhiteColumn(m, xi) && xi < cx) xi++; if(xi - xi0 >= 16) { #ifdef BENCHMARK_RLE sRle += xi - xi0; #endif w.DrawRect(x + xi0, y, xi - xi0, ccy, White); Fill(~todo + xi0, ~todo + xi, false); } xi++; } xi = 0; while(xi < cx) if(todo[xi]) { int xi0 = xi; while(xi < cx && todo[xi] && xi - xi0 < 2000) xi++; w.DrawImage(x + xi0, y, m, RectC(xi0, 0, xi - xi0, ccy)); } else xi++; }
NAMESPACE_UPP #ifdef SYSTEMDRAW Size GetPixelsPerMeter(const Draw& draw) { if(draw.Dots()) return Size(DOTS_PER_METER_INT, DOTS_PER_METER_INT); else return Size(96 * DOTS_PER_METER_INT / 600, 96 * DOTS_PER_METER_INT / 600); }
int HorzPixelsToDots(const Draw& draw, int dots) { return draw.Dots() ? dots : fround(dots / GetHorzPixelsPerDot(draw)); }
Size PixelsToDots(const Draw& draw, Size size) { return draw.Dots() ? size : iscale(size, Size(DOTS_PER_METER_INT, DOTS_PER_METER_INT), GetPixelsPerMeter(draw)); }
int PixelsToDots(const Draw& draw, int pixels) { return draw.Dots() ? pixels : fround(pixels / GetAvgPixelsPerDot(draw)); }
int VertDotsToPixels(const Draw& draw, int dots) { return draw.Dots() ? dots : fround(dots * GetVertPixelsPerDot(draw)); }
double GetAvgPixelsPerDot(const Draw& draw) { if(draw.Dots()) return 1; return GetAvgPixelsPerMeter(draw) / DOTS_PER_METER_DBL; }
double GetVertPixelsPerDot(const Draw& draw) { return draw.Dots() ? 1 : GetVertPixelsPerMeter(draw) / DOTS_PER_METER_DBL; }
int GetVertPixelsPerMeter(const Draw& draw) { return draw.Dots() ? DOTS_PER_METER_INT : 96 * DOTS_PER_METER_INT / 600; }
Size PointsToPixels(const Draw& draw, Size points) { if(draw.Dots()) return points * 600 / 72; return iscale(points, draw.GetPixelsPerInch(), Size(72, 72)); }
int PointsToPixels(const Draw& draw, int points) { if(draw.Dots()) return points * 600 / 72; return iscale(points, draw.GetPixelsPerInch().cx, 72); }
Size PixelsToPoints(const Draw& draw, Size pixels) { if(draw.Dots()) return pixels * 72 / 600; return iscale(pixels, Size(72, 72), draw.GetPixelsPerInch()); }
int PixelsToPoints(const Draw& draw, int pixels) { if(draw.Dots()) return pixels * 72 / 600; return iscale(pixels, 72, draw.GetPixelsPerInch().cx); }
int GetVertPixelsPerMeter(const Draw& draw) { return draw.Dots() ? DOTS_PER_METER_INT : iscale(draw.GetPagePixels().cy, 1000, max(draw.GetPageMMs().cy, 1)); }