bool ImagesEngine::RenderPage(HDC hDC, RectI screenRect, int pageNo, float zoom, int rotation, RectD *pageRect, RenderTarget target, AbortCookie **cookie_out) { Bitmap *bmp = LoadImage(pageNo); if (!bmp) return false; RectD pageRc = pageRect ? *pageRect : PageMediabox(pageNo); RectI screen = Transform(pageRc, pageNo, zoom, rotation).Round(); Graphics g(hDC); g.SetCompositingQuality(CompositingQualityHighQuality); g.SetSmoothingMode(SmoothingModeAntiAlias); g.SetPageUnit(UnitPixel); Color white(0xFF, 0xFF, 0xFF); Rect screenR(screenRect.ToGdipRect()); g.SetClip(screenR); g.FillRectangle(&SolidBrush(white), screenR); Matrix m; GetTransform(m, pageNo, zoom, rotation); m.Translate((REAL)(screenRect.x - screen.x), (REAL)(screenRect.y - screen.y), MatrixOrderAppend); g.SetTransform(&m); RectI pageRcI = PageMediabox(pageNo).Round(); ImageAttributes imgAttrs; imgAttrs.SetWrapMode(WrapModeTileFlipXY); Status ok = g.DrawImage(bmp, pageRcI.ToGdipRect(), 0, 0, pageRcI.dx, pageRcI.dy, UnitPixel, &imgAttrs); return ok == Ok; }
static void DrawFrame2(Graphics &g, RectI r) { g.SetCompositingQuality(CompositingQualityHighQuality); g.SetSmoothingMode(SmoothingModeAntiAlias); g.SetPageUnit(UnitPixel); Font f(L"Impact", 40, FontStyleRegular); CalcLettersLayout(g, &f, r.dx); SolidBrush bgBrush(Color(0xff, 0xf2, 0)); Rect r2(r.ToGdipRect()); r2.Inflate(1, 1); g.FillRectangle(&bgBrush, r2); Font f2(L"Impact", 16, FontStyleRegular); DrawSumatraLetters(g, &f, &f2, 18.f); if (gShowOptions) return; REAL msgY = (REAL)(r.dy / 2); if (gMsg) msgY += DrawMessage(g, gMsg, msgY, (REAL)r.dx, gMsgColor) + 5; if (gMsgError) DrawMessage(g, gMsgError, msgY, (REAL)r.dx, COLOR_MSG_FAILED); }
void PaintTransparentRectangles(HDC hdc, RectI screenRc, Vec<RectI>& rects, COLORREF selectionColor, BYTE alpha, int margin) { using namespace Gdiplus; // create path from rectangles GraphicsPath path(FillModeWinding); screenRc.Inflate(margin, margin); for (size_t i = 0; i < rects.size(); i++) { RectI rc = rects.at(i).Intersect(screenRc); if (!rc.IsEmpty()) path.AddRectangle(rc.ToGdipRect()); } // fill path (and draw optional outline margin) Graphics gs(hdc); Color c(alpha, GetRValueSafe(selectionColor), GetGValueSafe(selectionColor), GetBValueSafe(selectionColor)); SolidBrush tmpBrush(c); gs.FillPath(&tmpBrush, &path); if (margin) { path.Outline(nullptr, 0.2f); Pen tmpPen(Color(alpha, 0, 0, 0), (REAL)margin); gs.DrawPath(&tmpPen, &path); } }