Hello.
The following patch to the image sample shows a different method for downscaling images, that provides a higher quality image than "high quality" scaling.
Regards,
Peer
improved high quality image downscaling
-
- Knows some wx things
- Posts: 43
- Joined: Tue Jun 13, 2006 7:21 am
- Location: Denmark
- Contact:
improved high quality image downscaling
- Attachments
-
- image-sample-patch.txt
- Unified diff against image sample
- (10.24 KiB) Downloaded 201 times
-
- Knows some wx things
- Posts: 43
- Joined: Tue Jun 13, 2006 7:21 am
- Location: Denmark
- Contact:
The algorithm only works for downscaling. It is slower than wxIMAGE_QUALITY_HIGH, since it uses float math. (wxIMAGE_QUALITY_HIGH is blur + sample which is integer math only)
The process is simple: For each target pixel, compute the average colour of the corresponding area on the source image. Note that this may include fractions of pixels.
Example:
Source image:
With target pixel area overlayed:
thus the two rightmost pixels of the source image contribute more than the two leftmost pixels.
Please note that the code has not been optimized so it may be possible to reorganise to get more speed, but it will always be slower than wxIMAGE_QUALITY_HIGH.
The process is simple: For each target pixel, compute the average colour of the corresponding area on the source image. Note that this may include fractions of pixels.
Example:
Source image:
Code: Select all
+---+---+
| | |
+---+---+
| | |
+---+---+
Code: Select all
+---+---+
| TTTT |
+--TTTT-+
| TTTT |
+---+---+
Please note that the code has not been optimized so it may be possible to reorganise to get more speed, but it will always be slower than wxIMAGE_QUALITY_HIGH.