diff --git a/src/libs/icon/IconUtils.cpp b/src/libs/icon/IconUtils.cpp index 9382551593..192dc2cfff 100644 --- a/src/libs/icon/IconUtils.cpp +++ b/src/libs/icon/IconUtils.cpp @@ -96,7 +96,7 @@ BIconUtils::GetVectorIcon(const uint8* buffer, size_t size, renderer.Render(); // TODO: would be nice to get rid of this - // (B_RGBA32_PREMULTIPLIED or better yes, new blending_mode) + // (B_RGBA32_PREMULTIPLIED or better yet, new blending_mode) // NOTE: probably not necessary only because // transparent colors are "black" in all existing icons // lighter transparent colors should be too dark if @@ -106,6 +106,8 @@ BIconUtils::GetVectorIcon(const uint8* buffer, size_t size, return B_OK; } +// #pragma mark - + // ConvertFromCMAP8 status_t BIconUtils::ConvertFromCMAP8(BBitmap* source, BBitmap* result) @@ -117,6 +119,9 @@ BIconUtils::ConvertFromCMAP8(BBitmap* source, BBitmap* result) if (ret < B_OK) return ret; + if (source->ColorSpace() != B_CMAP8) + return B_BAD_VALUE; + uint8* src = (uint8*)source->Bits(); uint32 srcBPR = source->BytesPerRow(); uint32 width = source->Bounds().IntegerWidth() + 1; diff --git a/src/libs/icon/IconUtils.h b/src/libs/icon/IconUtils.h index d6981dd35c..032dd2c4c4 100644 --- a/src/libs/icon/IconUtils.h +++ b/src/libs/icon/IconUtils.h @@ -23,6 +23,15 @@ class BIconUtils { public: + // Utility functions to import a vector icon in "flat icon" + // format from a BNode attribute or from a flat buffer in + // memory into the preallocated BBitmap "result". + // The colorspace of result needs to be B_RGBA32 or at + // least B_RGB32 (though that makes less sense). The icon + // will be scaled from it's "native" size of 64x64 to the + // size of the bitmap, the scale is derived from the bitmap + // width, the bitmap should have square dimension, or the + // icon will be cut off at the bottom (or have room left). static status_t GetVectorIcon(BNode* node, const char* attrName, BBitmap* result); @@ -32,6 +41,9 @@ class BIconUtils { BBitmap* result); + // Utility functions to convert from old icon colorspace + // into colorspace of BBitmap "result" (should be B_RGBA32 + // to make any sense). static status_t ConvertFromCMAP8(BBitmap* source, BBitmap* result);