void ShadowSur::EllipseSkew(const float centerx, const float centery, const float radius, const float z1, const float z2) const { const int basepixel = SCALEXf(m_z); const int top = SCALEXf(z2) - basepixel; if (top <= 0) return; //This entire polygon is underneath this shadow level int bottom = SCALEXf(z1) - basepixel; if (bottom < 0) bottom = 0; // Polygon crosses shadow level const int ix = SCALEXf(centerx); const int iy = SCALEYf(centery); const int ir = SCALEDf(radius); SelectObject(m_hdc, GetStockObject(BLACK_PEN)); SelectObject(m_hdc, GetStockObject(BLACK_BRUSH)); for (int i=bottom;i<top;i++) { //SetViewportOrgEx(m_hdc, i, -i, NULL); SetViewportOrgEx(m_hdc, (int)((float)i*m_shadowDirX), (int)((float)i*m_shadowDirY), NULL); ::Ellipse(m_hdc, ix - ir, iy - ir, ix + ir, iy + ir); } SetViewportOrgEx(m_hdc, 0, 0, NULL); }
void DrawTime(HWND hwnd, HBRUSH hBrushRed) { PAINTSTRUCT ps; HDC hdc; hdc = BeginPaint(hwnd, &ps); SetMapMode(hdc, MM_ISOTROPIC); SetWindowExtEx(hdc, WINDOW_WIDTH, WINDOW_HEIGHT, NULL); SetViewportExtEx(hdc, WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, NULL); SelectObject(hdc, GetStockObject(NULL_PEN)); SelectObject(hdc, hBrushRed); SetBkMode(hdc, TRANSPARENT); if (n_chess % 2 + 1 == 1) { SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL); _DisplayTime(hwnd, hdc); SetViewportOrgEx(hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL); DisplayTwoDigits(hdc, 0, FALSE); DisplayColon(hdc); DisplayTwoDigits(hdc, 0, FALSE); } else { SetViewportOrgEx(hdc, PLAYER1_TIME_X1, PLAYER1_TIME_Y1, NULL); DisplayTwoDigits(hdc, 0, FALSE); DisplayColon(hdc) ; DisplayTwoDigits(hdc, 0, FALSE); SetViewportOrgEx (hdc, PLAYER2_TIME_X1 - 80, PLAYER2_TIME_Y1, NULL); _DisplayTime(hwnd, hdc); } EndPaint(hwnd,&ps); }
void graphdefaults() { set_defaults(); for (int i = 0; i <= MAXCOLORS; i++) { current_palette.colors[i] = i; BGIpalette[i] = BGIcolor[i]; } SetPaletteEntries(hPalette, BG, MAXCOLORS+1, BGIpalette); RealizePalette(hdc[0]); SetTextColor(hdc[0], PALETTEINDEX(text_color+BG)); SetTextColor(hdc[1], PALETTEINDEX(text_color+BG)); SetBkColor(hdc[0], PALETTEINDEX(BG)); SetBkColor(hdc[1], PALETTEINDEX(BG)); SelectClipRgn(hdc[0], NULL); SelectClipRgn(hdc[1], NULL); SetViewportOrgEx(hdc[0], 0, 0, NULL); SetViewportOrgEx(hdc[1], 0, 0, NULL); SelectObject(hdc[0], hBrush[fill_settings.pattern]); SelectObject(hdc[1], hBrush[fill_settings.pattern]); moveto(0,0); }
void ShadowSur::PolygonSkew(const Vector<RenderVertex> &rgv, const float z1, const float z2) const { const int basepixel = SCALEXf(m_z); const int top = SCALEXf(z2) - basepixel; if (top <= 0) return; //This entire polygon is underneath this shadow level int bottom = SCALEXf(z1) - basepixel; if (bottom < 0) bottom = 0; // Polygon crosses shadow level const int count = rgv.Size(); POINT * const rgpt = new POINT[count]; for (int i=0;i<count;i++) { rgpt[i].x = SCALEXf(rgv.ElementAt(i)->x); rgpt[i].y = SCALEYf(rgv.ElementAt(i)->y); } SelectObject(m_hdc, GetStockObject(BLACK_PEN)); SelectObject(m_hdc, GetStockObject(BLACK_BRUSH)); for (int i=bottom;i<top;i++) { //SetViewportOrgEx(m_hdc, i, -i, NULL); SetViewportOrgEx(m_hdc, (int)((float)i*m_shadowDirX), (int)((float)i*m_shadowDirY), NULL); ::Polygon(m_hdc, rgpt, count); } delete [] rgpt; SetViewportOrgEx(m_hdc, 0, 0, NULL); }
void ShadowSur::PolylineSkew(const Vertex2D * const rgv, const int count, const float * const rgz, const float z1, const float z2) const { //const int basepixel = SCALEXf(m_z); //const int bottom = SCALEX(z1) - basepixel; //const int top = SCALEX(z2) - basepixel; POINT * const rgpt = new POINT[count]; int cpoints = 0; // points above the shadow level if (rgz) for (int i=0;i<count;++i) if (rgz[i] > m_z) { rgpt[cpoints].x = SCALEXf(rgv[cpoints].x + rgz[cpoints]); rgpt[cpoints].y = SCALEYf(rgv[cpoints].y - rgz[cpoints]); ++cpoints; } SelectObject(m_hdc, m_hpnLine); for (int i=0;i<1;++i) { //SetViewportOrgEx(m_hdc, i, -i, NULL); SetViewportOrgEx(m_hdc, (int)((float)i*m_shadowDirX), (int)((float)i*m_shadowDirY), NULL); ::Polyline(m_hdc, rgpt, cpoints); } delete [] rgpt; SetViewportOrgEx(m_hdc, 0, 0, NULL); }
void CLCDCollection::OnDraw(CLCDGfxBase &rGfx) { if(!IsVisible()) { return; } //iterate through your objects and draw them LCD_OBJECT_LIST::iterator it = m_Objects.begin(); while(it != m_Objects.end()) { CLCDBase *pObject = *it++; LCDUIASSERT(NULL != pObject); if (pObject->IsVisible()) { pObject->OnPrepareDraw(rGfx); // create the clip region HRGN hRgn = CreateRectRgn(pObject->GetOrigin().x, pObject->GetOrigin().y, pObject->GetOrigin().x + pObject->GetWidth(), pObject->GetOrigin().y + pObject->GetHeight()); // ensure that controls only draw within their specified region SelectClipRgn(rGfx.GetHDC(), hRgn); // free the region (a copy is used in the call above) DeleteObject(hRgn); // offset the control at its origin so controls use (0,0) POINT ptPrevViewportOrg = { 0, 0 }; SetViewportOrgEx(rGfx.GetHDC(), pObject->GetOrigin().x, pObject->GetOrigin().y, &ptPrevViewportOrg); // allow controls to supply additional translation // this allows controls to move freely within the confined viewport OffsetViewportOrgEx(rGfx.GetHDC(), pObject->GetLogicalOrigin().x, pObject->GetLogicalOrigin().y, NULL); pObject->OnDraw(rGfx); // set the clipping region to nothing SelectClipRgn(rGfx.GetHDC(), NULL); // restore the viewport origin SetViewportOrgEx(rGfx.GetHDC(), ptPrevViewportOrg.x, ptPrevViewportOrg.y, NULL); // restore the viewport origin offset OffsetViewportOrgEx(rGfx.GetHDC(), 0, 0, NULL); } } }
static GpStatus METAFILE_PlaybackGetDC(GpMetafile *metafile) { GpStatus stat = Ok; stat = GdipGetDC(metafile->playback_graphics, &metafile->playback_dc); if (stat == Ok) { /* The result of GdipGetDC always expects device co-ordinates, but the * device co-ordinates of the source metafile do not correspond to * device co-ordinates of the destination. Therefore, we set up the DC * so that the metafile's bounds map to the destination points where we * are drawing this metafile. */ SetMapMode(metafile->playback_dc, MM_ANISOTROPIC); SetWindowOrgEx(metafile->playback_dc, metafile->bounds.X, metafile->bounds.Y, NULL); SetWindowExtEx(metafile->playback_dc, metafile->bounds.Width, metafile->bounds.Height, NULL); SetViewportOrgEx(metafile->playback_dc, metafile->playback_points[0].X, metafile->playback_points[0].Y, NULL); SetViewportExtEx(metafile->playback_dc, metafile->playback_points[1].X - metafile->playback_points[0].X, metafile->playback_points[2].Y - metafile->playback_points[0].Y, NULL); } return stat; }
/*********************************************************************** * SetViewportOrgEx (GDI.480) */ BOOL16 WINAPI SetViewportOrgEx16( HDC16 hdc, INT16 x, INT16 y, LPPOINT16 pt ) { POINT pt32; BOOL16 ret = SetViewportOrgEx( hdc, x, y, &pt32 ); if (pt) CONV_POINT32TO16( &pt32, pt ); return ret; }
void PageGDICalls (HDC hdcPrn, int cxPage, int cyPage) { static TCHAR szTextStr[] = TEXT ("Hello, Printer!") ; Rectangle (hdcPrn, 0, 0, cxPage, cyPage) ; MoveToEx (hdcPrn, 0, 0, NULL) ; LineTo (hdcPrn, cxPage, cyPage) ; MoveToEx (hdcPrn, cxPage, 0, NULL) ; LineTo (hdcPrn, 0, cyPage) ; SaveDC (hdcPrn) ; SetMapMode (hdcPrn, MM_ISOTROPIC) ; SetWindowExtEx (hdcPrn, 1000, 1000, NULL) ; SetViewportExtEx (hdcPrn, cxPage / 2, -cyPage / 2, NULL) ; SetViewportOrgEx (hdcPrn, cxPage / 2, cyPage / 2, NULL) ; Ellipse (hdcPrn, -500, 500, 500, -500) ; SetTextAlign (hdcPrn, TA_BASELINE | TA_CENTER) ; TextOut (hdcPrn, 0, 0, szTextStr, lstrlen (szTextStr)) ; RestoreDC (hdcPrn, -1) ; }
void Fl_Gdi::place(double x, double y, double w, double h, double tx, double ty, double tw, double th,int align) { double dx, dy; double s = tw/w; if(s<(th/h)) { dx = 0; dy = (th - s * h)*iy/144; } else { s=th/h; dy =0; dx = (tw - s * w)*ix/144; } if(align & 3) if(align & FL_ALIGN_TOP) dy=0; else dy *=2; if(align & 12) if(align & FL_ALIGN_LEFT) dx=0; else dx *=2; SetViewportOrgEx(gc_, VOx = (int)(ix * (lm_+tx) /72 - ox + dx), VOy = (int)( iy *(tm_+th) /72 - oy + dy),0); //setting origin to the upper left corner inside margins SetWindowOrgEx(gc_, WOx = (int)x, WOy = (int)y,0); SetViewportExtEx(gc_, VEx =(int)(ix*s), VEy =(int)(iy*s), 0); SetWindowExtEx(gc_, WEx = 72, WEy = 72,0); };
void gfxWindowsNativeDrawing::EndNativeDrawing() { if (mRenderState == RENDER_STATE_NATIVE_DRAWING) { // we drew directly to the HDC in the context; undo our changes SetViewportOrgEx(mDC, mOrigViewportOrigin.x, mOrigViewportOrigin.y, NULL); if (mTransformType != TRANSLATION_ONLY) SetWorldTransform(mDC, &mOldWorldTransform); mWinSurface->MarkDirty(); mRenderState = RENDER_STATE_NATIVE_DRAWING_DONE; } else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_BLACK) { mBlackSurface = mWinSurface; mWinSurface = nsnull; mRenderState = RENDER_STATE_ALPHA_RECOVERY_BLACK_DONE; } else if (mRenderState == RENDER_STATE_ALPHA_RECOVERY_WHITE) { mWhiteSurface = mWinSurface; mWinSurface = nsnull; mRenderState = RENDER_STATE_ALPHA_RECOVERY_WHITE_DONE; } else { NS_ERROR("Invalid RenderState in gfxWindowsNativeDrawing::EndNativeDrawing"); } }
BOOL DrawYScale(HDC hdc, RECT rect) { // Calculate dimensions int width = rect.right - rect.left; int height = rect.bottom - rect.top; FillRect(hdc, &rect, GetStockObject(WHITE_BRUSH)); // Move the origin SetViewportOrgEx(hdc, width / 2, height / 2, NULL); // Draw scale for (int y = 0; y < height / 2; y += 50) { MoveToEx(hdc, 0, y, NULL); LineTo(hdc, width / 2, y); MoveToEx(hdc, 0, -y, NULL); LineTo(hdc, width / 2, -y); } for (int y = 0; y < height / 2; y += 10) { MoveToEx(hdc, width / 8, y, NULL); LineTo(hdc, width / 2, y); MoveToEx(hdc, width / 8, -y, NULL); LineTo(hdc, width / 2, -y); } }
void SetIsotropic(HDC hdc, int cxClient, int cyClient) { SetMapMode(hdc, MM_ISOTROPIC); SetWindowExtEx(hdc, 1000, 1000, NULL); SetViewportExtEx(hdc, cxClient / 2, -cyClient / 2, NULL); SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL); }
void Fl_Gdi::fit(double x, double y, double w, double h, int align) { double dx, dy; double pwp = pw_ - lm_ - rm_; double php = ph_ - tm_ - bm_; double s = pwp/w; if(s<(php/h)) { dx = 0; dy = (php - s * h)*iy/144; } else { s=php/h; dy =0; dx = (pwp - s * w)*ix/144; } if(align & 3) if(align & FL_ALIGN_TOP) dy=0; else dy *=2; if(align & 12) if(align & FL_ALIGN_LEFT) dx=0; else dx *=2; SetViewportOrgEx(gc_, VOx = (int)(ix * lm_ /72 - ox + dx), VOy = (int)( iy *tm_ /72 - oy + dy),0); //setting origin to the upper left corner inside margins SetWindowOrgEx(gc_, WOx = (int)x, WOy = (int)y,0); SetViewportExtEx(gc_, VEx =(int) (ix*s), VEy =(int) (iy*s), 0); SetWindowExtEx(gc_, WEx = 72, WEy = 72,0); };
//******************************************************************* // helper to set scaling for print/preview static void SetScale(HDC dc, int uthei, int utwi, const OUT_PAR * po) { int width, height, mul, div; float yfact, xfact; long left, right, low, high; low = (int) (po->ymin - MARGIN); high = (int) (po->ymax + MARGIN); left = (int) po->xmin - MARGIN; right = (int) po->xmax + MARGIN; width = right - left; height = high - low; //to this point only used dest coords yfact = uthei / (float) height; xfact = utwi / (float) width; SetMapMode(dc, MM_ANISOTROPIC); if (fabs(yfact) < fabs(xfact)) { div = height; mul = uthei; } else { div = width; mul = utwi; } SetViewportExtEx(dc, mul, -mul, NULL); // size mult SetWindowExtEx(dc, div, div, NULL); // size divisor SetWindowOrgEx(dc, left, high, NULL); // where was origo SetViewportOrgEx(dc, 0, 0, NULL); // where do i want origo }
//-----------------------Render-------------------------------------- // // given a GDI surface this function renders the ship and the // landing pad //------------------------------------------------------------------- void CController::Render(HDC &surface) { //change the mapping mode so that the origin is at the bottom left //of our window and so that the y axis increases as it goes from //bottom to top SetMapMode( surface, MM_ANISOTROPIC ); SetViewportExtEx( surface, 1, -1, NULL ); SetWindowExtEx( surface, 1, 1, NULL ); SetViewportOrgEx( surface, 0, m_cyClient, NULL ); //select in the pen we want to use HPEN OldPen = (HPEN)SelectObject(surface, GetStockObject(WHITE_PEN)); //first render the stars for (int i=0; i<m_vecStarVB.size(); ++i) { //add some twinkle if (RandFloat() > 0.1) { SetPixel(surface, m_vecStarVB[i].x, m_vecStarVB[i].y, RGB(255, 255, 255)); } } //render the user controlled ship m_pUserLander->Render(surface); //render the landing pad... RenderLandingPad(surface); //return the mapping mode to its default state so text is rendered //correctly SetMapMode( surface, MM_ANISOTROPIC ); SetViewportExtEx( surface, 1, 1, NULL ); SetWindowExtEx( surface, 1, 1, NULL ); SetViewportOrgEx( surface, 0, 0, NULL ); //Render additional information SetBkMode(surface, TRANSPARENT); SetTextColor(surface, RGB(0,0,255)); string s= "Cursor Keys - Rotate Spacebar - Thrust R - Retry"; TextOutA(surface, 30, m_cyClient - 20, s.c_str(), s.size()); //replace the pen SelectObject(surface, OldPen); }
/** * @param hdc - drawing conImage. * @param prcPaint - the rectangle where the painting is requested. */ void CImageView::DrawImageView(HDC hdc, const RECT* prcPaint) { _ASSERTE(g_pResManager != NULL); RECT rcClient; GetClientRect(m_hwnd, &rcClient); if (prcPaint == NULL) prcPaint = &rcClient; if (IsRectEmpty(prcPaint)) return; #ifdef USE_MEM_DC int nClientWidth = prcPaint->right - prcPaint->left; int nClientHeight = prcPaint->bottom - prcPaint->top; HBITMAP hbmpMem; hbmpMem = CreateCompatibleBitmap(hdc, nClientWidth, nClientHeight); if (hbmpMem == NULL) return; HDC hdcMem; hdcMem = CreateCompatibleDC(hdc); if (hdcMem == NULL) { DeleteBitmap(hbmpMem); return; } SetViewportOrgEx(hdcMem, -prcPaint->left, -prcPaint->top, NULL); HBITMAP hbmpSafe = SelectBitmap(hdcMem, hbmpMem); #else // CS_PARENTDC sets the clipping rectangle of the child window to that of the parent window // so that the child can draw on the parent. Text view inherits this style from sub-classed // static control. This causes problems with unclipped TabbedTextOut() output. HRGN hrgn = CreateRectRgnIndirect(prcPaint); SelectClipRgn(hdc, hrgn); DeleteRgn(hrgn); HDC hdcMem = hdc; #endif FillRect(hdcMem, prcPaint, g_pResManager->m_hbrWindowBrush); HDC hdcTemp = CreateCompatibleDC(hdc); if (hdcTemp) { HBITMAP hbmpSafe2 = SelectBitmap(hdcTemp, m_hAdjustedBitmap); int nHorPos = GetScrollPos(m_hwnd, SB_HORZ); int nVertPos = GetScrollPos(m_hwnd, SB_VERT); int nImageLeft = rcClient.right > m_szAjustedBitmapSize.cx ? (rcClient.right - m_szAjustedBitmapSize.cx) / 2 : -nHorPos; int nImageTop = rcClient.bottom > m_szAjustedBitmapSize.cy ? (rcClient.bottom - m_szAjustedBitmapSize.cy) / 2 : -nVertPos; BitBlt(hdcMem, nImageLeft, nImageTop, m_szAjustedBitmapSize.cx, m_szAjustedBitmapSize.cy, hdcTemp, 0, 0, SRCCOPY); SelectBitmap(hdcTemp, hbmpSafe2); DeleteDC(hdcTemp); } #ifdef USE_MEM_DC BitBlt(hdc, prcPaint->left, prcPaint->top, nClientWidth, nClientHeight, hdcMem, prcPaint->left, prcPaint->top, SRCCOPY); SelectBitmap(hdcMem, hbmpSafe); DeleteDC(hdcMem); DeleteBitmap(hbmpMem); #endif }
void ShadowSur::PolygonSkew(const Vertex2D * const rgv, const int count, const float * const rgz) const { POINT * const rgpt = new POINT[count]; for (int i=0;i<count;i++) { rgpt[i].x = SCALEXf(rgv[i].x + rgz[i]); rgpt[i].y = SCALEYf(rgv[i].y - rgz[i]); } SelectObject(m_hdc, GetStockObject(BLACK_PEN)); SelectObject(m_hdc, GetStockObject(BLACK_BRUSH)); SetViewportOrgEx(m_hdc, 0, 0, NULL); ::Polygon(m_hdc, rgpt, count); delete [] rgpt; SetViewportOrgEx(m_hdc, 0, 0, NULL); }
void setviewport(int x1, int y1, int x2, int y2, int clip) { view_settings.left = x1; view_settings.top = y1; view_settings.right = x2; view_settings.bottom = y2; view_settings.clip = clip; if (hRgn) { DeleteObject(hRgn); } hRgn = clip ? CreateRectRgn(x1, y1, x2, y2) : NULL; SelectClipRgn(hdc[1], hRgn); SetViewportOrgEx(hdc[1], x1, y1, NULL); SelectClipRgn(hdc[0], hRgn); SetViewportOrgEx(hdc[0], x1, y1, NULL); moveto(0,0); }
HFONT CRetrySplashScreen::CreateDialogFont (HDC hdc, TCHAR *szFaceName, int ptSize, DWORD dwWeight, BOOL bUnderline) { POINT pt; FLOAT cxDPI, cyDPI; HFONT hFont; LOGFONT lf; int iDeciPtWidth = 0; int iDeciPtHeight = 10 * ptSize; int iSavedDC = SaveDC(hdc); SetGraphicsMode (hdc, GM_ADVANCED); ModifyWorldTransform(hdc, NULL, MWT_IDENTITY); SetViewportOrgEx (hdc, 0,0, NULL); SetWindowOrgEx (hdc, 0,0, NULL); cxDPI = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSX); cyDPI = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSY); pt.x = (int) (iDeciPtWidth * cxDPI / 72); pt.y = (int) (iDeciPtHeight * cyDPI / 72); DPtoLP(hdc, &pt, 1); lf.lfHeight = - (int) (fabs ((double) pt.y) / 10.0 + 0.5); lf.lfWidth = 0; lf.lfEscapement = 0; lf.lfOrientation = 0; lf.lfWeight = dwWeight; lf.lfItalic = 0; lf.lfUnderline = (bUnderline ? 1 : 0); lf.lfStrikeOut = 0; lf.lfCharSet = 0; lf.lfOutPrecision = 0; lf.lfClipPrecision = 0; lf.lfQuality = 0; lf.lfPitchAndFamily = 0; TCHAR szLocaleData[BUFFER_SIZE]; int iRet = GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGCOUNTRY, szLocaleData, BUFFER_SIZE); if (strncmp(szLocaleData, "Japan", 5) != 0){ strcpy (lf.lfFaceName, szFaceName); } else { strcpy (lf.lfFaceName, TEXT("MS UI Gothic")); } hFont = CreateFontIndirect(&lf); RestoreDC (hdc, iSavedDC); return hFont; }
//+------------------------------------------------------------------------ // // Member: COffScreenContext::GetDC // // Synopsis: Get the DC and establish view parameters. // //------------------------------------------------------------------------- HDC COffScreenContext::GetDC(RECT* prc) { if(_fOffScreen) { _rc = *prc; _nSavedDC = SaveDC(_hdcMem); Assert(_nSavedDC); SetViewportOrgEx(_hdcMem, -_rc.left, -_rc.top, (POINT*)NULL); return _hdcMem; } return _hdcWnd; }
HDC wdStartGdi(WD_HCANVAS hCanvas, BOOL bKeepContents) { if(d2d_enabled()) { d2d_canvas_t* c = (d2d_canvas_t*) hCanvas; dummy_ID2D1GdiInteropRenderTarget* gdi_interop; dummy_D2D1_DC_INITIALIZE_MODE init_mode; HRESULT hr; HDC dc; hr = dummy_ID2D1RenderTarget_QueryInterface(c->target, &dummy_IID_ID2D1GdiInteropRenderTarget, (void**) &gdi_interop); if(FAILED(hr)) { WD_TRACE_HR("wdStartGdi: ID2D1RenderTarget::" "QueryInterface(IID_ID2D1GdiInteropRenderTarget) failed."); return NULL; } init_mode = (bKeepContents ? dummy_D2D1_DC_INITIALIZE_MODE_COPY : dummy_D2D1_DC_INITIALIZE_MODE_CLEAR); hr = dummy_ID2D1GdiInteropRenderTarget_GetDC(gdi_interop, init_mode, &dc); if(FAILED(hr)) { WD_TRACE_HR("wdStartGdi: ID2D1GdiInteropRenderTarget::GetDC() failed."); dummy_ID2D1GdiInteropRenderTarget_Release(gdi_interop); return NULL; } c->gdi_interop = gdi_interop; if(c->flags & D2D_CANVASFLAG_RTL) SetLayout(dc, LAYOUT_RTL); return dc; } else { gdix_canvas_t* c = (gdix_canvas_t*) hCanvas; int status; HDC dc; status = gdix_vtable->fn_GetDC(c->graphics, &dc); if(status != 0) { WD_TRACE_ERR_("wdStartGdi: GdipGetDC() failed.", status); return NULL; } SetLayout(dc, c->dc_layout); if(c->dc_layout & LAYOUT_RTL) SetViewportOrgEx(dc, c->x + c->cx - (c->width-1), -c->y, NULL); return dc; } }
/***************************************************************************** * Prepare the printer DC for output. This function uses the specified CPI * values to scale the DC, using MM_ANISOTROPIC mapping mode. *****************************************************************************/ static void PrepareDC( void ) { int lpxlX = GetDeviceCaps( pd.hDC, LOGPIXELSX ); int lpxlY = GetDeviceCaps( pd.hDC, LOGPIXELSY ); SetMapMode( pd.hDC, MM_ANISOTROPIC ); SetViewportExtEx( pd.hDC, lpxlX, lpxlY, NULL ); SetWindowExtEx( pd.hDC, LOWORD( dwCPI ), HIWORD( dwCPI ), NULL ); SetViewportOrgEx( pd.hDC, offsetx, offsety, NULL ); SetBkMode( pd.hDC, TRANSPARENT ); SetTextColor( pd.hDC, color ); }
void tFigure::vrash_cord(float tt,int xx,int yy) { XFORM xform; float angle=tt; angle = angle * 3.1416 / 180.0; xform.eDx = 0.0f; xform.eDy = 0.0f; xform.eM11 = cos(angle); xform.eM12 = sin(angle); xform.eM21 = -sin(angle); xform.eM22 = cos(angle); SetGraphicsMode(imj->Canvas->Handle, GM_ADVANCED); SetWorldTransform(imj->Canvas->Handle, &xform); SetViewportOrgEx(imj->Canvas->Handle,xx,yy,NULL); }
void AtlMapZoom(ATL_DRAWINFO& di) { // Quit if not zoomed if (!di.bZoomed) return; RECT& rc = *(RECT*)di.prcBounds; // Setup mapping mode... SetMapMode(di.hdcDraw, MM_ANISOTROPIC); SetViewportExtEx(di.hdcDraw, di.ZoomNum.cx, di.ZoomNum.cy, NULL); SetWindowExtEx(di.hdcDraw, di.ZoomDen.cx, di.ZoomDen.cy, NULL); SetWindowOrgEx(di.hdcDraw, rc.left, rc.top, NULL); SetViewportOrgEx(di.hdcDraw, rc.left, rc.top, NULL); // Scale bounds... rc.right=rc.left + (rc.right-rc.left) * di.ZoomDen.cx / di.ZoomNum.cx; rc.bottom=rc.top + (rc.bottom-rc.top) * di.ZoomDen.cy / di.ZoomNum.cy; }
DrawEngine::DrawEngine(HDC hdc, HWND hwnd, int pxPerBlock, int width, int height) : hdc(hdc), hwnd(hwnd), width(width), height(height) { GetClientRect(hwnd, &rect); SaveDC(hdc); // Set up coordinate system SetMapMode(hdc, MM_ISOTROPIC); SetViewportExtEx(hdc, pxPerBlock, pxPerBlock, 0); SetWindowExtEx(hdc, 1, -1, 0); SetViewportOrgEx(hdc, 0, rect.bottom, 0); // Set default colors SetTextColor(hdc, RGB(255,255,255)); SetBkColor(hdc, RGB(70,70,70)); SetBkMode(hdc, TRANSPARENT); }
void PaintClover(HWND hwnd,HRGN hRgnClip, int cxClient, int cyClient) { double fAngle, fRadius ; PAINTSTRUCT ps; HDC hdc = BeginPaint (hwnd, &ps) ; SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ; SelectClipRgn (hdc, hRgnClip) ; fRadius = _hypot (cxClient / 2.0, cyClient / 2.0) ; for (fAngle = 0.0 ; fAngle < TWOPI ; fAngle += TWOPI / 360) { MoveToEx (hdc, 0, 0, NULL) ; LineTo (hdc, (int) ( fRadius * cos (fAngle) + 0.5), (int) (-fRadius * sin (fAngle) + 0.5)) ; } EndPaint (hwnd, &ps) ; }
void CContainerWnd::PaintBuffer(HWND hwnd, HDC dc, int width, int height) { PaintBufferPre(hwnd, dc, width, height); POINT prevPoint = { 0, 0 }; int dcState = 0; for (auto comp : m_components) { if(RectVisible(dc, comp)) { dcState = SaveDC(dc); SetViewportOrgEx(dc, comp->left, comp->top, &prevPoint); comp->Paint(hwnd, dc); GdiFlush(); if(dcState)RestoreDC(dc, dcState); } } // SetViewportOrgEx(dc, 0, 0, &prevPoint); PaintBufferPost(hwnd, dc, width, height); }
bool CNoteDlg::PrintPage(UINT nPage, HDC hDC) { if (nPage >= (UINT)m_arrPages.GetSize()) return false; RECT rcPage; rcPage.left = rcPage.top = 0; rcPage.bottom = GetDeviceCaps(hDC, PHYSICALHEIGHT); rcPage.right = GetDeviceCaps(hDC, PHYSICALWIDTH); rcPage.right = MulDiv(rcPage.right, 1440, GetDeviceCaps(hDC, LOGPIXELSX)); rcPage.bottom = MulDiv(rcPage.bottom, 1440, GetDeviceCaps(hDC, LOGPIXELSY)); RECT rcOutput = rcPage; // Convert from 1/1000" to twips rcOutput.left += MulDiv(m_rcMargin.left, 1440, 1000); rcOutput.right -= MulDiv(m_rcMargin.right, 1440, 1000); rcOutput.top += MulDiv(m_rcMargin.top, 1440, 1000); rcOutput.bottom -= MulDiv(m_rcMargin.bottom, 1440, 1000); FORMATRANGE fr; fr.hdc = hDC; fr.hdcTarget = hDC; fr.rc = rcOutput; fr.rcPage = rcPage; fr.chrg.cpMin = 0; fr.chrg.cpMax = -1; fr.chrg.cpMin = m_arrPages[nPage]; // We have to adjust the origin because 0,0 is not at the corner of the paper // but is at the corner of the printable region int nOffsetX = GetDeviceCaps(hDC, PHYSICALOFFSETX); int nOffsetY = GetDeviceCaps(hDC, PHYSICALOFFSETY); SetViewportOrgEx(hDC, -nOffsetX, -nOffsetY, NULL); m_wndEdit.FormatRange(fr, TRUE); m_wndEdit.DisplayBand(&rcOutput); // Tell the control to release cached information m_wndEdit.FormatRange(NULL, FALSE); return true; }
void Fl_Gdi::set_page(int page) { DEVMODE * mode = (DEVMODE *) GlobalLock(mode_); if(page) { ResetDC(gc_,mode); SetMapMode(gc_, MM_ANISOTROPIC); SetTextAlign(gc_, TA_BASELINE|TA_LEFT); SetBkMode(gc_, TRANSPARENT); StartPage(gc_); ix = GetDeviceCaps(gc_, LOGPIXELSX); iy = GetDeviceCaps(gc_, LOGPIXELSY); ox = GetDeviceCaps(gc_, PHYSICALOFFSETX); oy = GetDeviceCaps(gc_, PHYSICALOFFSETY); } GlobalUnlock(mode_); SetViewportOrgEx(gc_,VOx = (int)(ix * lm_ /72 - ox), VOy =(int)( iy *tm_ /72 - oy),0); //setting origin to the upper left corner inside margins SetViewportExtEx(gc_, VEx = (int)(ix * pw_ / 72), (int)(VEy = iy * ph_ / 72),0); SetWindowExtEx(gc_, WEx = (int) pw_, WEy = (int)ph_,0); //72 pixels per inch mapping SetWindowOrgEx(gc_, WOx = 0, WOy = 0,0); }