Subversion Repositories tpanel

Rev

Rev 141 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 141 Rev 142
Line 3049... Line 3049...
3049
 
3049
 
3050
        SkPaint paint;
3050
        SkPaint paint;
3051
        paint.setBlendMode(SkBlendMode::kSrc);
3051
        paint.setBlendMode(SkBlendMode::kSrc);
3052
        can_bm.drawBitmap(image1, 0, 0, &paint);
3052
        can_bm.drawBitmap(image1, 0, 0, &paint);
3053
        paint.setBlendMode(SkBlendMode::kSrcATop);
3053
        paint.setBlendMode(SkBlendMode::kSrcATop);
-
 
3054
        can_bm.drawBitmap(img_bar, 0, 0, &paint);       // Draw the above created image over the 0% image
-
 
3055
    }
-
 
3056
    else if (sr[0].bm.empty() && !sr[1].bm.empty())     // Only one bitmap in the second instance
-
 
3057
    {
-
 
3058
        MSG_TRACE("Drawing second image " << sr[1].bm << " ...");
-
 
3059
        map<int, IMAGE_t>::iterator iterImages = mImages.find(sr[1].number);   // State when level = 100%
-
 
3060
        SkBitmap image = iterImages->second.imageBm;    // 100%
-
 
3061
        SkCanvas can_bm(*bm, SkSurfaceProps(1, kUnknown_SkPixelGeometry));
-
 
3062
 
-
 
3063
        if (image.empty())
-
 
3064
        {
-
 
3065
            MSG_ERROR("Error creating the image \"" << sr[1].bm << "\"!");
-
 
3066
            TError::setError();
-
 
3067
            return false;
-
 
3068
        }
-
 
3069
 
-
 
3070
        int width = sr[1].bm_width;
-
 
3071
        int height = sr[1].bm_height;
-
 
3072
        int startX = 0;
-
 
3073
        int startY = 0;
-
 
3074
 
-
 
3075
        // Calculation: width / <effective pixels> * level
-
 
3076
        // Calculation: height / <effective pixels> * level
-
 
3077
        if (dr.compare("horizontal") == 0)
-
 
3078
            width = (int)((double)width / ((double)rh - (double)rl) * (double)level);
-
 
3079
        else
-
 
3080
            height = (int)((double)height / ((double)rh - (double)rl) * (double)level);
-
 
3081
 
-
 
3082
        if (ri && dr.compare("horizontal") == 0)     // range inverted?
-
 
3083
        {
-
 
3084
            startX = sr[1].mi_width - width;
-
 
3085
            width = sr[1].mi_width;
-
 
3086
        }
-
 
3087
        else if (dr.compare("horizontal") != 0)
-
 
3088
        {
-
 
3089
            startY = sr[1].mi_height - height;
-
 
3090
            height = sr[1].mi_height;
-
 
3091
        }
-
 
3092
 
-
 
3093
        MSG_DEBUG("dr=" << dr << ", startX=" << startX << ", startY=" << startY << ", width=" << width << ", height=" << height << ", level=" << level);
-
 
3094
        MSG_TRACE("Creating bargraph ...");
-
 
3095
        SkBitmap img_bar;
-
 
3096
        img_bar.allocPixels(SkImageInfo::MakeN32Premul(sr[1].bm_width, sr[1].bm_height));
-
 
3097
        img_bar.eraseColor(SK_ColorTRANSPARENT);
-
 
3098
        SkCanvas bar(img_bar, SkSurfaceProps(1, kUnknown_SkPixelGeometry));
-
 
3099
        SkPaint pt;
-
 
3100
 
-
 
3101
        for (int ix = 0; ix < sr[1].bm_width; ix++)
-
 
3102
        {
-
 
3103
            for (int iy = 0; iy < sr[1].bm_height; iy++)
-
 
3104
            {
-
 
3105
                SkColor pixel;
-
 
3106
 
-
 
3107
                if (ix >= startX && ix < width && iy >= startY && iy < height)
-
 
3108
                    pixel = image.getColor(ix, iy);
-
 
3109
                else
-
 
3110
                    pixel = SK_ColorTRANSPARENT;
-
 
3111
 
-
 
3112
                pt.setColor(pixel);
-
 
3113
                bar.drawPoint(ix, iy, pt);
-
 
3114
            }
-
 
3115
        }
-
 
3116
 
-
 
3117
        SkPaint paint;
-
 
3118
        paint.setBlendMode(SkBlendMode::kSrcOver);
3054
        can_bm.drawBitmap(img_bar, 0, 0, &paint);      // Draw the above created image over the 0% image
3119
        can_bm.drawBitmap(img_bar, 0, 0, &paint);      // Draw the above created image over the 0% image
3055
    }
3120
    }
3056
    else
3121
    else
3057
    {
3122
    {
3058
        MSG_TRACE("No bitmap defined.");
3123
        MSG_TRACE("No bitmap defined.");