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!
SetUserScale internals
SetUserScale internals
Last edited by nkwinder on Tue Mar 10, 2009 12:10 am, edited 1 time in total.
-
- Experienced Solver
- Posts: 72
- Joined: Fri Feb 20, 2009 7:13 pm
- Location: $(#wx)\src
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
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
-
- Experienced Solver
- Posts: 86
- Joined: Wed Apr 18, 2007 6:10 am
- Location: Shanghai China
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
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
solution for stained image under msw
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.
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.