Re: [wx-dev] [wx, Win32, 2.4.0] wxDC::SetUserScale with bitmaps under win32

4 views
Skip to first unread message

Dimitri

unread,
May 7, 2003, 10:13:52 AM5/7/03
to wx-...@lists.wxwindows.org
At 16:03 5/7/2003, Ben Elgin wrote:

>This mail is in reference to a wxWindows bug that I discovered to be
>already listed in SourceForge, as reference number [ 707380 ]. We have
>run into this big, and confirm the original poster's suspicion that it
>occurs under WinNT, Win2k, and WinXP.
>
>In brief, when wxDC::SetUserScale is used to zoom out a scene that has
>bitmaps, thus making the bitmaps smaller, oddly colored pixel-level
>artifacts appear. There are example files at SourceForge that match what
>we're seeing.
>
>My question for the dev list is, has there been any progress on this bug,
>or can anyone suggest useful work-arounds or other tips?

All I can say is that this is a 'problem' with the OS (This is also mentioned
in the comment that's in the bug at SF). It happens when stretching DIBs
IIRC. There's little wxWindows can do about it besides making an own
implementation (And that won't appear automagically).

Regards,
Dimitri

Wade Brainerd

unread,
May 7, 2003, 4:06:52 PM5/7/03
to wx-...@lists.wxwindows.org
Hi Ben,

I'm using SetUserScale in my project, and haven't seen the color
artifacts you're referring to. My only guess is that it might have
something to do with the MM_ANISOTROPIC in SetMapMode, but I haven't
looked into it at all.

Also, a recent patch of mine checked in to CVS head optimizes
wxImage::Scale quite a bit, you might try applying it to 2.4 from the
Patch Manager. One way around the SetUserScale issue would be to save
and restore the scale factor around the DrawBitmap call:

dc.GetUserScale( &ux, &uy );
dc.SetUserScale( 1.0, 1.0 );
wxImage ScaledImage = MyImage.Scale( MyImage.GetWidth()*ux,
MyImage.GetHeight()*uy );
dc.DrawBitmap( ScaledImage.ConvertToBitmap() );
dc.SetUserScake( ux, uy );

Wade


Ben Elgin wrote:

>
> This mail is in reference to a wxWindows bug that I discovered to be
> already listed in SourceForge, as reference number [ 707380 ]. We
> have run into this big, and confirm the original poster's suspicion
> that it occurs under WinNT, Win2k, and WinXP.
>
> In brief, when wxDC::SetUserScale is used to zoom out a scene that has
> bitmaps, thus making the bitmaps smaller, oddly colored pixel-level
> artifacts appear. There are example files at SourceForge that match
> what we're seeing.
>
> My question for the dev list is, has there been any progress on this
> bug, or can anyone suggest useful work-arounds or other tips?
>

> One solution we have already investigated is to use wxImage::Scale and
> a bunch of coordinate transforms to "roll our own" global zoom. This
> works in principle, but has several drawbacks - we lose several
> "freebies" that SetUserScale offers such as translation of mouse
> coordinates, and the scaling is much slower (taking a few seconds each
> time a new set of bitmaps need to be created). The latter problem
> could be solved by caching pre-zoomed bitmaps, but that becomes
> impractical at high zoom levels due to memory considerations.
>
> Thanks for any help that anyone can provide.
>
> Details of my primary development environment:
> WX: 2.4.0
> OS: WindowsNT4, sp5
> COMPILER: VC++ 6.0
>
>
>
> --
> // Ben Elgin el...@3rdtech.com www.cs.unc.edu/~elgin \\
> \\ 3rdTech Inc. Chapel Hill, NC 919-929-1903 //
> "listen: there's a hell of a good universe next door; let's go"
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-dev-un...@lists.wxwindows.org
> For additional commands, e-mail: wx-de...@lists.wxwindows.org
>


Ben Elgin

unread,
May 8, 2003, 10:01:04 AM5/8/03
to wx-...@lists.wxwindows.org
At 01:06 PM 05/07/03 -0700, you wrote:
>Hi Ben,
>I'm using SetUserScale in my project, and haven't seen the color artifacts
>you're referring to. My only guess is that it might have something to do
>with the MM_ANISOTROPIC in SetMapMode, but I haven't looked into it at all.

This sounds promising, but I'm puzzled because my manual shows that the
only valid arguments to wxDC::SetMapMode are wxMM_TWIPS, POINTS, METRIC,
LOMETRIC, and TEXT. In fact, those are all just measurement unit
standards, so ANISOTROPIC seems like a completely different sort of thing -
am I just looking in the wrong place?

Further confusing the situation is the fact that a global search of the
2.4.0 documentation in PDF turns up exactly one instance of "anisotropic",
where it explains the ::wxMakeMetafilePlaceable does the equivalent of
"SetMapMode(dc, MM_ANISOTROPIC)". So now I'm just confused. Who's map
mode should we be setting, and where?


>Also, a recent patch of mine checked in to CVS head optimizes
>wxImage::Scale quite a bit, you might try applying it to 2.4 from the
>Patch Manager. One way around the SetUserScale issue would be to save and
>restore the scale factor around the DrawBitmap call:
>dc.GetUserScale( &ux, &uy );
>dc.SetUserScale( 1.0, 1.0 );
>wxImage ScaledImage = MyImage.Scale( MyImage.GetWidth()*ux,
>MyImage.GetHeight()*uy );
>dc.DrawBitmap( ScaledImage.ConvertToBitmap() );
>dc.SetUserScake( ux, uy );
>
>Wade

Barring any easier solutions, that sounds pretty good, so I'll look into
your patch if nothing else comes through. Thanks!

Ben


>This mail is in reference to a wxWindows bug that I discovered to be
>already listed in SourceForge, as reference number [ 707380 ].

>>In brief, when wxDC::SetUserScale is used to zoom out a scene that has
>>bitmaps, thus making the bitmaps smaller, oddly colored pixel-level
>>artifacts appear.

>>My question for the dev list is, has there been any progress on this bug,
>>or can anyone suggest useful work-arounds or other tips?

>>[...]

Reply all
Reply to author
Forward
0 new messages