SetUserScale internals

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
nkwinder
Experienced Solver
Experienced Solver
Posts: 70
Joined: Sun Nov 23, 2008 2:32 pm

SetUserScale internals

Post by nkwinder »

hello

i' ve used setUserScale for zooming in and out an image. I 've noticed that the result is what i need for zooming in (nearest neighbor interpolation), but for zoom out the image is really messed up. So my first solution to this problem was to use SetUserScale only for zoom in, and rescale the actual image (and reconvert to bitmap) when zooming out of the original scale.

The problem with this solution is that although zoom in is really fast, zoom out is slow (especially for large images) due to allocations and deallocations.

So i'm thinking of making my own setUserScale. The problem is that i can't figure out the exact way it works (having already looked the dc source).

Can anyone tell me where to look at, or any other solution?

thanks in advance!
Last edited by nkwinder on Tue Mar 10, 2009 12:10 am, edited 1 time in total.
computerquip
Experienced Solver
Experienced Solver
Posts: 72
Joined: Fri Feb 20, 2009 7:13 pm
Location: $(#wx)\src

Post by computerquip »

What class are you using?
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

What do you precisely mean by "messed up"? like all pixelated?

I don't have any easy answer, except things like using OpenGL or so.

One thing comes to my mind : games usually use mipmaps to provide nicer-looking downscaling. The image is pre-scaled down to 1/2, 1/4, etc. of its original with a high quality algorithm. Then, when there is a need to display the image smaller, the closest pre-scaled down image can be used, stretched quickly to the necessary size - avoiding allocation slowdowns. I'm not sure how applicable this is in wxWidgets so feel free to ignore :)
xin.songtao
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Apr 18, 2007 6:10 am
Location: Shanghai China

Post by xin.songtao »

the code in below is mine, hope for help you.

It works well for small images( like 8000*4000 ),can be drag easily,zoom in and zoom out quickly.

http://forums.wxwidgets.org/viewtopic.php?t=23426
sis
Earned a small fee
Earned a small fee
Posts: 21
Joined: Wed Mar 18, 2009 6:07 pm

solution for stained image under msw

Post by sis »

I had the same problem.
I received the solution
http://trac.wxwidgets.org/ticket/10675#comment:3
----
"troelsk… added:

Do you call dc.DrawBitmap somewhere here?

If so, try dropping in this line and see if it helps
::SetStretchBltMode((HDC)dc.GetHDC(), COLORONCOLOR);

(http://trac.wxwidgets.org/ticket/3400)"
----
And ::SetStretchBltMode((HDC)dc->GetHDC(),COLORONCOLOR);
did repair MyPrintOut::OnPrintPage as well.
Post Reply