123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- // ImageEx.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "ImageEx.h"
- // CImageEx
- CImageEx::CImageEx(IN const WCHAR* filename,IN BOOL useEmbeddedColorManagement/* = FALSE*/)
- :Image(filename,useEmbeddedColorManagement)
- {
- }
- CImageEx::CImageEx(IN IStream* stream,IN BOOL useEmbeddedColorManagement/* = FALSE*/)
- :Image(stream,useEmbeddedColorManagement)
- {
- }
- CImageEx::~CImageEx()
- {
- }
- //绘画图像
- bool CImageEx::DrawImage(CDC * pDC, INT nXPos, INT nYPos)
- {
- if(IsNull())
- return false;
- //创建屏幕
- ASSERT(pDC!=NULL);
- Graphics graphics(pDC->GetSafeHdc());
- //获取属性
- INT nImageWidth=this->GetWidth();
- INT nImageHeight=this->GetHeight();
- //构造位置
- RectF rcDrawRect;
- rcDrawRect.X=(REAL)nXPos;
- rcDrawRect.Y=(REAL)nYPos;
- rcDrawRect.Width=(REAL)nImageWidth;
- rcDrawRect.Height=(REAL)nImageHeight;
- //绘画图像
- graphics.DrawImage(this,rcDrawRect,0,0,(REAL)nImageWidth,(REAL)nImageHeight,UnitPixel);
- return true;
- }
- //绘画图像
- bool CImageEx::DrawImage( CDC * pDC, INT nXPos, INT nYPos, INT nDestWidth, INT nDestHeight )
- {
- if(IsNull())
- return false;
- //创建屏幕
- ASSERT(pDC!=NULL);
- Graphics graphics(pDC->GetSafeHdc());
- //构造位置
- RectF rcDrawRect;
- rcDrawRect.X=(REAL)nXPos;
- rcDrawRect.Y=(REAL)nYPos;
- rcDrawRect.Width=(REAL)nDestWidth;
- rcDrawRect.Height=(REAL)nDestHeight;
- //绘画图像
- graphics.DrawImage(this,rcDrawRect,0,0,(REAL)GetWidth(),(REAL)GetHeight(),UnitPixel);
- return true;
- }
- //绘画图像
- bool CImageEx::DrawImage( CDC * pDC, RECT &rc )
- {
- if(IsNull())
- return false;
- //创建屏幕
- ASSERT(pDC!=NULL);
- Graphics graphics(pDC->GetSafeHdc());
- //构造位置
- RectF rcDrawRect;
- rcDrawRect.X=(REAL)rc.left;
- rcDrawRect.Y=(REAL)rc.top;
- rcDrawRect.Width=(REAL)(rc.right-rc.left);
- rcDrawRect.Height=(REAL)(rc.bottom-rc.top);
- //绘画图像
- graphics.DrawImage(this,rcDrawRect,0,0,(REAL)GetWidth(),(REAL)GetHeight(),UnitPixel);
- return true;
- }
- //绘画图像
- bool CImageEx::DrawImage(CDC * pDC, INT nXDest, INT nYDest, INT nDestWidth, INT nDestHeight, INT nXScr, INT nYSrc)
- {
- if(IsNull())
- return false;
- //创建屏幕
- ASSERT(pDC!=NULL);
- Graphics graphics(pDC->GetSafeHdc());
- //构造位置
- RectF rcDrawRect;
- rcDrawRect.X=(REAL)nXDest;
- rcDrawRect.Y=(REAL)nYDest;
- rcDrawRect.Width=(REAL)nDestWidth;
- rcDrawRect.Height=(REAL)nDestHeight;
- //绘画图像
- graphics.DrawImage(this,rcDrawRect,(REAL)nXScr,(REAL)nYSrc,(REAL)nDestWidth,(REAL)nDestHeight,UnitPixel);
- return true;
- }
- //绘画图像
- bool CImageEx::DrawImage(CDC * pDC, INT nXDest, INT nYDest, INT nDestWidth, INT nDestHeight, INT nXScr, INT nYSrc, INT nSrcWidth, INT nSrcHeight)
- {
- if(IsNull())
- return false;
- //创建屏幕
- ASSERT(pDC!=NULL);
- Graphics graphics(pDC->GetSafeHdc());
- //构造位置
- RectF rcDrawRect;
- rcDrawRect.X=(REAL)nXDest;
- rcDrawRect.Y=(REAL)nYDest;
- rcDrawRect.Width=(REAL)nDestWidth;
- rcDrawRect.Height=(REAL)nDestHeight;
- //绘画图像
- graphics.DrawImage(this,rcDrawRect,(REAL)nXScr,(REAL)nYSrc,(REAL)nSrcWidth,(REAL)nSrcHeight,UnitPixel);
- return true;
- }
- // 是否为空图借
- BOOL CImageEx::IsNull()
- {
- return this->lastResult != Ok;
- }
|