[haiku-development] Re: libicon

  • From: "Stephan Assmus" <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 13 Sep 2008 13:43:59 +0200

> Hi,
> I would like to port IM Kit to HVIF icons but I saw that libicon is only 
> available as a static library.
> Will it be included in the Haiku images as a shared object in the 
> (hopefully near) future?

libicon is linked into libbe.so, so in principle, it's API is available. All 
you need is BIconUtils. Through BIconUtils, you can render vector icon data. In 
your application, you don't need to keep instantiated BPrivate::Icon objects. 
Instead, you can either cache BBitmaps retrieved from BIconUtils, or cache 
const uint8* vector icon data retrieved from any new Haiku icon API (for 
example BNodeInfo::GetIcon(uint8** data, size_t* size, type_code* type)) or 
your application's resources. Then when you need the icon, you can let it 
render into a BBitmap again via BIconUtils. Thus, the only header you need is 
headers/libs/IconUtils.h. But be prepared to recompile your application if the 
Haiku API changes. Haiku will only be binary compatible for applications 
compiled against original BeOS R5 headers. Just something to keep in mind.

As an example, if you want to create icons for your tool bar, you could do the 
following:
* Design your icons in Icon-O-Matic.
* Store them as Icon-O-Matic native files (File->Save[ As])
* Also export them as "HVIF Source Code" (File->Export[ As])
* Put all exported icons in one header file which you include in your 
application source.
* Use BIconUtils::GetVectorIcon(const uint8* buffer, size_t size, BBitmap* 
result) to have your icon data rendered at any size (taken from "result" size).

> Also, do you know a tool to convert SVG icons to HVIF icons?
> I tried Icon-o-Matic but it seems that it has a fixed size for icons and 
> my SVG icons are larger than the editing area.

You should be able to select all shapes (in the list) and use the 
transformation tool to scale them down. The SVG import in Icon-O-Matic supports 
only rather basic SVG features, most importantly it does not support CSS. In 
any case, it is very important to cleanup the icons after import. 1) Icons are 
crisper if you make most shapes snap to integer pixels (see Options->Snap to 
Grid). And 2) It is mostly possible to simplify shapes and reuse paths across 
different shapes. If you google for "Icon-O-Matic video", you should get to a 
nice introduction to Icon-O-Matic that someone did. Sorry, forgot his name, but 
the video is really very useful for anyone wanting to get to know Icon-O-Matic 
better. I am afraid you will need to get familiar with Icon-O-Matic to really 
make use of vector icons in Haiku.

Best regards,
-Stephan

Other related posts: