本文整理汇总了C++中BResources::HasResource方法的典型用法代码示例。如果您正苦于以下问题:C++ BResources::HasResource方法的具体用法?C++ BResources::HasResource怎么用?C++ BResources::HasResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BResources
的用法示例。
在下文中一共展示了BResources::HasResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memio
// ---------------------------------------------------------------
// GetBitmap
//
// Returns a BBitmap object for the bitmap resource identified by
// the type type with the resource id, id.
// The user has to delete this object.
//
// Preconditions:
//
// Parameters: type, the type of resource to be loaded
// id, the id for the resource to be loaded
// roster, BTranslatorRoster used to do the translation
//
// Postconditions:
//
// Returns: NULL, if the resource couldn't be loaded or couldn't
// be translated to a BBitmap
// BBitmap * to the bitmap identified by type and id
// ---------------------------------------------------------------
BBitmap *
BTranslationUtils::GetBitmap(uint32 type, int32 id, BTranslatorRoster *roster)
{
BResources *pResources = BApplication::AppResources();
// Remember: pResources must not be freed because
// it belongs to the application
if (pResources == NULL || pResources->HasResource(type, id) == false)
return NULL;
// Load the bitmap resource from the application file
// pRawData should be NULL if the resource is an
// unknown type or not available
size_t bitmapSize = 0;
const void *kpRawData = pResources->LoadResource(type, id, &bitmapSize);
if (kpRawData == NULL || bitmapSize == 0)
return NULL;
BMemoryIO memio(kpRawData, bitmapSize);
// Put the pointer to the raw image data into a BMemoryIO object
// so that it can be used with BTranslatorRoster->Translate() in
// the GetBitmap(BPositionIO *, BTranslatorRoster *) function
return GetBitmap(&memio, roster);
// Translate the data in memio using the BTranslatorRoster roster
}
示例2: BBitmap
BBitmap *getIconFromResources(const char *icon_resname) {
BBitmap *bmp = NULL;
BResources *res = be_app->AppResources();
if (res->HasResource('BBMP',icon_resname)) {
printf("has resource bitmap [%s]\n",icon_resname);
BMessage msg;
size_t len;
char *buf;
buf = (char *)res->LoadResource('BBMP', icon_resname, &len);
// printf("loaded,len=%i\n",len);
msg.Unflatten(buf);
bmp = new BBitmap(&msg);
}
return bmp;
}