Previously the code selected scale factors that resulted in an image
smaller or equal the desired size. Now the code select scale factors
that create an image equal or larger than the desired size.
---
 .../idirectfbimageprovider_jpeg.c                  |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/interfaces/IDirectFBImageProvider/idirectfbimageprovider_jpeg.c 
b/interfaces/IDirectFBImageProvider/idirectfbimageprovider_jpeg.c
index 5591387..bf04e12 100644
--- a/interfaces/IDirectFBImageProvider/idirectfbimageprovider_jpeg.c
+++ b/interfaces/IDirectFBImageProvider/idirectfbimageprovider_jpeg.c
@@ -463,16 +463,21 @@ IDirectFBImageProvider_JPEG_RenderTo( 
IDirectFBImageProvider *thiz,
           }
           else if (rect.x == 0 && rect.y == 0) {
 #if JPEG_LIB_VERSION >= 70
-               cinfo.scale_num = 16;
-               while (cinfo.scale_num > 1) {
+            /*  The supported scaling ratios in libjpeg 7 and 8
+             *  are N/8 with all N from 1 to 16.
+             */
+               cinfo.scale_num = 1;
+               jpeg_calc_output_dimensions (&cinfo);
+               while (cinfo.scale_num < 16
+                      && cinfo.output_width < rect.w
+                      && cinfo.output_height < rect.h) {
+                    ++cinfo.scale_num;
                     jpeg_calc_output_dimensions (&cinfo);
-                    if (cinfo.output_width <= rect.w
-                        || cinfo.output_height <= rect.h)
-                         break;
-                    --cinfo.scale_num;
                }
-               jpeg_calc_output_dimensions (&cinfo);
 #else
+               /*  The supported scaling ratios in libjpeg 6
+                *  are 1/1, 1/2, 1/4, and 1/8
+                */
                while (cinfo.scale_denom < 8
                       && ((cinfo.output_width >> 1) >= rect.w)
                       && ((cinfo.output_height >> 1) >= rect.h)) {
-- 
1.7.1

_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to