* when a vector icon was present, BAppFileInfo::GetIcon() would return an
error if the provided bitmap was B_CMAP8, now BIconUtils will convert the icon to B_CMAP8 -> this behaviour is a little inconsistent compared to what happens when reading icons from attributes, there, the CMAP8 icon is prefered in case such a bitmap is passed, even if a vector icon exists. I am not really sure which behaviour is better. For a consistent UI, maybe it is better to prefer the vector icon always. I've added a note to BAppFileInfo. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22414 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e5b464d09f
commit
2a74c55308
@ -831,6 +831,13 @@ BAppFileInfo::GetIconForType(const char* type, BBitmap* icon,
|
||||
if (!icon || icon->InitCheck() != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// TODO: for consistency with attribute based icon reading, we
|
||||
// could also prefer B_CMAP8 icons here if the provided bitmap
|
||||
// is in that format. Right now, an existing B_CMAP8 icon resource
|
||||
// would be ignored as soon as a vector icon is present. On the other
|
||||
// hand, maybe this still results in a more consistent user interface,
|
||||
// since Tracker/Deskbar would surely show the vector icon.
|
||||
|
||||
// try vector icon first
|
||||
BString vectorAttributeName(kIconAttribute);
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <Node.h>
|
||||
#include <TypeConstants.h>
|
||||
|
||||
#include "AutoDeleter.h"
|
||||
#include "Icon.h"
|
||||
#include "IconRenderer.h"
|
||||
#include "FlatIconImporter.h"
|
||||
@ -165,8 +166,16 @@ BIconUtils::GetVectorIcon(const uint8* buffer, size_t size,
|
||||
if (ret < B_OK)
|
||||
return ret;
|
||||
|
||||
if (result->ColorSpace() != B_RGBA32 && result->ColorSpace() != B_RGB32)
|
||||
return B_BAD_VALUE;
|
||||
BBitmap* temp = result;
|
||||
ObjectDeleter<BBitmap> deleter;
|
||||
|
||||
if (result->ColorSpace() != B_RGBA32 && result->ColorSpace() != B_RGB32) {
|
||||
temp = new (nothrow) BBitmap(result->Bounds(),
|
||||
B_BITMAP_NO_SERVER_LINK, B_RGBA32);
|
||||
deleter.SetTo(temp);
|
||||
if (!temp || temp->InitCheck() != B_OK)
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
Icon icon;
|
||||
ret = icon.InitCheck();
|
||||
@ -178,11 +187,19 @@ BIconUtils::GetVectorIcon(const uint8* buffer, size_t size,
|
||||
if (ret < B_OK)
|
||||
return ret;
|
||||
|
||||
IconRenderer renderer(result);
|
||||
IconRenderer renderer(temp);
|
||||
renderer.SetIcon(&icon);
|
||||
renderer.SetScale((result->Bounds().Width() + 1.0) / 64.0);
|
||||
renderer.SetScale((temp->Bounds().Width() + 1.0) / 64.0);
|
||||
renderer.Render();
|
||||
|
||||
if (temp != result) {
|
||||
uint8* src = (uint8*)temp->Bits();
|
||||
uint32 width = temp->Bounds().IntegerWidth() + 1;
|
||||
uint32 height = temp->Bounds().IntegerHeight() + 1;
|
||||
uint32 srcBPR = temp->BytesPerRow();
|
||||
ret = ConvertToCMAP8(src, width, height, srcBPR, result);
|
||||
}
|
||||
|
||||
// TODO: would be nice to get rid of this
|
||||
// (B_RGBA32_PREMULTIPLIED or better yet, new blending_mode)
|
||||
// NOTE: probably not necessary only because
|
||||
@ -191,7 +208,7 @@ BIconUtils::GetVectorIcon(const uint8* buffer, size_t size,
|
||||
// app_server uses correct blending
|
||||
// renderer.Demultiply();
|
||||
|
||||
return B_OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
// #pragma mark -
|
||||
@ -465,6 +482,9 @@ BIconUtils::ConvertToCMAP8(const uint8* src,
|
||||
if (ret < B_OK)
|
||||
return ret;
|
||||
|
||||
if (result->ColorSpace() != B_CMAP8)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
uint32 dstWidth = result->Bounds().IntegerWidth() + 1;
|
||||
uint32 dstHeight = result->Bounds().IntegerHeight() + 1;
|
||||
|
||||
@ -483,13 +503,12 @@ memset(result->Bits(), 255, result->BitsLength());
|
||||
//
|
||||
//#else
|
||||
|
||||
if (result->ColorSpace() != B_CMAP8)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
uint8* dst = (uint8*)result->Bits();
|
||||
uint32 dstBPR = result->BytesPerRow();
|
||||
|
||||
const color_map* colorMap = system_colors();
|
||||
if (!colorMap)
|
||||
return B_NO_INIT;
|
||||
uint16 index;
|
||||
|
||||
for (uint32 y = 0; y < height; y++) {
|
||||
|
Loading…
Reference in New Issue
Block a user