From 6b422a8c2240e7b0095be7de4d7e2bb846a30540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 5 Aug 2006 13:53:54 +0000 Subject: [PATCH] * added a little documentation to BIconUtils in the header git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18401 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/libs/icon/IconUtils.cpp | 7 ++++++- src/libs/icon/IconUtils.h | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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);