[interfacekit] Re: Icons and BBitmap

  • From: Tyler Dauwalder <tyler@xxxxxxxxxxxxx>
  • To: interfacekit@xxxxxxxxxxxxx
  • Date: Mon, 19 Aug 2002 01:49:31 -0700

Hi folks,

I ran into a bit of trouble whilest working on BMimeType::SetIcon(). My 
intent was to archive the icon passed to BMimeType, send it in a 
message to the mime manager (running in the registrar), unarchive it, 
and let the MimeDatabase class deal with color conversions, etc, etc, 
before preparing the proper bits to be written to the appropriate icon 
attribute. That way, all code needing any sort of knowledge about the 
format of data stored in the database itself is kept in the 
MimeDatabase class, and not spread all over the place.

The problem I discovered is that R5::BBitmap::Instantiate() is not 
happy, and by not happy I mean crashing our registrar when I try to 
call R5::BBitmap::Instantiate indirectly via 
OBOS::instantiate_object(). Our implementation of instantiate_object() 
appears to find the proper function in libbe.so (btw, whoever wrote 
BArchivable deserves a pat on the back; that thing's a monster), but 
actually calling it leads to a crash. (I thought for a moment it might 
be that it didn't like the OBOS::BMessage it was being passed, but it 
looks to me like we're still using R5::BMessage...). I wrote up an 
empty OBOS::BBitmap class just to see if its Instantiate() function 
would cause a crash as well, and lo and behold it didn't. Why the 
difference? I don't know. :-) 

At any rate, I've worked around it for the time being, moving the color 
conversion code elsewhere (incidentally, converting a B_RGB32 bitmap to 
a B_CMAP8 bitmap using BBitmap::SetBits is way more involved that it 
needs to be...). BMimeType::Get/SetIcon() is now finally working, 
though I plan to add some more tests to be sure all the color 
conversion code works like I think it should. The other Icon() 
functions will be tackled next...

-Tyler

Other related posts: