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