Subversion Repositories tpanel

Rev

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

Rev 184 Rev 365
Line 89... Line 89...
89
 
89
 
90
        SkCanvas ctx(img, SkSurfaceProps(1, kUnknown_SkPixelGeometry));
90
        SkCanvas ctx(img, SkSurfaceProps(1, kUnknown_SkPixelGeometry));
91
        SkImageInfo info = img.info();
91
        SkImageInfo info = img.info();
92
        SkPaint paint;
92
        SkPaint paint;
93
        paint.setBlendMode(SkBlendMode::kSrcOver);
93
        paint.setBlendMode(SkBlendMode::kSrcOver);
94
        sk_sp<SkImage> _image = SkImage::MakeFromBitmap(imgMask);
94
        sk_sp<SkImage> _image = SkImages::RasterFromBitmap(imgMask);
95
        ctx.drawImage(_image, 0, 0, SkSamplingOptions(), &paint);
95
        ctx.drawImage(_image, 0, 0, SkSamplingOptions(), &paint);
96
 
96
 
97
        Button::POSITION_t position = calcImagePosition(mSr[instance].mi_width, mSr[instance].mi_height, instance);
97
        Button::POSITION_t position = calcImagePosition(mSr[instance].mi_width, mSr[instance].mi_height, instance);
98
 
98
 
99
        if (!position.valid)
99
        if (!position.valid)
Line 106... Line 106...
106
        SkCanvas can(*bm, SkSurfaceProps(1, kUnknown_SkPixelGeometry));
106
        SkCanvas can(*bm, SkSurfaceProps(1, kUnknown_SkPixelGeometry));
107
        paint.setBlendMode(SkBlendMode::kSrc);
107
        paint.setBlendMode(SkBlendMode::kSrc);
108
 
108
 
109
        if (mSr[instance].sb == 0)
109
        if (mSr[instance].sb == 0)
110
        {
110
        {
111
            sk_sp<SkImage> _image = SkImage::MakeFromBitmap(img);
111
            sk_sp<SkImage> _image = SkImages::RasterFromBitmap(img);
112
            can.drawImage(_image, position.left, position.top, SkSamplingOptions(), &paint);
112
            can.drawImage(_image, position.left, position.top, SkSamplingOptions(), &paint);
113
        }
113
        }
114
        else    // Scale to fit
114
        else    // Scale to fit
115
        {
115
        {
116
            SkRect rect = SkRect::MakeXYWH(position.left, position.top, position.width, position.height);
116
            SkRect rect = SkRect::MakeXYWH(position.left, position.top, position.width, position.height);
117
            sk_sp<SkImage> im = SkImage::MakeFromBitmap(img);
117
            sk_sp<SkImage> im = SkImages::RasterFromBitmap(img);
118
            can.drawImageRect(im, rect, SkSamplingOptions(), &paint);
118
            can.drawImageRect(im, rect, SkSamplingOptions(), &paint);
119
        }
119
        }
120
    }
120
    }
121
    else if (!imageBm.empty() && !mSr[instance].bm.empty())
121
    else if (!imageBm.empty() && !mSr[instance].bm.empty())
122
    {
122
    {
Line 147... Line 147...
147
        if (mSr[instance].sb == 0)
147
        if (mSr[instance].sb == 0)
148
        {
148
        {
149
            if ((mSr[instance].jb == 0 && mSr[instance].bx >= 0 && mSr[instance].by >= 0) || mSr[instance].jb != 0)  // Draw the full image
149
            if ((mSr[instance].jb == 0 && mSr[instance].bx >= 0 && mSr[instance].by >= 0) || mSr[instance].jb != 0)  // Draw the full image
150
            {
150
            {
151
                MSG_DEBUG("Drawing full image ...");
151
                MSG_DEBUG("Drawing full image ...");
152
                sk_sp<SkImage> _image = SkImage::MakeFromBitmap(image);
152
                sk_sp<SkImage> _image = SkImages::RasterFromBitmap(image);
153
                can.drawImage(_image, position.left, position.top, SkSamplingOptions(), &paint);
153
                can.drawImage(_image, position.left, position.top, SkSamplingOptions(), &paint);
154
            }
154
            }
155
            else    // We need only a subset of the image
155
            else    // We need only a subset of the image
156
            {
156
            {
157
                MSG_DEBUG("Create a subset of an image ...");
157
                MSG_DEBUG("Create a subset of an image ...");
Line 169... Line 169...
169
 
169
 
170
                MSG_DEBUG("Rectangle of part: x: " << position.left << ", y: " << position.top << ", w: " << position.width << ", h: " << position.height);
170
                MSG_DEBUG("Rectangle of part: x: " << position.left << ", y: " << position.top << ", w: " << position.width << ", h: " << position.height);
171
                SkBitmap part;      // Bitmap receiving the wanted part from the whole image
171
                SkBitmap part;      // Bitmap receiving the wanted part from the whole image
172
                SkIRect irect = SkIRect::MakeXYWH(position.left, position.top, position.width, position.height);
172
                SkIRect irect = SkIRect::MakeXYWH(position.left, position.top, position.width, position.height);
173
                image.extractSubset(&part, irect);  // Extract the part of the image containg the pixels we want
173
                image.extractSubset(&part, irect);  // Extract the part of the image containg the pixels we want
174
                sk_sp<SkImage> _image = SkImage::MakeFromBitmap(part);
174
                sk_sp<SkImage> _image = SkImages::RasterFromBitmap(part);
175
                can.drawImage(_image, 0, 0, SkSamplingOptions(), &paint); // Draw the image
175
                can.drawImage(_image, 0, 0, SkSamplingOptions(), &paint); // Draw the image
176
            }
176
            }
177
        }
177
        }
178
        else    // Scale to fit
178
        else    // Scale to fit
179
        {
179
        {
180
            MSG_DEBUG("Scaling image to fit.");
180
            MSG_DEBUG("Scaling image to fit.");
181
            SkRect rect = SkRect::MakeXYWH(position.left, position.top, position.width, position.height);
181
            SkRect rect = SkRect::MakeXYWH(position.left, position.top, position.width, position.height);
182
            sk_sp<SkImage> im = SkImage::MakeFromBitmap(image);
182
            sk_sp<SkImage> im = SkImages::RasterFromBitmap(image);
183
            can.drawImageRect(im, rect, SkSamplingOptions(), &paint);
183
            can.drawImageRect(im, rect, SkSamplingOptions(), &paint);
184
        }
184
        }
185
    }
185
    }
186
    else if ((imageBm.empty() && !mSr[0].bm.empty()) || (imageMi.empty() && !mSr[0].mi.empty()))
186
    else if ((imageBm.empty() && !mSr[0].bm.empty()) || (imageMi.empty() && !mSr[0].mi.empty()))
187
    {
187
    {