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


C++ BBitmap::InitCheck方法代码示例

本文整理汇总了C++中BBitmap::InitCheck方法的典型用法代码示例。如果您正苦于以下问题:C++ BBitmap::InitCheck方法的具体用法?C++ BBitmap::InitCheck怎么用?C++ BBitmap::InitCheck使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BBitmap的用法示例。


在下文中一共展示了BBitmap::InitCheck方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: file

void
NetworkStatusView::_UpdateBitmaps()
{
	for (int i = 0; i < kStatusCount; i++) {
		delete fTrayIcons[i];
		delete fNotifyIcons[i];
		fTrayIcons[i] = NULL;
		fNotifyIcons[i] = NULL;
	}

	image_info info;
	if (our_image(info) != B_OK)
		return;

	BFile file(info.name, B_READ_ONLY);
	if (file.InitCheck() < B_OK)
		return;

	BResources resources(&file);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
	if (resources.InitCheck() < B_OK)
		return;
#endif

	for (int i = 0; i < kStatusCount; i++) {
		const void* data = NULL;
		size_t size;
		data = resources.LoadResource(B_VECTOR_ICON_TYPE,
			kNetworkStatusNoDevice + i, &size);
		if (data != NULL) {
			// Scale main tray icon
			BBitmap* trayIcon = new BBitmap(Bounds(), B_RGBA32);
			if (trayIcon->InitCheck() == B_OK
				&& BIconUtils::GetVectorIcon((const uint8 *)data,
					size, trayIcon) == B_OK) {
				fTrayIcons[i] = trayIcon;
			} else
				delete trayIcon;

			// Scale notification icon
			BBitmap* notifyIcon = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32);
			if (notifyIcon->InitCheck() == B_OK
				&& BIconUtils::GetVectorIcon((const uint8 *)data,
					size, notifyIcon) == B_OK) {
				fNotifyIcons[i] = notifyIcon;
			} else
				delete notifyIcon;
		}
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:50,代码来源:NetworkStatusView.cpp

示例2: GetBitmap

BBitmap* Preferences::GetBitmap( const char* aName )
	{
	BBitmap 	*bitmap = NULL;
	size_t 		len = 0;
	status_t 	error;	

	const void *data = iResources->LoadResource( 'BBMP', aName, &len );

	BMemoryIO stream(data, len);
	
	BMessage archive;
	error = archive.Unflatten(&stream);
	if (error != B_OK)
		return NULL;
	bitmap = new BBitmap(&archive);
	if(!bitmap)
		return NULL;

	if(bitmap->InitCheck() != B_OK)
	{
		delete bitmap;
		return NULL;
	}
	
	return bitmap;
}
开发者ID:louisdem,项目名称:beos-begadu,代码行数:26,代码来源:Preferences.cpp

示例3: new

status_t
Icon::GetData(icon_size which, BBitmap** _bitmap) const
{
	BBitmap* source;
	switch (which) {
		case B_LARGE_ICON:
			source = fLarge;
			break;
		case B_MINI_ICON:
			source = fMini;
			break;
		default:
			return B_BAD_VALUE;
	}

	if (source == NULL)
		return B_ENTRY_NOT_FOUND;

	BBitmap* bitmap = new (nothrow) BBitmap(source);
	if (bitmap == NULL || bitmap->InitCheck() != B_OK) {
		delete bitmap;
		return B_NO_MEMORY;
	}

	*_bitmap = bitmap;
	return B_OK;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:27,代码来源:IconView.cpp

示例4: fFrame

OffscreenBitmap::OffscreenBitmap(BRect frame, color_space colorSpace)
	: fFrame(frame)
	, fColorSpace(colorSpace)
	, fStatus(B_ERROR)
	, fBitmap(NULL)
	, fView(NULL)
{
	BBitmap *bitmap = new BBitmap(frame, fColorSpace, true);
	AutoDelete<BBitmap> _bitmap(bitmap);
	if (bitmap == NULL || bitmap->IsValid() == false || bitmap->InitCheck() != B_OK)
		return;
	
	BView *view = new BView(frame, "offscreen", B_FOLLOW_ALL, B_WILL_DRAW);
	AutoDelete<BView> _view(view);
	if (view == NULL)
		return;
	
	bitmap->Lock();
	bitmap->AddChild(view);
	// bitmap is locked during the life time of this object
	
	fBitmap = _bitmap.Release();
	fView = _view.Release();
	fStatus = B_OK;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:25,代码来源:PictureTest.cpp

示例5: new

// SetIcon
status_t
IconButton::SetIcon(const unsigned char* bitsFromQuickRes,
                    uint32 width, uint32 height, color_space format, bool convertToBW)
{
    status_t status = B_BAD_VALUE;
    if (bitsFromQuickRes && width > 0 && height > 0) {
        BBitmap* quickResBitmap = new(nothrow) BBitmap(BRect(0.0, 0.0, width - 1.0, height - 1.0), format);
        status = quickResBitmap ? quickResBitmap->InitCheck() : B_ERROR;
        if (status >= B_OK) {
            // It doesn't look right to copy BitsLength() bytes, but bitmaps
            // exported from QuickRes still contain their padding, so it is alright.
            memcpy(quickResBitmap->Bits(), bitsFromQuickRes, quickResBitmap->BitsLength());
            if (format != B_RGB32 && format != B_RGBA32 && format != B_RGB32_BIG && format != B_RGBA32_BIG) {
                // colorspace needs conversion
                BBitmap* bitmap = new(nothrow) BBitmap(quickResBitmap->Bounds(), B_RGB32, true);
                if (bitmap && bitmap->IsValid()) {
                    BView* helper = new BView(bitmap->Bounds(), "helper",
                                              B_FOLLOW_NONE, B_WILL_DRAW);
                    if (bitmap->Lock()) {
                        bitmap->AddChild(helper);
                        helper->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
                        helper->FillRect(helper->Bounds());
                        helper->SetDrawingMode(B_OP_OVER);
                        helper->DrawBitmap(quickResBitmap, BPoint(0.0, 0.0));
                        helper->Sync();
                        bitmap->Unlock();
                    }
                    status = _MakeBitmaps(bitmap);
                } else
                    printf("IconButton::SetIcon() - B_RGB32 bitmap is not valid\n");
                delete bitmap;
            } else {
                // native colorspace (32 bits)
                if (convertToBW) {
                    // convert to gray scale icon
                    uint8* bits = (uint8*)quickResBitmap->Bits();
                    uint32 bpr = quickResBitmap->BytesPerRow();
                    for (uint32 y = 0; y < height; y++) {
                        uint8* handle = bits;
                        uint8 gray;
                        for (uint32 x = 0; x < width; x++) {
                            gray = uint8((116 * handle[0] + 600 * handle[1] + 308 * handle[2]) / 1024);
                            handle[0] = gray;
                            handle[1] = gray;
                            handle[2] = gray;
                            handle += 4;
                        }
                        bits += bpr;
                    }
                }
                status = _MakeBitmaps(quickResBitmap);
            }
        } else
            printf("IconButton::SetIcon() - error allocating bitmap: %s\n", strerror(status));
        delete quickResBitmap;
    }
    return status;
}
开发者ID:mmanley,项目名称:Antares,代码行数:59,代码来源:IconButton.cpp

示例6: scaledBounds

status_t
MakeScreenshot(BBitmap **here)
{
	status_t err;
	BScreen bs;
	BWindow *win;
	BBitmap *shot;
	BBitmap *scaledBmp = NULL;
	be_app->Lock();
	win = be_app->WindowAt(0);
	if (win) {
		win->Lock();
		win->Hide();
		win->Unlock();
	}
	snooze(500000);
	err = bs.GetBitmap(&shot);
	if (!err) {
		BRect scaledBounds(0,0,640-1,480-1);
		scaledBmp = new BBitmap(scaledBounds, B_BITMAP_ACCEPTS_VIEWS, B_RGB32/*shot->ColorSpace()*/);
		err = scaledBmp->InitCheck();
		if (!err) {
			err = ENOSYS;
#ifdef B_ZETA_VERSION
			err = ScaleBitmap(*shot, *scaledBmp);
#endif
			if (err) {
				// filtered scaling didn't work, do it manually
				BView *v = new BView(scaledBounds, "scaleview", B_FOLLOW_NONE, 0);
				scaledBmp->AddChild(v);
				v->LockLooper();
				v->DrawBitmap(shot);
				v->Sync();
				v->UnlockLooper();
				scaledBmp->RemoveChild(v);
				delete v;
				err = B_OK;
			}
		}
		delete shot;
	}

	if (win) {
		win->Lock();
		win->Show();
		win->Unlock();
	}
	be_app->Unlock();
	
	if (err)
		return err;
	
	*here = scaledBmp;

	return B_OK;
}
开发者ID:HaikuArchives,项目名称:HaikuThemeManager,代码行数:56,代码来源:MakeScreenshot.cpp

示例7: if

// Retrieves an icon associated with a given device.
status_t
get_device_icon(const char *device, BBitmap *icon, icon_size which)
{
	// check parameters
	if (device == NULL || icon == NULL)
		return B_BAD_VALUE;

	uint8* data;
	size_t size;
	type_code type;
	status_t status = get_device_icon(device, &data, &size, &type);
	if (status == B_OK) {
		status = BIconUtils::GetVectorIcon(data, size, icon);
		delete[] data;
		return status;
	}

	// Vector icon was not available, try old one

	BRect rect;
	if (which == B_MINI_ICON)
		rect.Set(0, 0, 15, 15);
	else if (which == B_LARGE_ICON)
		rect.Set(0, 0, 31, 31);

	BBitmap* bitmap = icon;
	int32 iconSize = which;

	if (icon->ColorSpace() != B_CMAP8
		|| (which != B_MINI_ICON && which != B_LARGE_ICON)) {
		if (which < B_LARGE_ICON)
			iconSize = B_MINI_ICON;
		else
			iconSize = B_LARGE_ICON;

		bitmap = new(std::nothrow) BBitmap(
			BRect(0, 0, iconSize - 1, iconSize -1), B_BITMAP_NO_SERVER_LINK,
			B_CMAP8);
		if (bitmap == NULL || bitmap->InitCheck() != B_OK) {
			delete bitmap;
			return B_NO_MEMORY;
		}
	}

	// get the icon, convert temporary data into bitmap if necessary
	status = get_device_icon(device, bitmap->Bits(), iconSize);
	if (status == B_OK && icon != bitmap)
		status = BIconUtils::ConvertFromCMAP8(bitmap, icon);

	if (icon != bitmap)
		delete bitmap;

	return status;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:55,代码来源:Mime.cpp

示例8: BBitmap

void
ConfigWindow::MakeHowToView()
{
	BResources *resources = BApplication::AppResources();
	if (resources)
	{
		size_t length;
		char *buffer = (char *)resources->FindResource('ICON',101,&length);
		if (buffer)
		{
			BBitmap *bitmap = new BBitmap(BRect(0,0,63,63),B_CMAP8);
			if (bitmap && bitmap->InitCheck() == B_OK)
			{
				// copy and enlarge a 32x32 8-bit bitmap
				char *bits = (char *)bitmap->Bits();
				for (int32 i = 0,j = -64;i < length;i++)
				{
					if ((i % 32) == 0)
						j += 64;

					char *b = bits + (i << 1) + j;
					b[0] = b[1] = b[64] = b[65] = buffer[i];
				}
				fConfigView->AddChild(new BitmapView(bitmap));
			}
			else
				delete bitmap;
		}
	}

	BRect rect = fConfigView->Bounds();
	BTextView *text = new BTextView(rect,NULL,rect,B_FOLLOW_NONE,B_WILL_DRAW);
	text->SetViewColor(fConfigView->Parent()->ViewColor());
	text->SetAlignment(B_ALIGN_CENTER);
	text->SetText(
		MDR_DIALECT_CHOICE ("\n\nCreate a new account using the \"Add\" button.\n\n"
		"Delete accounts (or only the inbound/outbound) by using the \"Remove\" button on the selected item.\n\n"
		"Select an item in the list to edit its configuration.",
		"\n\nアカウントの新規作成は\"追加\"ボタンを\n使います。"
		"\n\nアカウント自体またはアカウントの\n送受信設定を削除するには\n項目を選択して\"削除\"ボタンを使います。"
		"\n\nアカウント内容の変更は、\nマウスで項目をクリックしてください。"));
	rect = text->Bounds();
	text->ResizeTo(rect.Width(),text->TextHeight(0,42));
	text->SetTextRect(rect);

	text->MakeEditable(false);
	text->MakeSelectable(false);

	fConfigView->AddChild(text);
	
	static_cast<CenterContainer *>(fConfigView)->Layout();
}
开发者ID:HaikuArchives,项目名称:BeMailDaemon,代码行数:52,代码来源:ConfigWindow.cpp

示例9: new

status_t
CanvasMessage::ReadBitmap(BBitmap** _bitmap, bool minimal,
	color_space colorSpace, uint32 flags)
{
	uint32 bitsLength;
	int32 width, height, bytesPerRow;

	Read(width);
	Read(height);
	Read(bytesPerRow);

	if (!minimal) {
		Read(colorSpace);
		Read(flags);
	}

	Read(bitsLength);

	if (bitsLength > fDataLeft)
		return B_ERROR;

#ifndef CLIENT_COMPILE
	flags = B_BITMAP_NO_SERVER_LINK;
#endif

	BBitmap *bitmap = new(std::nothrow) BBitmap(
		BRect(0, 0, width - 1, height - 1), flags, colorSpace, bytesPerRow);
	if (bitmap == NULL)
		return B_NO_MEMORY;

	status_t result = bitmap->InitCheck();
	if (result != B_OK) {
		delete bitmap;
		return result;
	}

	if (bitmap->BitsLength() < (int32)bitsLength) {
		delete bitmap;
		return B_ERROR;
	}

	int32 readSize = fSource->Read(bitmap->Bits(), bitsLength);
	if ((uint32)readSize != bitsLength) {
		delete bitmap;
		return readSize < 0 ? readSize : B_ERROR;
	}

	fDataLeft -= readSize;
	*_bitmap = bitmap;
	return B_OK;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:51,代码来源:CanvasMessage.cpp

示例10: BBitmap

BBitmap*
OffscreenBitmap::Copy()
{
	// the result bitmap that does not accept views	
	// to save resources in the application server
	BBitmap *copy = new BBitmap(fFrame, fColorSpace, false);
	AutoDelete<BBitmap> _copy(copy);
	if (copy == NULL || copy->IsValid() == false || copy->InitCheck() != B_OK)
		return NULL;

	fView->Sync();
	fBitmap->Unlock();
	
	memcpy(copy->Bits(), fBitmap->Bits(), fBitmap->BitsLength());	
	
	fBitmap->Lock();

	return _copy.Release();
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:19,代码来源:PictureTest.cpp

示例11: new

BBitmap*
BAlert::_InitIcon()
{
	// Save the desired alert type and set it to "empty" until
	// loading the icon was successful
	alert_type alertType = fMsgType;
	fMsgType = B_EMPTY_ALERT;

	// After a bit of a search, I found the icons in app_server. =P
	BBitmap* icon = NULL;
	BPath path;
	status_t status = find_directory(B_BEOS_SERVERS_DIRECTORY, &path);
	if (status < B_OK) {
		FTRACE((stderr, "BAlert::_InitIcon() - find_directory failed: %s\n",
			strerror(status)));
		return NULL;
	}

	path.Append("app_server");
	BFile file;
	status = file.SetTo(path.Path(), B_READ_ONLY);
	if (status < B_OK) {
		FTRACE((stderr, "BAlert::_InitIcon() - BFile init failed: %s\n",
			strerror(status)));
		return NULL;
	}

	BResources resources;
	status = resources.SetTo(&file);
	if (status < B_OK) {
		FTRACE((stderr, "BAlert::_InitIcon() - BResources init failed: %s\n",
			strerror(status)));
		return NULL;
	}

	// Which icon are we trying to load?
	const char* iconName = "";	// Don't want any seg faults
	switch (alertType) {
		case B_INFO_ALERT:
			iconName = "info";
			break;
		case B_IDEA_ALERT:
			iconName = "idea";
			break;
		case B_WARNING_ALERT:
			iconName = "warn";
			break;
		case B_STOP_ALERT:
			iconName = "stop";
			break;

		default:
			// Alert type is either invalid or B_EMPTY_ALERT;
			// either way, we're not going to load an icon
			return NULL;
	}

	int32 iconSize = 32 * icon_layout_scale();
	// Allocate the icon bitmap
	icon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1),
		0, B_RGBA32);
	if (icon == NULL || icon->InitCheck() < B_OK) {
		FTRACE((stderr, "BAlert::_InitIcon() - No memory for bitmap\n"));
		delete icon;
		return NULL;
	}

	// Load the raw icon data
	size_t size = 0;
	const uint8* rawIcon;

#ifdef __ANTARES__
	// Try to load vector icon
	rawIcon = (const uint8*)resources.LoadResource(B_VECTOR_ICON_TYPE,
		iconName, &size);
	if (rawIcon != NULL
		&& BIconUtils::GetVectorIcon(rawIcon, size, icon) == B_OK) {
		// We have an icon, restore the saved alert type
		fMsgType = alertType;
		return icon;
	}
#endif

	// Fall back to bitmap icon
	rawIcon = (const uint8*)resources.LoadResource(B_LARGE_ICON_TYPE,
		iconName, &size);
	if (rawIcon == NULL) {
		FTRACE((stderr, "BAlert::_InitIcon() - Icon resource not found\n"));
		delete icon;
		return NULL;
	}

	// Handle color space conversion
#ifdef __ANTARES__
	if (icon->ColorSpace() != B_CMAP8) {
		BIconUtils::ConvertFromCMAP8(rawIcon, iconSize, iconSize,
			iconSize, icon);
	}
#else
	icon->SetBits(rawIcon, iconSize, 0, B_CMAP8);
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:Alert.cpp

示例12: appFile

void
ConfigWindow::MakeHowToView()
{
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
    BResources *resources = BApplication::AppResources();
    if (resources) {
        size_t length;
        char *buffer = (char *)resources->FindResource(B_LARGE_ICON_TYPE, 101,
                       &length);
        if (buffer) {
            BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
                                                    B_CMAP8);
            if (bitmap && bitmap->InitCheck() == B_OK) {
                // copy and enlarge a 32x32 8-bit bitmap
                char *bits = (char *)bitmap->Bits();
                for (int32 i = 0, j = -64; i < (int32)length; i++) {
                    if ((i % 32) == 0)
                        j += 64;

                    char *b = bits + (i << 1) + j;
                    b[0] = b[1] = b[64] = b[65] = buffer[i];
                }
                fConfigView->AddChild(new BitmapView(bitmap));
            } else
                delete bitmap;
        }
    }
#else
    app_info info;
    if (be_app->GetAppInfo(&info) == B_OK) {
        BFile appFile(&info.ref, B_READ_ONLY);
        BAppFileInfo appFileInfo(&appFile);
        if (appFileInfo.InitCheck() == B_OK) {
            BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
                                                    B_RGBA32);
            if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) {
                fConfigView->AddChild(new BitmapView(bitmap));
            } else
                delete bitmap;
        }
    }
#endif // HAIKU_TARGET_PLATFORM_HAIKU

    BRect rect = fConfigView->Bounds();
    BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE,
                                    B_WILL_DRAW);
    text->SetViewColor(fConfigView->Parent()->ViewColor());
    text->SetAlignment(B_ALIGN_CENTER);
    text->SetText(B_TRANSLATE(
                      "\n\nCreate a new account with the Add button.\n\n"
                      "Remove an account with the Remove button on the selected item.\n\n"
                      "Select an item in the list to change its settings."));
    rect = text->Bounds();
    text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
    text->SetTextRect(rect);

    text->MakeEditable(false);
    text->MakeSelectable(false);

    fConfigView->AddChild(text);

    static_cast<CenterContainer *>(fConfigView)->Layout();
}
开发者ID:mmadia,项目名称:haiku-1,代码行数:63,代码来源:ConfigWindow.cpp

示例13: file

void
IconView::_SetIcon(entry_ref* ref)
{
	// retrieve icons from file
	BFile file(ref, B_READ_ONLY);
	BAppFileInfo info(&file);
	if (file.InitCheck() != B_OK || info.InitCheck() != B_OK)
		return;

	// try vector/PNG icon first
	uint8* data = NULL;
	size_t size = 0;
	if (info.GetIcon(&data, &size) == B_OK) {
		_SetIcon(NULL, NULL, data, size);
		free(data);
		return;
	}

	// try large/mini icons
	bool hasMini = false;
	bool hasLarge = false;

	BBitmap* large = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
	if (large->InitCheck() != B_OK) {
		delete large;
		large = NULL;
	}
	BBitmap* mini = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
	if (mini->InitCheck() != B_OK) {
		delete mini;
		mini = NULL;
	}

	if (large != NULL && info.GetIcon(large, B_LARGE_ICON) == B_OK)
		hasLarge = true;
	if (mini != NULL && info.GetIcon(mini, B_MINI_ICON) == B_OK)
		hasMini = true;

	if (!hasMini && !hasLarge) {
		// TODO: don't forget device icons!

		// try MIME type icon
		char type[B_MIME_TYPE_LENGTH];
		if (info.GetType(type) != B_OK)
			return;

		BMimeType mimeType(type);
		if (icon_for_type(mimeType, &data, &size) != B_OK) {
			// only try large/mini icons when there is no vector icon
			if (large != NULL
				&& icon_for_type(mimeType, *large, B_LARGE_ICON) == B_OK)
				hasLarge = true;
			if (mini != NULL
				&& icon_for_type(mimeType, *mini, B_MINI_ICON) == B_OK)
				hasMini = true;
		}
	}

	if (data != NULL) {
		_SetIcon(NULL, NULL, data, size);
		free(data);
	} else if (hasLarge || hasMini)
		_SetIcon(large, mini, NULL, 0);

	delete large;
	delete mini;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:67,代码来源:IconView.cpp

示例14: strerror

BBitmap*
BAlert::_CreateTypeIcon()
{
	if (Type() == B_EMPTY_ALERT)
		return NULL;

	// The icons are in the app_server resources
	BBitmap* icon = NULL;
	BPath path;
	status_t status = find_directory(B_BEOS_SERVERS_DIRECTORY, &path);
	if (status != B_OK) {
		FTRACE((stderr, "BAlert::_CreateTypeIcon() - find_directory "
			"failed: %s\n", strerror(status)));
		return NULL;
	}

	path.Append("app_server");
	BFile file;
	status = file.SetTo(path.Path(), B_READ_ONLY);
	if (status != B_OK) {
		FTRACE((stderr, "BAlert::_CreateTypeIcon() - BFile init failed: %s\n",
			strerror(status)));
		return NULL;
	}

	BResources resources;
	status = resources.SetTo(&file);
	if (status != B_OK) {
		FTRACE((stderr, "BAlert::_CreateTypeIcon() - BResources init "
			"failed: %s\n", strerror(status)));
		return NULL;
	}

	// Which icon are we trying to load?
	const char* iconName;
	switch (fType) {
		case B_INFO_ALERT:
			iconName = "info";
			break;
		case B_IDEA_ALERT:
			iconName = "idea";
			break;
		case B_WARNING_ALERT:
			iconName = "warn";
			break;
		case B_STOP_ALERT:
			iconName = "stop";
			break;

		default:
			// Alert type is either invalid or B_EMPTY_ALERT;
			// either way, we're not going to load an icon
			return NULL;
	}

	int32 iconSize = 32 * icon_layout_scale();
	// Allocate the icon bitmap
	icon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1),
		0, B_RGBA32);
	if (icon == NULL || icon->InitCheck() < B_OK) {
		FTRACE((stderr, "BAlert::_CreateTypeIcon() - No memory for bitmap\n"));
		delete icon;
		return NULL;
	}

	// Load the raw icon data
	size_t size = 0;
	const uint8* rawIcon;

	// Try to load vector icon
	rawIcon = (const uint8*)resources.LoadResource(B_VECTOR_ICON_TYPE,
		iconName, &size);
	if (rawIcon != NULL
		&& BIconUtils::GetVectorIcon(rawIcon, size, icon) == B_OK) {
		return icon;
	}

	// Fall back to bitmap icon
	rawIcon = (const uint8*)resources.LoadResource(B_LARGE_ICON_TYPE,
		iconName, &size);
	if (rawIcon == NULL) {
		FTRACE((stderr, "BAlert::_CreateTypeIcon() - Icon resource not found\n"));
		delete icon;
		return NULL;
	}

	// Handle color space conversion
	if (icon->ColorSpace() != B_CMAP8) {
		BIconUtils::ConvertFromCMAP8(rawIcon, iconSize, iconSize,
			iconSize, icon);
	}

	return icon;
}
开发者ID:tqh,项目名称:haiku-efi,代码行数:94,代码来源:Alert.cpp

示例15: BBitmap

bool
VideoView::IsOverlaySupported()
{
	struct colorcombo {
		color_space colspace;
		const char *name;
	} colspace[] = {
		{ B_RGB32,		"B_RGB32"},
		{ B_RGBA32,		"B_RGBA32"},
		{ B_RGB24,		"B_RGB24"},
		{ B_RGB16,		"B_RGB16"},
		{ B_RGB15,		"B_RGB15"},
		{ B_RGBA15,		"B_RGBA15"},
		{ B_RGB32_BIG,	"B_RGB32_BIG"},
		{ B_RGBA32_BIG,	"B_RGBA32_BIG "},
		{ B_RGB24_BIG,	"B_RGB24_BIG "},
		{ B_RGB16_BIG,	"B_RGB16_BIG "},
		{ B_RGB15_BIG,	"B_RGB15_BIG "},
		{ B_RGBA15_BIG, "B_RGBA15_BIG "},
		{ B_YCbCr422,	"B_YCbCr422"},
		{ B_YCbCr411,	"B_YCbCr411"},
		{ B_YCbCr444,	"B_YCbCr444"},
		{ B_YCbCr420,	"B_YCbCr420"},
		{ B_YUV422,		"B_YUV422"},
		{ B_YUV411,		"B_YUV411"},
		{ B_YUV444,		"B_YUV444"},
		{ B_YUV420,		"B_YUV420"},
		{ B_NO_COLOR_SPACE, NULL}
	};
	
	bool supported = false;
	for (int i = 0; colspace[i].name; i++) {
		BBitmap *test = new BBitmap(BRect(0,0,320,240),	B_BITMAP_WILL_OVERLAY 
			| B_BITMAP_RESERVE_OVERLAY_CHANNEL, colspace[i].colspace);
		if (test->InitCheck() == B_OK) {
			printf("Display supports %s (0x%08x) overlay\n", colspace[i].name, 
				colspace[i].colspace);
			overlay_restrictions restrict;
			if (B_OK == test->GetOverlayRestrictions(&restrict)) {
				printf(
					"Overlay restrictions: source horizontal_alignment %d\n", 
					restrict.source.horizontal_alignment);
				printf("Overlay restrictions: source vertical_alignment %d\n", 
					restrict.source.vertical_alignment);
				printf("Overlay restrictions: source width_alignment %d\n", 
					restrict.source.width_alignment);
				printf("Overlay restrictions: source height_alignment %d\n", 
					restrict.source.height_alignment);
				printf("Overlay restrictions: source min_width %d\n", 
					restrict.source.min_width);
				printf("Overlay restrictions: source max_width %d\n", 
					restrict.source.max_width);
				printf("Overlay restrictions: source min_height %d\n", 
					restrict.source.min_height);
				printf("Overlay restrictions: source max_height %d\n", 
					restrict.source.max_height);
				printf(
					"Overlay restrictions: destination horizontal_alignment "
					"%d\n", restrict.destination.horizontal_alignment);
				printf("Overlay restrictions: destination vertical_alignment "
					"%d\n", restrict.destination.vertical_alignment);
				printf("Overlay restrictions: destination width_alignment "
					"%d\n", restrict.destination.width_alignment);
				printf("Overlay restrictions: destination height_alignment "
					"%d\n", restrict.destination.height_alignment);
				printf("Overlay restrictions: destination min_width %d\n", 
					restrict.destination.min_width);
				printf("Overlay restrictions: destination max_width %d\n", 
					restrict.destination.max_width);
				printf("Overlay restrictions: destination min_height %d\n", 
					restrict.destination.min_height);
				printf("Overlay restrictions: destination max_height %d\n", 
					restrict.destination.max_height);
				printf("Overlay restrictions: min_width_scale %.3f\n", 
					restrict.min_width_scale);
				printf("Overlay restrictions: max_width_scale %.3f\n", 
					restrict.max_width_scale);
				printf("Overlay restrictions: min_height_scale %.3f\n", 
					restrict.min_height_scale);
				printf("Overlay restrictions: max_height_scale %.3f\n", 
					restrict.max_height_scale);
			}
			supported = true;
		}
		delete test;
//		if (supported)
//			break;
	}
	return supported;
}
开发者ID:DonCN,项目名称:haiku,代码行数:90,代码来源:VideoView.cpp


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