我最近一直在做有关直流打印的问题。 当然,需要依靠名为StretchBlt的API。 因为画面像素和打印机的像素比率不同。 但是,到现在还没有结束。 但是我找到了写关于StretchBlt的资料。 和大家分享。
移动MOUSE放大显示图像的不同部位,2 .左键单击提高放大倍率,3 .右键单击降低放大倍率。 放大倍率大时会发生抖动。
---实现过程:
----1 .使用appwizard生成SDI APP图像。
----2 .将以下成员数据添加到cimage view中:
CSize m_sizeDest;
CSize m_sizeSource;
CBitmap * m_pBitmap;
CDC * m_pdcMem;
int oldx,oldy,s,d; file://s确定扩大的区域,
d决定放大显示区域,放大倍率=d/s
布尔恢复器;
龙马纳;
---- 3.将喜欢的位图添加到资源中,使其成为IDB_BITMAP1。
----4.cimageview的以下消息编程:
CImageView:CImageView () )。
{
//初始化值
m_pdcMem=new CDC;
m_pBitmap=new CBitmap;
恢复器=true;
s=30; d=45;
mana=src复制;
}
CImageView:~CImageView () ) )。
{
delete m_pdcMem;
delete m_pBitmap;
}
是voidcimageview :3360 ondraw (CDC * PDC )
{
静态布尔加载;
if (! 加载) {
位图Bm;
里德=! 加载;
m _ pbitmap-load bitmap (IDB _ bitmap 1;
m _ PDC mem-createcompatibledc (PDC;
m _ PDC mem-select object (m _ pbitmap;
m_pbitmap-getobject(sizeof )、bm );
m_sizeSource.cx=bm.bmWidth;
m_sizeSource.cy=bm.bmHeight;
m_sizeDest=m_sizeSource;
PDC-stretchblt (0,0,m_sizeSource.cx,m_sizeSource.cy,
m_pdcMem,0,0,m_sizeSource.cx,m_sizeSource.cy,mana;
}
else {
PDC-stretchblt (0,0,m_sizeSource.cx,m_sizeSource.cy,
m_pdcMem,0,0,m_sizeSource.cx,m_sizeSource.cy,mana;
}
}
voidcimageview :3360 onmousemove (uint n flags,CPoint point () ) ) ) ) ) ) ) )。
{
字符串代码;
int dd;
CRect srect,drect,mrect;
cmainframe*pframe=(cmainframe* ) afxgetapp(-m_pmainwnd;
ctatusbar * p status=p frame-m _ wnd status bar;
if(pstatus ) ) )。
{
Cord.format(x=%d,Y=%d ),point.x,point.y );
pstatus-setpanetext(1,cord );
srect.left=point.x - s;
srect.top=point.y - s;
srect.right=point.x s;
srect.bottom=point.y s;
drect.left=point.x - d;
drect.top=point.y - d;
drect.right=point.x d;
drect.bottom=point.y d;
mrect.left=oldx - d;
mrect.top=oldy - d;
mrect.right=oldx d;
mrect.bottom=oldy d;
dd=2*d;
CDC * pDC=GetDC (;
开放阵列(PDC;
if (recover )
{
PDC-bitblt(mrect.left,mrect.top,dd,dd,
m_pdcMem,mrect.left,mrect.top,mana;
}
PDC-stretchblt(drect.left,drect.top,
drect.Width (,drect.Height )、m_pdcMem、srect.left,
srect.top,srect.Width (,srect.Height ),SRCCOPY );
oldx=point.x; oldy=point.y;
发行版(PDC;
}
恢复器=true;
cview :3360 onmousemove (n flags,point );
}
voidcimageview :3360 onrbuttondown (uint n flags,CPoint point () ) ) ) ) ) ) ) )。
{
if(d5 )。
{
CDC * pDC=GetDC (;
PDC-stretchblt(oldx-d,oldy - d,2*d,
2*d,m_pdcMem,oldx - d,oldy - d,2*d,2*d,mana;
d -=10;
发行版(PDC;
cimage view :3360 onmousemove (n flags,point );
}
cview :3360 onrbuttondown (n flags,point );
}
voidcimageview :3360 onlbuttondown (uint n flags,CPoint point () ) ) ) ) ) ) ) )。
{
if(d150 ) )。
{
d =10;
cimage view :3360 onmousemove (n flags,point );
}
cview :3360 onlbuttondown (n flags,point );
}