src/hbcore/image/hbvgimageiconrenderer.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    52 }
    52 }
    53 
    53 
    54 void HbVgImageIconRenderer::applyIconProperties()
    54 void HbVgImageIconRenderer::applyIconProperties()
    55 {
    55 {
    56     if (!specialCaseApplied) {
    56     if (!specialCaseApplied) {
       
    57         VGImage tmpImage = vgImage;
       
    58         if (iconColor.isValid()) {
       
    59             tmpImage = vgCreateImage(VG_sARGB_8888_PRE,
       
    60                                      rendersize.width(), rendersize.height(),
       
    61                                      VG_IMAGE_QUALITY_NONANTIALIASED);
       
    62             VGfloat matrix[20] = {0, 0, 0, 0,
       
    63                                   0, 0, 0, 0,
       
    64                                   0, 0, 0, 0,
       
    65                                   0, 0, 0, 1,
       
    66                                   (VGfloat)iconColor.red() / 255.0, (VGfloat)iconColor.green() / 255.0, (VGfloat)iconColor.blue() / 255.0, 0
       
    67                                  };
       
    68             vgColorMatrix(tmpImage, vgImage, matrix);
       
    69         }
    57         if (iconMode == QIcon::Disabled) {
    70         if (iconMode == QIcon::Disabled) {
    58             VGImage modifiedVgImage = vgCreateImage((VGImageFormat)  VG_sARGB_8888_PRE,
    71             VGImage modifiedVgImage = vgCreateImage(VG_sARGB_8888_PRE,
    59                                                     rendersize.width(), rendersize.height(), VG_IMAGE_QUALITY_NONANTIALIASED);
    72                                                     rendersize.width(), rendersize.height(),
    60 
    73                                                     VG_IMAGE_QUALITY_NONANTIALIASED);
    61             VGImageFormat imageFormat =
       
    62                 (VGImageFormat)vgGetParameteri(vgImage, VG_IMAGE_FORMAT);
       
    63 
       
    64             VGfloat matrix[20] = {0.1700, 0.1700, 0.1700, 0,
    74             VGfloat matrix[20] = {0.1700, 0.1700, 0.1700, 0,
    65                                   0.5721, 0.5721, 0.5721, 0,
    75                                   0.5721, 0.5721, 0.5721, 0,
    66                                   0.0577, 0.0577, 0.0577, 0,
    76                                   0.0577, 0.0577, 0.0577, 0,
    67                                   0, 0, 0, 1,
    77                                   0, 0, 0, 1,
    68                                   0, 0, 0, 0
    78                                   0, 0, 0, 0
    69                                  };
    79                                  };
    70 
    80             vgColorMatrix(modifiedVgImage, tmpImage, matrix);
    71             vgColorMatrix(modifiedVgImage, vgImage, matrix);
    81             if (tmpImage != vgImage) {
       
    82                 vgDestroyImage(tmpImage);
       
    83             }
    72             vgDestroyImage(vgImage);
    84             vgDestroyImage(vgImage);
    73             vgImage = modifiedVgImage;
    85             vgImage = modifiedVgImage;
    74         }
    86         } else if (tmpImage != vgImage) {
    75 
       
    76         if (iconColor.isValid() && iconMode != QIcon::Disabled) {
       
    77             VGImage resultImage = vgCreateImage((VGImageFormat)  VG_sARGB_8888_PRE,
       
    78                                                 rendersize.width(), rendersize.height(), VG_IMAGE_QUALITY_NONANTIALIASED);
       
    79 
       
    80             VGfloat matrix[20] = {0, 0, 0, 0,
       
    81                                   0, 0, 0, 0,
       
    82                                   0, 0, 0, 0,
       
    83                                   0, 0, 0, 1,
       
    84                                   (VGfloat)iconColor.red() / 255.0, (VGfloat)iconColor.green() / 255.0, (VGfloat)iconColor.blue() / 255.0, 0
       
    85                                  };
       
    86             vgColorMatrix(resultImage, vgImage, matrix);
       
    87             vgDestroyImage(vgImage);
    87             vgDestroyImage(vgImage);
    88             vgImage = resultImage;
    88             vgImage = tmpImage;
    89         }
    89         }
    90         specialCaseApplied = true;
    90         specialCaseApplied = true;
    91     }
    91     }
    92 }
    92 }
    93 
    93