Hello Rene & John; That worked well thank you for your help! cheers. On 5/03/13 8:00 AM, John Scipione wrote:
I'm glad you asked! Here is some sample code to get an application icon based on it's signature assuming a 32x32 or greater icon. For 16x16 use B_MINI_ICON in place of B_LARGE_ICON. #include <AppFileInfo.h> #include <Bitmap.h> #include <MimeType.h> #include <Rect.h> #include <Roster.h> const char* signature = "application/x-vnd-MyCoolApp"; BBitmap* icon = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32); // use BRect(0, 0, 15, 15) for 16x16 icon. // You may specify larger than 32x32 here and it will scale for you. // Specify B_CMAP8 for the color space is you want an old school // 8-bit BeOS icon app_info appInfo; if (be_roster->GetAppInfo(signature, &appInfo) == B_OK) { // fetch the app icon BFile file(&appInfo.ref, B_READ_ONLY); BAppFileInfo appMime(&file); if (appMime.GetIcon(icon, B_LARGE_ICON) != B_OK) { // couldn't find it, get the generic 3-boxes icon BMimeType defaultAppMime; defaultAppMime.SetTo(B_APP_MIME_TYPE); defaultAppMime.GetIcon(icon, size); } } You can use larger icon sizes and it will automatically scale the result for you, just make sure to specify B_LARGE_ICON and not B_MINI_ICON or you may end up with a scaled version of the 16x16 icon which won't look very good. Note, I didn't compile the above so it's possible that there are syntax errors in it. John Scipione On Mon, Mar 4, 2013 at 1:38 PM, Andrew Lindesay <apl@xxxxxxxxxxxxxx> wrote:Hello; I am wondering what is the best mechanism to obtain the Application's icon into a BBitmap? I see BAppFileInfo, but can't see how to use it from within an application. cheers. -- Andrew Lindesay
-- Andrew Lindesay