Subversion Repositories tpanel

Rev

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

Rev 404 Rev 424
Line 223... Line 223...
223
    SkBitmap imgB, imgBR, imgR, imgTR, imgT, imgTL, imgL, imgBL;
223
    SkBitmap imgB, imgBR, imgR, imgTR, imgT, imgTL, imgL, imgBL;
224
 
224
 
225
    if (!getBorderFragment(bd.b, bd.b_alpha, &imgB, color))
225
    if (!getBorderFragment(bd.b, bd.b_alpha, &imgB, color))
226
        return false;
226
        return false;
227
 
227
 
228
    MSG_DEBUG("Got images " << bd.b << " and " << bd.b_alpha << " with size " << imgB.info().width() << " x " << imgB.info().height());
228
    MSG_DEBUG("Got images \"" << bd.b << "\" and \"" << bd.b_alpha << "\" with size " << imgB.info().width() << " x " << imgB.info().height());
229
    if (!getBorderFragment(bd.br, bd.br_alpha, &imgBR, color))
229
    if (!getBorderFragment(bd.br, bd.br_alpha, &imgBR, color))
230
        return false;
230
        return false;
231
 
231
 
232
    MSG_DEBUG("Got images " << bd.br << " and " << bd.br_alpha << " with size " << imgBR.info().width() << " x " << imgBR.info().height());
232
    MSG_DEBUG("Got images \"" << bd.br << "\" and \"" << bd.br_alpha << "\" with size " << imgBR.info().width() << " x " << imgBR.info().height());
233
    if (!getBorderFragment(bd.r, bd.r_alpha, &imgR, color))
233
    if (!getBorderFragment(bd.r, bd.r_alpha, &imgR, color))
234
        return false;
234
        return false;
235
 
235
 
236
    MSG_DEBUG("Got images " << bd.r << " and " << bd.r_alpha << " with size " << imgR.info().width() << " x " << imgR.info().height());
236
    MSG_DEBUG("Got images \"" << bd.r << "\" and \"" << bd.r_alpha << "\" with size " << imgR.info().width() << " x " << imgR.info().height());
237
    if (!getBorderFragment(bd.tr, bd.tr_alpha, &imgTR, color))
237
    if (!getBorderFragment(bd.tr, bd.tr_alpha, &imgTR, color))
238
        return false;
238
        return false;
239
 
239
 
240
    MSG_DEBUG("Got images " << bd.tr << " and " << bd.tr_alpha << " with size " << imgTR.info().width() << " x " << imgTR.info().height());
240
    MSG_DEBUG("Got images \"" << bd.tr << "\" and \"" << bd.tr_alpha << "\" with size " << imgTR.info().width() << " x " << imgTR.info().height());
241
    if (getBorderFragment(bd.t, bd.t_alpha, &imgT, color))
241
    if (getBorderFragment(bd.t, bd.t_alpha, &imgT, color))
242
        return false;
242
        return false;
243
 
243
 
244
    MSG_DEBUG("Got images " << bd.t << " and " << bd.t_alpha << " with size " << imgT.info().width() << " x " << imgT.info().height());
244
    MSG_DEBUG("Got images \"" << bd.t << "\" and \"" << bd.t_alpha << "\" with size " << imgT.info().width() << " x " << imgT.info().height());
245
    if (!getBorderFragment(bd.tl, bd.tl_alpha, &imgTL, color))
245
    if (!getBorderFragment(bd.tl, bd.tl_alpha, &imgTL, color))
246
        return false;
246
        return false;
247
 
247
 
248
    MSG_DEBUG("Got images " << bd.tl << " and " << bd.tl_alpha << " with size " << imgTL.info().width() << " x " << imgTL.info().height());
248
    MSG_DEBUG("Got images \"" << bd.tl << "\" and \"" << bd.tl_alpha << "\" with size " << imgTL.info().width() << " x " << imgTL.info().height());
249
    if (!getBorderFragment(bd.l, bd.l_alpha, &imgL, color))
249
    if (!getBorderFragment(bd.l, bd.l_alpha, &imgL, color))
250
        return false;
250
        return false;
251
 
251
 
252
    MSG_DEBUG("Got images " << bd.l << " and " << bd.l_alpha << " with size " << imgL.info().width() << " x " << imgL.info().height());
252
    MSG_DEBUG("Got images \"" << bd.l << "\" and \"" << bd.l_alpha << "\" with size " << imgL.info().width() << " x " << imgL.info().height());
253
    if (!getBorderFragment(bd.bl, bd.bl_alpha, &imgBL, color))
253
    if (!getBorderFragment(bd.bl, bd.bl_alpha, &imgBL, color))
254
        return false;
254
        return false;
255
 
255
 
256
    MSG_DEBUG("Got images " << bd.bl << " and " << bd.bl_alpha << " with size " << imgBL.info().width() << " x " << imgBL.info().height());
256
    MSG_DEBUG("Got images \"" << bd.bl << "\" and \"" << bd.bl_alpha << "\" with size " << imgBL.info().width() << " x " << imgBL.info().height());
257
    MSG_DEBUG("Button image size: " << (imgTL.info().width() + imgT.info().width() + imgTR.info().width()) << " x " << (imgTL.info().height() + imgL.info().height() + imgBL.info().height()));
257
    MSG_DEBUG("Button image size: " << (imgTL.info().width() + imgT.info().width() + imgTR.info().width()) << " x " << (imgTL.info().height() + imgL.info().height() + imgBL.info().height()));
258
    MSG_DEBUG("Total size: " << pinfo.width << " x " << pinfo.height);
258
    MSG_DEBUG("Total size: " << pinfo.width << " x " << pinfo.height);
259
    stretchImageWidth(&imgB, pinfo.width - imgBL.info().width() - imgBR.info().width());
259
    stretchImageWidth(&imgB, pinfo.width - imgBL.info().width() - imgBR.info().width());
260
    stretchImageWidth(&imgT, pinfo.width - imgTL.info().width() - imgTR.info().width());
260
    stretchImageWidth(&imgT, pinfo.width - imgTL.info().width() - imgTR.info().width());
261
    stretchImageHeight(&imgL, pinfo.height - imgTL.info().height() - imgBL.info().height());
261
    stretchImageHeight(&imgL, pinfo.height - imgTL.info().height() - imgBL.info().height());
Line 1169... Line 1169...
1169
 
1169
 
1170
    // If the path ends with "alpha.png" then it is a mask image. This not what
1170
    // If the path ends with "alpha.png" then it is a mask image. This not what
1171
    // we want first unless this is the only image available.
1171
    // we want first unless this is the only image available.
1172
    if (!endsWith(path, "alpha.png") || pathAlpha.empty())
1172
    if (!endsWith(path, "alpha.png") || pathAlpha.empty())
1173
    {
1173
    {
1174
        if (retrieveImage(path, image))
1174
        if (!path.empty() && retrieveImage(path, image))
1175
        {
1175
        {
1176
            haveBaseImage = true;
1176
            haveBaseImage = true;
1177
            // Underly the pixels with the border color
1177
            // Underly the pixels with the border color
1178
            MSG_DEBUG("Path: " << path << ", pathAlpha: " << pathAlpha);
-
 
1179
            if (pathAlpha.empty() || !fs::exists(pathAlpha) || path == pathAlpha)
1178
            if (pathAlpha.empty() || !fs::exists(pathAlpha) || path == pathAlpha)
1180
            {
1179
            {
1181
                SkImageInfo info = image->info();
1180
                SkImageInfo info = image->info();
1182
                SkBitmap b;
1181
                SkBitmap b;
1183
                allocPixels(info.width(), info.height(), &b);
1182
                allocPixels(info.width(), info.height(), &b);
Line 1270... Line 1269...
1270
 
1269
 
1271
bool TPageInterface::retrieveImage(const string& path, SkBitmap* image)
1270
bool TPageInterface::retrieveImage(const string& path, SkBitmap* image)
1272
{
1271
{
1273
    DECL_TRACER("TPageInterface::retrieveImage(const string& path, SkBitmap* image)");
1272
    DECL_TRACER("TPageInterface::retrieveImage(const string& path, SkBitmap* image)");
1274
 
1273
 
-
 
1274
    if (path.empty() || !image)
-
 
1275
    {
-
 
1276
        MSG_WARNING("One or all of the parameters are invalid!");
-
 
1277
        return false;
-
 
1278
    }
-
 
1279
 
1275
    sk_sp<SkData> im;
1280
    sk_sp<SkData> im;
1276
 
1281
 
1277
    if (!(im = readImage(path)))
1282
    if (!(im = readImage(path)))
1278
        return false;
1283
        return false;
1279
 
1284