src/hbcore/image/hbvgimageiconrenderer.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
--- a/src/hbcore/image/hbvgimageiconrenderer.cpp	Tue Jul 06 14:36:53 2010 +0300
+++ b/src/hbcore/image/hbvgimageiconrenderer.cpp	Wed Aug 18 10:05:37 2010 +0300
@@ -54,38 +54,38 @@
 void HbVgImageIconRenderer::applyIconProperties()
 {
     if (!specialCaseApplied) {
+        VGImage tmpImage = vgImage;
+        if (iconColor.isValid()) {
+            tmpImage = vgCreateImage(VG_sARGB_8888_PRE,
+                                     rendersize.width(), rendersize.height(),
+                                     VG_IMAGE_QUALITY_NONANTIALIASED);
+            VGfloat matrix[20] = {0, 0, 0, 0,
+                                  0, 0, 0, 0,
+                                  0, 0, 0, 0,
+                                  0, 0, 0, 1,
+                                  (VGfloat)iconColor.red() / 255.0, (VGfloat)iconColor.green() / 255.0, (VGfloat)iconColor.blue() / 255.0, 0
+                                 };
+            vgColorMatrix(tmpImage, vgImage, matrix);
+        }
         if (iconMode == QIcon::Disabled) {
-            VGImage modifiedVgImage = vgCreateImage((VGImageFormat)  VG_sARGB_8888_PRE,
-                                                    rendersize.width(), rendersize.height(), VG_IMAGE_QUALITY_NONANTIALIASED);
-
-            VGImageFormat imageFormat =
-                (VGImageFormat)vgGetParameteri(vgImage, VG_IMAGE_FORMAT);
-
+            VGImage modifiedVgImage = vgCreateImage(VG_sARGB_8888_PRE,
+                                                    rendersize.width(), rendersize.height(),
+                                                    VG_IMAGE_QUALITY_NONANTIALIASED);
             VGfloat matrix[20] = {0.1700, 0.1700, 0.1700, 0,
                                   0.5721, 0.5721, 0.5721, 0,
                                   0.0577, 0.0577, 0.0577, 0,
                                   0, 0, 0, 1,
                                   0, 0, 0, 0
                                  };
-
-            vgColorMatrix(modifiedVgImage, vgImage, matrix);
+            vgColorMatrix(modifiedVgImage, tmpImage, matrix);
+            if (tmpImage != vgImage) {
+                vgDestroyImage(tmpImage);
+            }
             vgDestroyImage(vgImage);
             vgImage = modifiedVgImage;
-        }
-
-        if (iconColor.isValid() && iconMode != QIcon::Disabled) {
-            VGImage resultImage = vgCreateImage((VGImageFormat)  VG_sARGB_8888_PRE,
-                                                rendersize.width(), rendersize.height(), VG_IMAGE_QUALITY_NONANTIALIASED);
-
-            VGfloat matrix[20] = {0, 0, 0, 0,
-                                  0, 0, 0, 0,
-                                  0, 0, 0, 0,
-                                  0, 0, 0, 1,
-                                  (VGfloat)iconColor.red() / 255.0, (VGfloat)iconColor.green() / 255.0, (VGfloat)iconColor.blue() / 255.0, 0
-                                 };
-            vgColorMatrix(resultImage, vgImage, matrix);
+        } else if (tmpImage != vgImage) {
             vgDestroyImage(vgImage);
-            vgImage = resultImage;
+            vgImage = tmpImage;
         }
         specialCaseApplied = true;
     }