1/* 2 * Copyright 2011, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Documentation by: 6 * Adrien Destugues <pulkomandy@pulkomandy.ath.cx> 7 * Corresponds to: 8 * /trunk/headers/os/interface/IconUtils.h rev 42600 9 * /trunk/src/kits/interface/IconUtils.cpp rev 42600 10 */ 11 12 13/*! 14 \file IconUtils.h 15 \brief Vector icon handling utility class 16*/ 17 18 19/*! 20 \class BIconUtils 21 \ingroup interface 22 \ingroup libbe 23 \brief The BIconUtils class provide utility methods for managing and 24 drawing vector icons. 25 26 Haiku icons are stored in the HVIF (Haiku Vector Icon Format). This format 27 was designed specifically for this purpose, and allows the icon data to be 28 small enough to fit in file's inodes. This way, the icon can be displayed 29 like any other file attribute, without extra disk access. 30 31 This class provide only static methods to allow access to the icon data and 32 rendering to BBitmaps for later use in an application. It also supports 33 older icons in bitmap format. These may still be useful at very small 34 sizes. Note you can't create an instance of BIconUtils, just call the 35 static methods. 36*/ 37 38 39/*! 40 \fn static status_t BIconUtils::GetIcon(BNode* node, 41 const char* vectorIconAttrName, const char* smallIconAttrName, 42 const char* largeIconAttrName, icon_size size, BBitmap* result) 43 \brief Utility function to import an icon from a node. 44 45 Utility function to import an icon from the node that 46 has either of the provided attribute names. Which icon type 47 is preferred (vector, small or large B_CMAP8 icon) depends 48 on the colorspace of the provided bitmap. 49 50 \note If the colorspace is B_CMAP8, B_CMAP8 icons are preferred. In that 51 case, the bitmap size must also match the provided icon_size "size"! 52*/ 53 54 55/*! 56 \fn static status_t BIconUtils::GetVectorIcon(BNode* node, 57 const char* attrName, BBitmap* result) 58 \brief Utility function to import a vector icon in "flat icon" format. 59 60 Utility function to import a vector icon in "flat icon" 61 format from a BNode attribute into the preallocated BBitmap \a result. 62 The colorspace of result needs to be B_RGBA32 or at 63 least B_RGB32 (though that makes less sense). The icon 64 will be scaled from it's "native" size of 64x64 to the 65 size of the bitmap. 66 67 \note The scale is derived from the bitmap width, the bitmap should have 68 square dimension, or the icon will be cut off at the bottom (or have 69 room left). 70*/ 71 72 73/*! 74 \fn static status_t BIconUtils::GetVectorIcon(const uint8* buffer, 75 size_t size, BBitmap* result) 76 \brief Utility function to import a vector icon in "flat icon" format. 77 78 Utility function to import a vector icon in "flat icon" 79 format from the given \a buffer into the preallocated BBitmap \a result. 80 The colorspace of result needs to be B_RGBA32 or at 81 least B_RGB32 (though that makes less sense). The icon 82 will be scaled from it's "native" size of 64x64 to the 83 size of the bitmap. 84 85 \note The scale is derived from the bitmap width, the bitmap should have 86 square dimension, or the icon will be cut off at the bottom (or have 87 room left). 88*/ 89 90 91/*! 92 \fn static status_t BIconUtils::GetCMAP8Icon(BNode* node, 93 const char* smallIconAttrName, const char* largeIconAttrName, 94 icon_size size, BBitmap* icon) 95 \brief Utility function to import an "old" BeOS icon in B_CMAP8 colorspace. 96 97 Utility function to import an "old" BeOS icon in B_CMAP8 colorspace from 98 either the small icon attribute or the large icon attribute as given in 99 \a smallIconAttrName and \a largeIconAttrName. Which icon is loaded depends 100 on the given \a size. 101*/ 102 103 104/*! 105 \fn static status_t BIconUtils::ConvertFromCMAP8(BBitmap* source, 106 BBitmap* result) 107 \brief Converts an old-style icon to another colorspace. 108 109 Utility function to convert from old icon colorspace into colorspace of 110 BBitmap \a result 111 112 \note result should be in B_RGBA32 colorspace, and source in B_CMAP8. 113*/ 114 115 116/*! 117 \fn static status_t BIconUtils::ConvertToCMAP8(BBitmap* source, 118 BBitmap* result) 119 \brief Converts a true-color icon to CMAP8 colorspace. 120 121 Utility function to convert data from source into \a result colorspace. 122 Call this to convert a picture to a format suitable for storage as an 123 old-style icon. 124 125 \note result should be in B_CMAP8 colorspace, and source in B_RGBA32. 126*/ 127 128 129/*! 130 \fn static status_t BIconUtils::ConvertFromCMAP8(const uint8* data, 131 uint32 width, uint32 height, uint32 bytesPerRow, BBitmap* result); 132 \brief Convert raw data in B_CMAP8 colorspace to a B_RGBA32 BBitmap. 133*/ 134 135 136/*! 137 \fn static status_t BIconUtils::ConvertToCMAP8(const uint8* data, 138 uint32 width, uint32 height, uint32 bytesPerRow, BBitmap* result); 139 \brief Convert B_RGBA32 raw data into a B_CMAP8 BBitmap. 140*/ 141