本文整理汇总了C++中BBitmap::Archive方法的典型用法代码示例。如果您正苦于以下问题:C++ BBitmap::Archive方法的具体用法?C++ BBitmap::Archive怎么用?C++ BBitmap::Archive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBitmap
的用法示例。
在下文中一共展示了BBitmap::Archive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
void
Utility::CopyToClipboard(const BBitmap& screenshot) const
{
if (be_clipboard->Lock()) {
be_clipboard->Clear();
BMessage* clipboard = be_clipboard->Data();
if (clipboard) {
BMessage* bitmap = new BMessage();
screenshot.Archive(bitmap);
clipboard->AddMessage("image/bitmap", bitmap);
be_clipboard->Commit();
}
be_clipboard->Unlock();
}
}
示例2: OnCopy
// Copy graph as bitmap to clipboard
void AppWindow::OnCopy() {
BRect rect;
BBitmap *bitmap = GetGraph(rect, B_RGB32);
if (bitmap != NULL) {
if (be_clipboard->Lock()) {
be_clipboard->Clear();
BMessage *clip, data;
bitmap->Archive(&data);
if (NULL != (clip = be_clipboard->Data())) {
clip->AddMessage("image/x-vnd.Be-bitmap", &data);
clip->AddRect("rect", rect);
be_clipboard->Commit();
}
be_clipboard->Unlock();
}
delete bitmap;
}
}
示例3: MessageReceived
void VBoxClipboardService::MessageReceived(BMessage *message)
{
uint32_t formats = 0;
message->PrintToStream();
switch (message->what)
{
case VBOX_GUEST_CLIPBOARD_HOST_MSG_FORMATS:
{
int rc;
uint32_t cb;
void *pv;
bool commit = false;
if (message->FindInt32("Formats", (int32 *)&formats) != B_OK)
break;
if (!formats)
break;
if (!be_clipboard->Lock())
break;
be_clipboard->Clear();
BMessage *clip = be_clipboard->Data();
if (!clip)
{
be_clipboard->Unlock();
break;
}
if (formats & VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT)
{
pv = _VBoxReadHostClipboard(VBOX_SHARED_CLIPBOARD_FMT_UNICODETEXT, &cb);
if (pv)
{
char *text;
rc = RTUtf16ToUtf8((PCRTUTF16)pv, &text);
if (RT_SUCCESS(rc))
{
BString str(text);
/** @todo user vboxClipboardUtf16WinToLin() */
// convert Windows CRLF to LF
str.ReplaceAll("\r\n", "\n");
// don't include the \0
clip->AddData("text/plain", B_MIME_TYPE, str.String(), str.Length());
RTStrFree(text);
commit = true;
}
free(pv);
}
}
if (formats & VBOX_SHARED_CLIPBOARD_FMT_BITMAP)
{
pv = _VBoxReadHostClipboard(VBOX_SHARED_CLIPBOARD_FMT_BITMAP, &cb);
if (pv)
{
void *pBmp = NULL;
size_t cbBmp = 0;
rc = vboxClipboardDibToBmp(pv, cb, &pBmp, &cbBmp);
if (RT_SUCCESS(rc))
{
BMemoryIO mio(pBmp, cbBmp);
BBitmap *bitmap = BTranslationUtils::GetBitmap(&mio);
if (bitmap)
{
BMessage bitmapArchive;
/** @todo r=ramshankar: split this into functions with error checking as
* neccessary. */
if ( bitmap->IsValid()
&& bitmap->Archive(&bitmapArchive) == B_OK
&& clip->AddMessage("image/bitmap", &bitmapArchive) == B_OK)
{
commit = true;
}
delete bitmap;
}
RTMemFree(pBmp);
}
free(pv);
}
}
/*
* Make sure we don't bounce this data back to the host, it's impolite. It can also
* be used as a hint to applications probably.
*/
clip->AddBool("FromVirtualBoxHost", true);
if (commit)
be_clipboard->Commit();
be_clipboard->Unlock();
break;
}
case VBOX_GUEST_CLIPBOARD_HOST_MSG_READ_DATA:
{
int rc;
if (message->FindInt32("Formats", (int32 *)&formats) != B_OK)
//.........这里部分代码省略.........