root/BF_GUI_Misc.cpp

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. BF_GUI_GetBitmapFromResources

   1 #include <Resources.h>
   2 #include <Bitmap.h>
   3 #include <stdlib.h>
   4 #include "BF_GUI_Misc.h"
   5 #include "Main.h"
   6 
   7 void 
   8 BF_GUI_GetBitmapFromResources( BBitmap*& themap, int32 resid)    /* [previous][next][first][last][top][bottom][index][help] */
   9 {
  10 
  11         BResources res; 
  12         status_t err; 
  13         
  14         size_t  reslength;
  15         const char * resbuf;
  16         BMessage archive;
  17 
  18         //      Open resource file
  19         BFile file( poApp->AppFileName().String(), B_READ_ONLY );  
  20 
  21         // if the file loads OK, that is
  22         if ( (file.InitCheck() || (err = res.SetTo(&file)) ) == B_NO_ERROR )  {
  23 
  24                 // Find and load resource
  25                 resbuf = (char*)res.LoadResource( B_ANY_TYPE, resid, &reslength );
  26                                                         
  27                 if( resbuf ) {
  28                 
  29                         // Inflate and unarchive BBitmap
  30                         archive.Unflatten( resbuf );    
  31                         themap = new BBitmap( &archive );       
  32 
  33                 } else {
  34                         (new BAlert("", "Error while reading resource from file.", "OK"))->Go();
  35                 }
  36                                 
  37         } else {        // Error
  38                 (new BAlert("", "Error opening resource file.", "OK"))->Go();
  39                 exit(1);
  40         }
  41 }

/* [previous][next][first][last][top][bottom][index][help] */