Ticket #9554: 0001-Allow-Tracker-to-load-image-resources-with-any-size.patch

File 0001-Allow-Tracker-to-load-image-resources-with-any-size.patch, 1.3 KB (added by jscipione, 8 years ago)

Allow Tracker to grab icons at any size, not just icon_size constants.

  • src/kits/tracker/Bitmaps.cpp

    From 68acb6b716cafbe9bb6f58d6a2b48443a76a50a7 Mon Sep 17 00:00:00 2001
    From: John Scipione <jscipione@gmail.com>
    Date: Thu, 21 Mar 2013 09:33:20 -0400
    Subject: [PATCH] Allow Tracker to load image resources with any size
    
    ---
     src/kits/tracker/Bitmaps.cpp |   11 ++++-------
     1 file changed, 4 insertions(+), 7 deletions(-)
    
    diff --git a/src/kits/tracker/Bitmaps.cpp b/src/kits/tracker/Bitmaps.cpp
    index a148342..6d3d99e 100644
    a b BImageResources::GetIconResource(int32 id, icon_size size,  
    153153        && BIconUtils::GetVectorIcon((uint8*)data, length, dest) == B_OK) {
    154154        return B_OK;
    155155    }
    156 #endif
    157 
    158     // fall back to R5 icon
     156#else
    159157    if (size != B_LARGE_ICON && size != B_MINI_ICON)
    160158        return B_ERROR;
     159#endif
    161160
     161    // fall back to R5 icon
    162162    length = 0;
    163163    data = LoadResource(size == B_LARGE_ICON ? 'ICON' : 'MICN', id, &length);
    164164
    165     if (data == NULL
    166         || length != (size_t)(size == B_LARGE_ICON ? 1024 : 256)) {
     165    if (data == NULL || length != (size_t)(size * size)) {
    167166        TRESPASS();
    168167        return B_ERROR;
    169168    }
    170169
    171 #ifdef __HAIKU__
    172170    if (dest->ColorSpace() != B_CMAP8) {
    173171        return BIconUtils::ConvertFromCMAP8((uint8*)data, size, size,
    174172            size, dest);
    175173    }
    176 #endif
    177174
    178175    dest->SetBits(data, (int32)length, 0, B_CMAP8);
    179176    return B_OK;