2011-08-09 23:31:46 +04:00
|
|
|
/*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Copyright 2011 Haiku, Inc. All rights reserved.
|
2011-08-09 23:31:46 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Authors:
|
|
|
|
* Adrien Destugues, pulkomandy@pulkomandy.ath.cx
|
|
|
|
*
|
2011-08-09 23:31:46 +04:00
|
|
|
* Corresponds to:
|
2013-02-07 06:05:00 +04:00
|
|
|
* headers/os/interface/IconUtils.h rev 42600
|
|
|
|
* src/kits/interface/IconUtils.cpp rev 42600
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
|
|
|
|
/*!
|
2011-08-10 01:57:31 +04:00
|
|
|
\file IconUtils.h
|
2013-02-07 06:05:00 +04:00
|
|
|
\ingroup interface
|
|
|
|
\ingroup libbe
|
2011-08-10 01:57:31 +04:00
|
|
|
\brief Vector icon handling utility class
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
/*!
|
|
|
|
\class BIconUtils
|
2011-08-09 23:31:46 +04:00
|
|
|
\ingroup interface
|
|
|
|
\ingroup libbe
|
|
|
|
\brief The BIconUtils class provide utility methods for managing and
|
|
|
|
drawing vector icons.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
Haiku icons are stored in the HVIF (Haiku Vector Icon Format). This format
|
|
|
|
was designed specifically for this purpose, and allows the icon data to be
|
|
|
|
small enough to fit in file's inodes. This way, the icon can be displayed
|
|
|
|
like any other file attribute, without extra disk access.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
This class provide only static methods to allow access to the icon data and
|
|
|
|
rendering to BBitmaps for later use in an application. It also supports
|
|
|
|
older icons in bitmap format. These may still be useful at very small
|
|
|
|
sizes. Note you can't create an instance of BIconUtils, just call the
|
|
|
|
static methods.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::GetIcon(BNode* node,
|
2011-08-09 23:31:46 +04:00
|
|
|
const char* vectorIconAttrName, const char* smallIconAttrName,
|
|
|
|
const char* largeIconAttrName, icon_size size, BBitmap* result)
|
|
|
|
\brief Utility function to import an icon from a node.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
Utility function to import an icon from the node that
|
|
|
|
has either of the provided attribute names. Which icon type
|
|
|
|
is preferred (vector, small or large B_CMAP8 icon) depends
|
|
|
|
on the colorspace of the provided bitmap.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
\note If the colorspace is B_CMAP8, B_CMAP8 icons are preferred. In that
|
|
|
|
case, the bitmap size must also match the provided icon_size "size"!
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::GetVectorIcon(BNode* node,
|
2011-08-09 23:31:46 +04:00
|
|
|
const char* attrName, BBitmap* result)
|
|
|
|
\brief Utility function to import a vector icon in "flat icon" format.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
Utility function to import a vector icon in "flat icon"
|
|
|
|
format from a BNode attribute into the preallocated BBitmap \a 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.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
\note 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).
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::GetVectorIcon(const uint8* buffer,
|
2011-08-09 23:39:10 +04:00
|
|
|
size_t size, BBitmap* result)
|
2011-08-09 23:31:46 +04:00
|
|
|
\brief Utility function to import a vector icon in "flat icon" format.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
Utility function to import a vector icon in "flat icon"
|
|
|
|
format from the given \a buffer into the preallocated BBitmap \a 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.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
\note 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).
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::GetCMAP8Icon(BNode* node,
|
2011-08-09 23:31:46 +04:00
|
|
|
const char* smallIconAttrName, const char* largeIconAttrName,
|
|
|
|
icon_size size, BBitmap* icon)
|
|
|
|
\brief Utility function to import an "old" BeOS icon in B_CMAP8 colorspace.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
Utility function to import an "old" BeOS icon in B_CMAP8 colorspace from
|
|
|
|
either the small icon attribute or the large icon attribute as given in
|
|
|
|
\a smallIconAttrName and \a largeIconAttrName. Which icon is loaded depends
|
|
|
|
on the given \a size.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::ConvertFromCMAP8(BBitmap* source,
|
|
|
|
BBitmap* result)
|
2011-08-09 23:31:46 +04:00
|
|
|
\brief Converts an old-style icon to another colorspace.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
Utility function to convert from old icon colorspace into colorspace of
|
|
|
|
BBitmap \a result
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
\note result should be in B_RGBA32 colorspace, and source in B_CMAP8.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::ConvertToCMAP8(BBitmap* source,
|
|
|
|
BBitmap* result)
|
2011-08-09 23:31:46 +04:00
|
|
|
\brief Converts a true-color icon to CMAP8 colorspace.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
Utility function to convert data from source into \a result colorspace.
|
|
|
|
Call this to convert a picture to a format suitable for storage as an
|
|
|
|
old-style icon.
|
2011-08-10 01:57:31 +04:00
|
|
|
|
2011-08-09 23:31:46 +04:00
|
|
|
\note result should be in B_CMAP8 colorspace, and source in B_RGBA32.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::ConvertFromCMAP8(const uint8* data,
|
|
|
|
uint32 width, uint32 height, uint32 bytesPerRow, BBitmap* result);
|
2011-08-09 23:31:46 +04:00
|
|
|
\brief Convert raw data in B_CMAP8 colorspace to a B_RGBA32 BBitmap.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|
|
|
|
|
2011-08-10 01:57:31 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\fn static status_t BIconUtils::ConvertToCMAP8(const uint8* data,
|
|
|
|
uint32 width, uint32 height, uint32 bytesPerRow, BBitmap* result);
|
2011-08-09 23:31:46 +04:00
|
|
|
\brief Convert B_RGBA32 raw data into a B_CMAP8 BBitmap.
|
2014-06-14 01:25:02 +04:00
|
|
|
|
|
|
|
\since Haiku R1
|
2011-08-09 23:31:46 +04:00
|
|
|
*/
|