当前位置: 首页>>代码示例>>C++>>正文


C++ BResources::HasResource方法代码示例

本文整理汇总了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
}
开发者ID:mmanley,项目名称:Antares,代码行数:44,代码来源:TranslationUtils.cpp

示例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;
}
开发者ID:louisdem,项目名称:beos-bemobile,代码行数:15,代码来源:mobileview.cpp


注:本文中的BResources::HasResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。