wxImage::Scale - normal/high quality no difference Topic is solved

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
PhoenixPl
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Wed Feb 15, 2006 9:26 am

wxImage::Scale - normal/high quality no difference

Post by PhoenixPl »

Hello,

Using:
Windows XP sp2
wxWidgets 2.7.1 CVS from 11/10/2006

I have just noticed that wxWidgets 2.7.1 has new way to scale/resample images. I have tried to use both wxImage:Scale() with wxIMAGE_QUALITY_NORMAL and wxIMAGE_QUALITY_HIGH quality settings, but I don't see any difference between them.

I took an image of 768x576x32 and loaded it into 3 applications:
- api1 - loads and displays image with GdiPlus
- api2 - loads and displays image with wxImage normal quality
- api3 - loads and displays image with wxImage high quality

All images are "stretch" to 1024x768x32 image. I can see large quality difference between api1 and api2/3, but I don't see any difference between api2 and api3. Images seems to look identical. Any ideas why it is happening? Is wxIMAGE_QUALITY_HIGH really using bicubic resampling or is it work in progress?
vdell
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Re: wxImage::Scale - normal/high quality no difference

Post by vdell »

I personally dont use the CVS version but maybe you could check the code to see if there actually are any differences (i.e. maybe the new api is not yet completed or something)?
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Hi!
Here's the source of the latest image.cpp: http://cvs.wxwidgets.org/viewcvs.cgi/wx ... cvs-markup
Seems like it realy uses bicubic resampling when stretching images.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
PhoenixPl
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Wed Feb 15, 2006 9:26 am

Post by PhoenixPl »

upCASE wrote:Hi!
Here's the source of the latest image.cpp: http://cvs.wxwidgets.org/viewcvs.cgi/wx ... cvs-markup
Seems like it realy uses bicubic resampling when stretching images.
I already browsed source and I know about wxImage::ResampleBicubic, but it doesn't explain why there is no difference between normal and high quality (and there should be a difference).

Do you think that it has something to do with the VC? From source I can't see any ifdefs for VC/GCC only for this function so I assume that this is "universal" method. Maybe this has something to do with wxUSE_GRAPHICS_CONTEXT, but there is no real explanation for it in both manual or source (or I have miss something).

Code: Select all

// Enable the new wxGraphicsPath and wxGraphicsContext classes for an advanced
// 2D drawing API.  (Still somewhat experimental)
//
// Please note that on Windows you will need to link with gdiplus.lib (use
// USE_GDIPLUS=1 for makefile builds) and distribute gdiplus.dll with your
// application if you want it to be runnable on pre-XP systems.
//
// Default is 0
//
// Recommended setting: 1
#ifndef wxUSE_GRAPHICS_CONTEXT
PhoenixPl
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Wed Feb 15, 2006 9:26 am

Post by PhoenixPl »

It seams that there is a small difference between normal and bicubic scaling. Unfortunately quality doesn't change a lot but it's good enough for simple operations. Lets say that the problem is solved for now. :D
nusi
Knows some wx things
Knows some wx things
Posts: 30
Joined: Thu Aug 24, 2006 7:43 pm

Post by nusi »

The output of the current version of wxImage::ResampleBicubic differs from what was originaly to be used. Someone seems to have optimized a bit too much. When I use the original code of ResampleBicubic (http://sourceforge.net/tracker/index.ph ... tid=309863) the images look better than what I get when I use current wxImage::ResampleBicubic.
PhoenixPl
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Wed Feb 15, 2006 9:26 am

Post by PhoenixPl »

So any ideas what to do with it right now? Do you have a copy of old method?
nusi
Knows some wx things
Knows some wx things
Posts: 30
Joined: Thu Aug 24, 2006 7:43 pm

Post by nusi »

It depends on what you can do with your code. I have no proposal, if wxImage::Scale or wxImage::ResampleBicubic need to behave fine.
But if you can add a function like "wxImage MyResampleBicubic(const wxImage &img)", then just follow above link, download the patch, open it with your texteditor and extract ResampleBicubic. Compile and fix the errors. They're easy to fix. In most cases you just need to call img.GetWidth() or similar.
PhoenixPl
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Wed Feb 15, 2006 9:26 am

Post by PhoenixPl »

Thanks, I will try.
ztMAMOHT
In need of some credit
In need of some credit
Posts: 7
Joined: Wed Jul 14, 2010 12:15 pm
Location: Ukraine Zhitomir
Contact:

Post by ztMAMOHT »

Hi all.
I downloaded wxWidgets 2.9.1 then
./сonfigure
make
sudo make install
and Code::Blocks 10.05
Then opened my old project and compile it(but I checked the buildinfo version of wxWidgets was 2.9.1). I have tried everything from:
wxImageResizeQuality (
wxIMAGE_QUALITY_NEAREST,
wxIMAGE_QUALITY_BILINEAR,
wxIMAGE_QUALITY_BICUBIC,
wxIMAGE_QUALITY_NORMAL,
wxIMAGE_QUALITY_HIGH
)

The quality was still poor.
I read about the patches: image_scaling_cvs.patch and image_scaling_2.6.3.patch please tell me how to use them.
Or tell my other solution.
Post Reply