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


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

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


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

示例1: file

void
TBarApp::FetchAppIcon(BarTeamInfo* barInfo)
{
	int32 width = IconSize();
	int32 index = (width - kMinimumIconSize) / kIconSizeInterval;

	// first look in the icon cache
	barInfo->icon = barInfo->iconCache[index];
	if (barInfo->icon != NULL)
		return;

	// icon wasn't in cache, get it from be_roster and cache it
	app_info appInfo;
	icon_size size = width >= 31 ? B_LARGE_ICON : B_MINI_ICON;
	BBitmap* icon = new BBitmap(IconRect(), kIconColorSpace);
	if (be_roster->GetAppInfo(barInfo->sig, &appInfo) == B_OK) {
		// fetch the app icon
		BFile file(&appInfo.ref, B_READ_ONLY);
		BAppFileInfo appMime(&file);
		if (appMime.GetIcon(icon, size) == B_OK) {
			delete barInfo->iconCache[index];
			barInfo->iconCache[index] = barInfo->icon = icon;
			return;
		}
	}

	// couldn't find the app icon
	// fetch the generic 3 boxes icon and cache it
	BMimeType defaultAppMime;
	defaultAppMime.SetTo(B_APP_MIME_TYPE);
	if (defaultAppMime.GetIcon(icon, size) == B_OK) {
		delete barInfo->iconCache[index];
		barInfo->iconCache[index] = barInfo->icon = icon;
		return;
	}

	// couldn't find generic 3 boxes icon
	// fill with transparent
	uint8* iconBits = (uint8*)icon->Bits();
	if (icon->ColorSpace() == B_RGBA32) {
		int32 i = 0;
		while (i < icon->BitsLength()) {
			iconBits[i++] = B_TRANSPARENT_32_BIT.red;
			iconBits[i++] = B_TRANSPARENT_32_BIT.green;
			iconBits[i++] = B_TRANSPARENT_32_BIT.blue;
			iconBits[i++] = B_TRANSPARENT_32_BIT.alpha;
		}
	} else {
		// Assume B_CMAP8
		for (int32 i = 0; i < icon->BitsLength(); i++)
			iconBits[i] = B_TRANSPARENT_MAGIC_CMAP8;
	}

	delete barInfo->iconCache[index];
	barInfo->iconCache[index] = barInfo->icon = icon;
}
开发者ID:kbjava,项目名称:haiku,代码行数:56,代码来源:BarApp.cpp

示例2: message

status_t
RemoteDrawingEngine::ReadBitmap(ServerBitmap* bitmap, bool drawCursor,
	BRect bounds)
{
	if (_AddCallback() != B_OK)
		return B_UNSUPPORTED;

	RemoteMessage message(NULL, fHWInterface->SendBuffer());

	message.Start(RP_READ_BITMAP);
	message.Add(fToken);
	message.Add(bounds);
	message.Add(drawCursor);
	if (message.Flush() != B_OK)
		return B_UNSUPPORTED;

	status_t result;
	do {
		result = acquire_sem_etc(fResultNotify, 1, B_RELATIVE_TIMEOUT,
			100 * 1000 * 1000);
	} while (result == B_INTERRUPTED);

	if (result != B_OK)
		return result;

	BBitmap* read = fReadBitmapResult;
	if (read == NULL)
		return B_UNSUPPORTED;

	result = bitmap->ImportBits(read->Bits(), read->BitsLength(),
		read->BytesPerRow(), read->ColorSpace());
	delete read;
	return result;
}
开发者ID:mariuz,项目名称:haiku,代码行数:34,代码来源:RemoteDrawingEngine.cpp

示例3:

int32
get_bitmap_bits_length(const Bitmap *bitmap)
{
	BBitmap *bb = (BBitmap*)bitmap;
	if (bb)
		return bb->BitsLength();
	return 0;
}
开发者ID:aljen,项目名称:haiku-opengl,代码行数:8,代码来源:hsp_bitmap_wrapper.cpp

示例4: 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

示例5: BMenuItem

BitmapMenuItem::BitmapMenuItem(const char* name, const BBitmap& bitmap,
	BMessage* message, char shortcut, uint32 modifiers)
	: BMenuItem(name, message, shortcut, modifiers),
	m_bitmap(bitmap.Bounds(), bitmap.ColorSpace())
{
	// Sadly, operator= for bitmaps is not yet implemented.
	// Half of m_bitmap's initialization is above; now we copy
	// the bits.
	m_bitmap.SetBits(bitmap.Bits(), bitmap.BitsLength(),
		0, bitmap.ColorSpace());
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:11,代码来源:BitmapMenuItem.cpp

示例6:

bool
PairsView::_HasBitmap(BList& bitmaps, BBitmap* bitmap)
{
	// TODO: if this takes too long, we could build a hash value for each
	// bitmap in a separate list
	for (int32 i = bitmaps.CountItems(); i-- > 0;) {
		BBitmap* item = (BBitmap*)bitmaps.ItemAtFast(i);
		if (!memcmp(item->Bits(), bitmap->Bits(), item->BitsLength()))
			return true;
	}

	return false;
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:13,代码来源:PairsView.cpp

示例7: 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

示例8: genericType

void
IconView::SetGenericIcon()
{
	// get default icon
	BMimeType genericType(B_FILE_MIME_TYPE);
	if (genericType.GetIcon(fIconBitmap, B_LARGE_ICON) != B_OK) {
		// clear bitmap
		uint8 transparent = 0;
		if (fIconBitmap->ColorSpace() == B_CMAP8)
			transparent = B_TRANSPARENT_MAGIC_CMAP8;

		memset(fIconBitmap->Bits(), transparent, fIconBitmap->BitsLength());
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:14,代码来源:InfoWin.cpp

示例9: file

/*=============================================================================================*\
|	FetchBitmap																					|
+-----------------------------------------------------------------------------------------------+
|	Effet: Converie une image en un BBitmap. La couleur de transparence est celle du pixel dans	|
|			le coin superieur gauche.															|
|	Entree:																						|
|		char *pzFileName: Le path du fichier image a convertir.									|
|		bool bTran: True si on utilise la transparence, false sinon.							|
|	Sortie:																						|
|		BBitmap *: Le pointeur le bitmap de l'image. NULL si la conversion a echouer.			|
\*=============================================================================================*/
BBitmap*
BitmapCatalog::FetchBitmap(char* pzFileName, bool bTrans) 
{ 


	BFile file(pzFileName, B_READ_ONLY); 
	BTranslatorRoster *roster = BTranslatorRoster::Default(); 
	BBitmapStream stream; 
	BBitmap *result = NULL; 
	if (roster->Translate(&file, NULL, NULL, &stream, B_TRANSLATOR_BITMAP) < B_OK) 
		return NULL; 
	stream.DetachBitmap(&result); 


//  OliverESP: 7 x 1 so -> #include <TranslationUtils.h> //OliverESP:
//			   less code and works
	//BBitmap *result = BTranslationUtils::GetBitmapFile(pzFileName);
	
	if (result == NULL)
		return NULL;

	if(!bTrans)
		return result;
	
	int32 iLenght = result->BitsLength() / 4;
	int32 i;
	int32 * cBit = (int32*)result->Bits();
	int32 backColor = cBit[result->Bounds().IntegerWidth() - 1];
	int32 iTrans = 0;
      
	//Determine le mode de definition de couleur
	switch(result->ColorSpace())
	{
	case B_RGB32:		iTrans = B_TRANSPARENT_MAGIC_RGBA32; break;
	case B_RGB32_BIG:	iTrans = B_TRANSPARENT_MAGIC_RGBA32_BIG; break;
	default:			break; //TODO: Major screwup here!
	}

	if (iTrans)
	{
		for(i = 0; i < iLenght; i++)
		{
			if(cBit[i] == backColor)
				cBit[i] = iTrans;
		}
	}

	return result; 
}
开发者ID:HaikuArchives,项目名称:WhisperBeNet,代码行数:60,代码来源:BitmapCatalog.cpp

示例10: r

static BBitmap*
CreateIcon(const BMessage* msg, icon_size which)
{

	const void* data;
	ssize_t size;
	BBitmap* bitmap = NULL;

	// See if a Haiku Vector Icon available
	if (msg->FindData(VECTOR_ICON_NAME, VECTOR_ICON_TYPE, &data,
		&size) == B_OK)  {
		BRect r(0, 0, LARGE_ICON_SIZE - 1, LARGE_ICON_SIZE - 1);
		bitmap = new BBitmap(r, B_RGBA32);
		if (BIconUtils::GetVectorIcon((const uint8*)data, size,
			bitmap) == B_OK) {
			printf("Created vector icon bitmap\n");
			return bitmap;
		} else {
			delete bitmap;
			bitmap = NULL;
		}
	}

	// If not, look for BeOS style icon
	float bmapSize;
	uint32 iconType;
	const char* iconName;

	if (which == B_LARGE_ICON) {
		bmapSize = LARGE_ICON_SIZE - 1;
		iconType = LARGE_ICON_TYPE;
		iconName = LARGE_ICON_NAME;
	} else if (which == B_MINI_ICON) {
		bmapSize = MINI_ICON_SIZE - 1;
		iconType = MINI_ICON_TYPE;
		iconName = MINI_ICON_NAME;
	} else
		return NULL;

	if (msg->FindData(iconName, iconType, &data, &size) == B_OK) {
		bitmap = new BBitmap(BRect(0, 0, bmapSize, bmapSize),
			ICON_COLOR_SPACE);
		ASSERT((bitmap->BitsLength() == size));
		memcpy(bitmap->Bits(), data, size);
	}
	return bitmap;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:47,代码来源:EndpointInfo.cpp

示例11: CreateIcon

static BBitmap* CreateIcon(const BMessage* msg, icon_size which)
{
    float iconSize;
    uint32 iconType;
    const char* iconName;

    if (which == B_LARGE_ICON) {
        iconSize = LARGE_ICON_SIZE;
        iconType = LARGE_ICON_TYPE;
        iconName = LARGE_ICON_NAME;
    } else if (which == B_MINI_ICON) {
        iconSize = MINI_ICON_SIZE;
        iconType = MINI_ICON_TYPE;
        iconName = MINI_ICON_NAME;
    } else {
        return NULL;
    }

    const void* data;
    ssize_t size;
    BBitmap* bitmap = NULL;

#ifdef __ANTARES__
    iconSize = LARGE_ICON_SIZE;

    if (msg->FindData(VECTOR_ICON_NAME, VECTOR_ICON_TYPE, &data,
                      &size) == B_OK)  {
        BRect r(0, 0, iconSize-1, iconSize-1);
        bitmap = new BBitmap(r, B_RGBA32);
        if (BIconUtils::GetVectorIcon((const uint8*)data, size,
                                      bitmap) == B_OK) {
            printf("Created vector icon bitmap\n");
            return bitmap;
        } else
            delete bitmap;
    }
#endif

    if (msg->FindData(iconName, iconType, &data, &size) == B_OK)
    {
        BRect r(0, 0, iconSize-1, iconSize-1);
        bitmap = new BBitmap(r, ICON_COLOR_SPACE);
        ASSERT((bitmap->BitsLength() == size));
        memcpy(bitmap->Bits(), data, size);
    }
    return bitmap;
}
开发者ID:mmanley,项目名称:Antares,代码行数:47,代码来源:EndpointInfo.cpp

示例12: 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

示例13: file

/*=============================================================================================*\
|	FetchBitmap																					|
+-----------------------------------------------------------------------------------------------+
|	Effet: Converie une image en un BBitmap. La couleur de transparence est celle du pixel dans	|
|			le coin superieur gauche.															|
|	Entree:																						|
|		char *pzFileName: Le path du fichier image a convertir.									|
|		bool bTran: True si on utilise la transparence, false sinon.							|
|	Sortie:																						|
|		BBitmap *: Le pointeur le bitmap de l'image. NULL si la conversion a echouer.			|
\*=============================================================================================*/
BBitmap * BeNetBitmapCatalog::FetchBitmap(char *pzFileName, bool bTrans) 
{ 
      BFile file(pzFileName, B_READ_ONLY); 
      BTranslatorRoster *roster = BTranslatorRoster::Default(); 
      BBitmapStream stream; 
      BBitmap *result = NULL; 
      if (roster->Translate(&file, NULL, NULL, &stream, 
            B_TRANSLATOR_BITMAP) < B_OK) 
         return NULL; 
      stream.DetachBitmap(&result); 
            
      
      if(!bTrans) return result;
      int32 iLenght = result->BitsLength() / 4;
      int32 i;
      int32 * cBit = (int32)result->Bits();
      int32 backColor = cBit[result->Bounds().IntegerWidth() - 1];
      int32 iTrans = 0;
      
      //Determine le mode de definition de couleur
      switch(result->ColorSpace())
      {
      		case B_RGB32:{
      				iTrans = B_TRANSPARENT_MAGIC_RGBA32;
      			}break;
      		case B_RGB32_BIG:{
      				iTrans = B_TRANSPARENT_MAGIC_RGBA32_BIG;
      			}break;
       }
      
      if(iTrans)
      {
     	for(i = 0; i < iLenght; i++)
      	{
      		if(cBit[i] == backColor)
      		{
     			cBit[i] = B_TRANSPARENT_MAGIC_RGBA32_BIG;
      		}
      	}
      }
      
      return result; 
}//Fin de FetchBitmap.
开发者ID:BackupTheBerlios,项目名称:dengon-svn,代码行数:54,代码来源:BeNetBitmapCatalog.cpp

示例14:

void
RemoteMessage::AddBitmap(const BBitmap& bitmap)
{
	BRect bounds = bitmap.Bounds();
	Add(bounds.IntegerWidth() + 1);
	Add(bounds.IntegerHeight() + 1);
	Add(bitmap.BytesPerRow());
	Add(bitmap.ColorSpace());
	Add(bitmap.Flags());

	uint32 bitsLength = bitmap.BitsLength();
	Add(bitsLength);

	if (!_MakeSpace(bitsLength))
		return;

	memcpy(fBuffer + fWriteIndex, bitmap.Bits(), bitsLength);
	fWriteIndex += bitsLength;
	fAvailable -= bitsLength;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:20,代码来源:RemoteMessage.cpp

示例15:

BBitmap::BBitmap(const BBitmap& source, uint32 flags)
	:
	fBasePointer(NULL),
	fSize(0),
	fColorSpace(B_NO_COLOR_SPACE),
	fBounds(0, 0, -1, -1),
	fBytesPerRow(0),
	fWindow(NULL),
	fServerToken(-1),
	fAreaOffset(-1),
	fArea(-1),
	fServerArea(-1),
	fFlags(0),
	fInitError(B_NO_INIT)
{
	if (!source.IsValid())
		return;

	_InitObject(source.Bounds(), source.ColorSpace(), flags,
		source.BytesPerRow(), B_MAIN_SCREEN_ID);

	if (InitCheck() == B_OK)
		memcpy(Bits(), source.Bits(), min_c(BitsLength(), source.BitsLength()));
}
开发者ID:orangejua,项目名称:haiku,代码行数:24,代码来源:Bitmap.cpp


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