Click to See Complete Forum and Search --> : Scroll bitmap


jnf
June 1st, 1999, 03:19 AM
(VC++ 6, Win98)
I want to disply a Bitmap in CScrollView with Scale capability.
Following is my code.
Problem is:
When m_ScaleRatio=1,
ok;
When m_ScaleRatio>1,
with each scrolling,a thin white line appears between the
update rect and other area of the bitmap.

Can anyone tell me why this happens,and how to do right way?

class CMyView:public CScrollView
{
...
RGBQUAD* m_pbm;
BITMAPINFO* m_pbmInfo; //top-bottom bitmap
...
int m_ScaleRatio; //Scale ratio(=1,2,3,4...)
};

void CMyView::SetScaleratio(int ratio)
{
m_ScaleRatio=ratio;
SIZE size;
size.cx=m_pbmInfo->bmiHeader.biWidth;
size.cy=-(m_pbmInfo->bmiHeader.biHeight);
SetScrollSizes(MM_TEXT,CSize(size.cx*m_ScaleRatio,size.cy*m_ScaleRatio),
CSize(64*m_ScaleRatio,64*m_ScaleRatio),CSize(8*m_ScaleRatio,8*m_ScaleRatio));
Invalidate();
}

void CMyView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
CScrollView::OnPrepareDC(pDC, pInfo);
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(1,1);
pDC->SetViewportExt(m_ScaleRatio,m_ScaleRatio);
return;
}

void CMyView::OnDraw(CDC* pDC)
{
CRect rect;
int r=pDC->GetClipBox(&rect);
if(r!=ERROR&&r!=NULLREGION)
{
SIZE size;
size.cx=m_pbmInfo->bmiHeader.biWidth;
size.cy=-(m_pbmInfo->bmiHeader.biHeight);
::StretchDIBits(pDC->GetSafeHdc(),rect.left,rect.top,rect.Width(),rect.Height(),
rect.left,size.cy-rect.bottom,rect.Width(),rect.Height(),
(void*)m_pbm, m_pbmInfo,DIB_RGB_COLORS,SRCCOPY);
};
return;
}