Re: Scaling of data into dc
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 13 May 2007 12:04:05 -0400
See below...
On Sun, 13 May 2007 12:18:03 +0200, Matthias Pospiech <matthiaspospiech@xxxxxxxx> wrote:
Joseph M. Newcomer schrieb:****
This is a completely wrong approach. Use SetViewportExt/SetWindowExt to accomplish this.I tried to implement the scaling with SetViewportExt/SetWindowExt.
Otherwise, you end up scaling the bitmap which gets really lousy representation for the
graphics.
That however worked only partly
- What is the difference between the two ?
One sets the specificaiton of the size of the viwport and one sets the specification of
the size the window. The ratio of the two provides the mapping between physical and
logical coordinates. RTM.
****
- I changed in CMemDC.h the lines*****
SetMapMode(pDC->GetMapMode());
SetWindowExt(pDC->GetWindowExt());
SetViewportExt(pDC->GetViewportExt());
to
SetMapMode(MM_ANISOTROPIC);
SetWindowExt(CSize(m_rect_dest.Width(), m_rect_dest.Height()));
SetViewportExt(CSize(m_rect_source.Width(), m_rect_source.Height()));
You have not specified what pDC is. Note that you would apply the mapping mode to EITHER
the MemDC or the actual DC, but not both, because then the two mapping modes compound each
other. If you feel the compulsion to use the intermediate memory DC, then you would apply
it there, although it appeared that the only reason you were doing this is so you could do
a StretchBlt, so unless there are other reasons, the need for the MemDC has evaporated.
You could also have used MM_ISOTROPIC unless you plan to allow aspect ratio distortions.
****
****
and changed from StrechBlt to BitBlt again, because I do not want to mix
two differend streching ways.
Yes, that's right. It is not clear you even need the extra MemDC and the BitBlt, unless
you have other reasons for doing this
*****
*****
The generated bitmap is now scaled, BUT
- only the size of the data (if smaller the the dc size) is
invalidated/shown, although the UpdatePlot invalidates the whole area:
This is probably caused by the apparent rescaling of the original DC. Scale only one.
*****
*****
which means that if the data has size 50x50 and the dc 100x100 then the
data is streched on the dc twice, but only the area 50x50 is shown.
void CGraphCtrl::UpdatePlot()
{
CRect rc;
GetClientRect(rc);
InvalidateRect(&rc);
Remove the three above lines. Replace with
Invalidate();
****
UpdateWindow();*****
}
Now my code has changed but the overall problem is still the same and I
have no idea how to proceed.
Scale only the one you are drawing into. The MemDC needs to have the same dimensions as
the target window.
joe
*****
Joseph M. Newcomer [MVP]
Matthias
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Scaling of data into dc
- From: Matthias Pospiech
- Re: Scaling of data into dc
- References:
- Scaling of data into dc
- From: Matthias Pospiech
- Re: Scaling of data into dc
- From: Joseph M . Newcomer
- Re: Scaling of data into dc
- From: Matthias Pospiech
- Scaling of data into dc
- Prev by Date: Re: Another issue in my MFC app
- Next by Date: Re: strange behaviour of CString
- Previous by thread: Re: Scaling of data into dc
- Next by thread: Re: Scaling of data into dc
- Index(es):
Relevant Pages
|