Exemple #1
0
void DlgMix::SetMix()
{
	pDocSrc = (CDemoDoc*) m_cbSrc.GetItemData(m_cbSrc.GetCurSel());
	pDocDst = (CDemoDoc*) m_cbDst.GetItemData(m_cbDst.GetCurSel());
	OpType = m_cbOpType.GetItemData(m_cbOpType.GetCurSel());

	if (pDocSrc==0 || pDocDst==0) return;

	CxImage* pImageSrc = pDocSrc->GetImage();
	CxImage* pImageDst = pDocDst->GetImage();

	SetThumbs(pImageSrc,pImageDst);

	CxImage tmp;
	tmp.Copy(m_imageDst);
	tmp.Mix(m_imageSrc,(CxImage::ImageOpType)OpType,(long)(m_xoffset*m_ratio),(long)(m_yoffset*m_ratio),m_mixalpha!=0);

	if (m_mixalpha!=0){
		RGBQUAD c={255,255,255,0};
		tmp.SetTransColor(c);
		tmp.AlphaStrip();
	}

	if (m_bitmap) DeleteObject(m_bitmap);
	m_bitmap = tmp.MakeBitmap(m_picture.GetDC()->m_hDC);
	m_picture.SetBitmap(m_bitmap);
}
Exemple #2
0
//////////////////////////////////////////////////////////////////////////////
// CDemoView drawing
void CDemoView::OnDraw(CDC* pDC)
{
	CDemoDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	BOOL bPrinting = pDC->IsPrinting();

	CMemDC* pMemDC = NULL;
	if (!bPrinting) pDC = pMemDC = new CMemDC(pDC);

	if (!bPrinting && m_brHatch.m_hObject){
		CRect rect;
		GetClientRect(&rect);
		rect.right  = max(rect.right , m_totalDev.cx);
		rect.bottom = max(rect.bottom, m_totalDev.cy);
		m_brHatch.UnrealizeObject();
		CPoint pt(0, 0);
		pDC->LPtoDP(&pt);
		pt = pDC->SetBrushOrg(pt.x % 8, pt.y % 8);
		CBrush* old = pDC->SelectObject(&m_brHatch);
		pDC->FillRect(&rect, &m_brHatch);
		pDC->SelectObject(old);
	}

	CxImage* ima = pDoc->GetImage(); 
	if (ima) {
		if (bPrinting) {
			// get size of printer page (in pixels)
			int cxPage = pDC->GetDeviceCaps(HORZRES);
			int cyPage = pDC->GetDeviceCaps(VERTRES);
			//int dcbpp = pDC->GetDeviceCaps(BITSPIXEL);
			//int dcnc = pDC->GetDeviceCaps(NUMCOLORS);
			//int dcp = pDC->GetDeviceCaps(PLANES);
			// get printer pixels per inch
			int cxInch = pDC->GetDeviceCaps(LOGPIXELSX);
			int cyInch = pDC->GetDeviceCaps(LOGPIXELSY);
			// Best Fit case: create a rectangle which preserves the aspect ratio
			int cx = ima->GetXDPI() ? (ima->GetWidth()*cxInch)/ima->GetXDPI():ima->GetWidth()*cxInch/96;
			int cy = ima->GetYDPI() ? (ima->GetHeight()*cyInch)/ima->GetYDPI():ima->GetHeight()*cyInch/96;
			// print it!
			/*HDC TmpDC=CreateCompatibleDC(pDC->GetSafeHdc());
			HBITMAP bm =::CreateCompatibleBitmap(pDC->GetSafeHdc(), cx, cy);
			HBITMAP oldbm = (HBITMAP)::SelectObject(TmpDC,bm);
			BitBlt(TmpDC,0,0,cx,cy,0,0,0,WHITENESS);
			ima->Draw(TmpDC,CRect(0,0,cx,cy));
			BitBlt(pDC->GetSafeHdc(),100,100,cx,cy,TmpDC,0,0,SRCCOPY);
			DeleteObject(SelectObject(TmpDC,oldbm));
			DeleteDC(TmpDC);*/
			CxImage tmp;
			tmp.Copy(*ima);
			RGBQUAD c={255,255,255,0};
			if (tmp.GetTransIndex()>=0) tmp.SetPaletteColor((BYTE)tmp.GetTransIndex(),c);
			tmp.SetTransColor(c);
			tmp.AlphaStrip();
			tmp.Stretch(pDC->GetSafeHdc(), CRect(100,100,cx,cy));
		} else {
			if (pDoc->GetStretchMode()) {
				CRect rect;
				GetClientRect(&rect);
				ima->Draw(pDC->GetSafeHdc(), rect,0,pDoc->GetSmoothMode()!=0);
			} else {
				float zoom=pDoc->GetZoomFactor();
				if (zoom==1)
					ima->Draw(pDC->GetSafeHdc());
				else
					ima->Draw(pDC->GetSafeHdc(),
						CRect(0,0,(int)(ima->GetWidth()*zoom),(int)(ima->GetHeight()*zoom)),
						0,pDoc->GetSmoothMode()!=0);
			}

			if ( m_tracker.m_rect.Width()>0 && m_tracker.m_rect.Height()>0 )
				m_tracker.Draw(pDC);
		}
	}

	delete pMemDC;
}
void CReportEntityPicture::Draw( CDC* dc, CRect rect )
/* ============================================================
	Function :		CReportEntityPicture::Draw
	Description :	Draws the object.
	Access :		Public

	Return :		void
	Parameters :	CDC* dc		-	"CDC" to draw to
					CRect rect	-	True (zoomed) rectangle to 
									draw to.
					
	Usage :			Called from "CDiagramEditor::DrawObjects".

   ============================================================*/
{
	if( m_bitmap )
	{
		if (dc->IsPrinting()) 
		{
			// get size of printer page (in pixels)
			int cxPage = dc->GetDeviceCaps(HORZRES);
			int cyPage = dc->GetDeviceCaps(VERTRES);
			//int dcbpp = pDC->GetDeviceCaps(BITSPIXEL);
			//int dcnc = pDC->GetDeviceCaps(NUMCOLORS);
			//int dcp = pDC->GetDeviceCaps(PLANES);
			// get printer pixels per inch
			int cxInch = dc->GetDeviceCaps(LOGPIXELSX);
			int cyInch = dc->GetDeviceCaps(LOGPIXELSY);
			// Best Fit case: create a rectangle which preserves the aspect ratio
			int cx=m_bitmap->GetXDPI()?(m_bitmap->GetWidth()*cxInch)/m_bitmap->GetXDPI():
							m_bitmap->GetWidth()*cxInch/96;
			int cy=m_bitmap->GetYDPI()?(m_bitmap->GetHeight()*cyInch)/m_bitmap->GetYDPI():
						    m_bitmap->GetHeight()*cyInch/96;

			cx = rect.Width();
			cy = rect.Height();

			// print it!
			/*HDC TmpDC=CreateCompatibleDC(pDC->GetSafeHdc());
			HBITMAP bm =::CreateCompatibleBitmap(pDC->GetSafeHdc(), cx, cy);
			HBITMAP oldbm = (HBITMAP)::SelectObject(TmpDC,bm);
			BitBlt(TmpDC,0,0,cx,cy,0,0,0,WHITENESS);
			ima->Draw(TmpDC,CRect(0,0,cx,cy));
			BitBlt(pDC->GetSafeHdc(),100,100,cx,cy,TmpDC,0,0,SRCCOPY);
			DeleteObject(SelectObject(TmpDC,oldbm));
			DeleteDC(TmpDC);*/
			CxImage tmp;
			tmp.Copy(*m_bitmap);
			RGBQUAD c={255,255,255,0};
			tmp.SetTransColor(c);
			tmp.AlphaStrip();
			tmp.Stretch(dc->GetSafeHdc(), CRect(rect.left,rect.top,rect.left+cx,rect.top+cy));
		}
		else
		{
			rect.InflateRect( -1, -1 );
			m_bitmap->Draw(dc->m_hDC,rect);
			//dc->PlayMetaFile()
			//m_bitmap->GetType()
		}
	}

	CPen pen;
	if( GetBorderStyle()!=0 )
	{
		const float* table = Drawer::GetColorByIndex(GetBorderColor());
		COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f));
		pen.CreatePen( PS_SOLID, GetBorderThickness(), clr );
		dc->SelectObject( &pen );

		if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_LEFT)
		{
			dc->MoveTo(rect.left,rect.bottom);
			dc->LineTo(rect.left,rect.top);
		}
		if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_RIGHT)
		{
			dc->MoveTo(rect.right,rect.bottom);
			dc->LineTo(rect.right,rect.top);
		}

		if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_TOP)
		{
			dc->MoveTo(rect.left,rect.top);
			dc->LineTo(rect.right,rect.top);
		}

		if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_BOTTOM)
		{
			dc->MoveTo(rect.left,rect.bottom);
			dc->LineTo(rect.right,rect.bottom);
		}
	}
	
	dc->SelectStockObject( BLACK_PEN );
	dc->SelectStockObject( WHITE_BRUSH );

}