[haiku-3rdparty-dev] Re: GetVectorIcon

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Sat, 19 Mar 2011 14:31:13 +0100

Am 19.03.2011 13:55, schrieb ciprian.nedisan@xxxxxxxxxxxx:


On Sat, 19 Mar 2011 12:52:27 +0200 Stephan Assmus
<superstippi@xxxxxx>  wrote:
What is the exact behavior you are observing

The icon is resized when the corresponding view is resized, and i
noticed, then the icon is resized to bigger than 256 , it
completely disappears, and when i resize the view to smaller , then
the bitmap/icon appears again.

I took from a program (i can not remember anymore which), a method
for loading icons from resource to bitmap, and adapted it, and now
it looks like that:

BBitmap* _LoadBitmap( BString const&  imageName, int size )
{
        if (!fRes)
                return NULL;

        size_t nbytes = 0;
        color_space cspace = B_RGBA32;

        const void* data = fRes->LoadResource( 'HVIF', imageName.String(),
&nbytes);


     size--;

        BBitmap* bitmap = new BBitmap( BRect(0,0, size, size ),
                cspace);
        if (bitmap->InitCheck() != B_OK)
                return NULL;

        if (BIconUtils::GetVectorIcon((const uint8*)data, nbytes, bitmap)
!= B_OK)
     {
         //delete[] data;
         delete bitmap;

         return NULL;
     }

        return( bitmap );
}

So it seems the restricion is the first argument of GetVectorIcon?

Like I said, I looked over the code, and like Rene, I couldn't spot a place where it checks the bitmap size. What is the error returned from GetVectorIcon()? You can use printf("GetVectorIcon(): %s", strerror(returnCode). What does bitmap->InitCheck() return? And have you printed out the size? Maybe you have a bug in your size calculation and it is actually much larger than you think...

Best regards,
-Stephan

Other related posts: