void CFMView::OnDraw(CDC* pDC) { CFMDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // Get the pointer to the CFMImage object CFMImage * pImage = pDoc->GetImage(); if (pImage == NULL) return; // Get the client area CRect ClientRect; GetClientRect(&ClientRect); // Get the size of the image CSize sizeImage; sizeImage.cx = pImage->GetWidth(); sizeImage.cy = pImage->GetHeight(); // FIT SCREEN if (m_iViewSize == FIT_SCREEN) { // Compute the ratio between widths and the ratio between the heights and pick the smallest one: float ratio = min ((float) ClientRect.right / sizeImage.cx, (float) ClientRect.bottom / sizeImage.cy); // Compute the necessary size of the image: CSize sizeDrawingImage; sizeDrawingImage.cx = (LONG) (sizeImage.cx * ratio); sizeDrawingImage.cy = (LONG) (sizeImage.cy * ratio); // The rect for drawing: CRect rectDrawing(CPoint(0,0), sizeDrawingImage); // Center the rect: rectDrawing.OffsetRect((ClientRect.right - sizeDrawingImage.cx) / 2, (ClientRect.bottom - sizeDrawingImage.cy) / 2); // Draw the image: pImage->StretchBlt(pDC->m_hDC, rectDrawing.left, rectDrawing.top, rectDrawing.Width(), rectDrawing.Height(), SRCCOPY); } else if (m_iViewSize == FULL_IMAGE) { pImage->StretchBlt(pDC->m_hDC, 0, 0, sizeImage.cx, sizeImage.cy, SRCCOPY); SetScrollSizes(MM_TEXT, sizeImage); } }
//-------------------------------------------------------------- void ofApp::draw(){ ofColor _sC = ofColor(230, 255); ofColor _eC = ofColor(40, 255); ofBackgroundGradient( _sC, _eC ); lighting.enable(); cam.begin(); lineMovingPlateDrawing(200, true); pixelDrawing(150); rectDrawing(100); boxDrawing(0); baseDrawing(-50); cam.end(); }