[haiku-development] Re: Vector Icons help...?

  • From: Philippe Houdoin <philippe.houdoin@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 11:19:01 +0100

Stephan was wondering:
> Apparently, the MessageImporter is used when the FlatIconImporter
> returns an error, but why that is, I cannot say at the moment.
> I thought the MessageImporter isn't even part of libicon.a, but part
> of I-O-M. Maybe I can have a look tonight.

It's part of libicon.a, and used in BIconUtils::GetVectorIcon() as
fallback :

    FlatIconImporter importer;
    ret = importer.Import(&icon, const_cast<uint8*>(buffer), size);
    if (ret < B_OK) {
        // try the message based format used by Icon-O-Matic
        MessageImporter messageImporter;
        BMemoryIO memoryIO(const_cast<uint8*>(buffer), size);
        ret = messageImporter.Import(&icon, &memoryIO);
        if (ret < B_OK)
            return ret;
    }

So, the original issue is, as spotted by Pete, due to FlatIconImporter
returning Out Of Memory, or to be more
specific due to _ParseStyles failure.

As I've actually see the HVIF icon rendered as a 32x32 CMAP8 bitmap
displayed in an unmodified PatchBay, I know that my change actually
succeed to render once.
But what I didn't check:
1. that the 16x16 CMAP8 bitmap was rendered successfully too
2. that the raw data wasn't corrupted in the process

I assume GetVectorIcon() don't modify the passed raw data.
But maybe I'm wrong here.

Pete, did you try to comment out the "Render 32x32 and 16x16 icons for
R5 compatibility" portion in midi_server's DeviceWatcher()
constructor, to just have the HVIF raw data loaded and no large/mini
icons rendered?

+ /*
    // Render 32x32 and 16x16 icons for R5 compatibility
    if (fVectorIconData != NULL) {
        fLargeIcon = new(std::nothrow) BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
        fMiniIcon  = new(std::nothrow) BBitmap(BRect(0, 0, 15, 15), B_CMAP8);

        if (BIconUtils::GetVectorIcon(fVectorIconData, fVectorIconDataSize,
            fLargeIcon) != B_OK) {
            delete fLargeIcon;
            fLargeIcon = NULL;
        }
        if (BIconUtils::GetVectorIcon(fVectorIconData, fVectorIconDataSize,
            fMiniIcon) != B_OK) {
            delete fMiniIcon;
            fMiniIcon = NULL;
        }
+ */

Philippe.

Other related posts: