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


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

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


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

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

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

status_t MesaDriver::CopyPixelsIn(BBitmap *bitmap, BPoint location)
{
	color_space scs = bitmap->ColorSpace();
	color_space dcs = m_bitmap->ColorSpace();

	if (scs != dcs && (dcs != B_RGBA32 || scs != B_RGB32)) {
		printf("CopyPixelsIn(): incompatible color space: %s != %s\n",
			color_space_name(scs),
			color_space_name(dcs));
		return B_BAD_TYPE;
	}
	
	// debugger("CopyPixelsIn()");

	BRect sr = bitmap->Bounds();
	BRect dr = m_bitmap->Bounds();

	sr = sr & dr.OffsetBySelf(location);
	dr = sr.OffsetByCopy(-location.x, -location.y); 
	
	uint8 *ps = (uint8 *) bitmap->Bits();
	uint8 *pd = (uint8 *) m_bitmap->Bits();
	uint32 *s, *d;
	uint32 y;
	for (y = (uint32) sr.top; y <= (uint32) sr.bottom; y++) {
		s = (uint32 *) (ps + y * bitmap->BytesPerRow());
		s += (uint32) sr.left;
		
		d = (uint32 *) (pd + (y + (uint32) (dr.top - sr.top)) * m_bitmap->BytesPerRow());
		d += (uint32) dr.left;
		
		memcpy(d, s, dr.IntegerWidth() * 4);
	}
	return B_OK;
}
开发者ID:MttDs,项目名称:new-rexeno-tindpe,代码行数:35,代码来源:GLView.cpp

示例4:

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

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

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

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

示例8:

void
MesaSoftwareRenderer::_ClearFront(gl_context* ctx)
{
	CALLED();

	MesaSoftwareRenderer* mr = (MesaSoftwareRenderer*)ctx->DriverCtx;
	BGLView* bglview = mr->GLView();
	assert(bglview);
	BBitmap* bitmap = mr->fBitmap;
	assert(bitmap);
	GLuint* start = (GLuint*)bitmap->Bits();
	size_t pixelSize = 0;
	get_pixel_size_for(bitmap->ColorSpace(), &pixelSize, NULL, NULL);
	const GLuint* clearPixelPtr = (const GLuint*)mr->fClearColor;
	const GLuint clearPixel = B_LENDIAN_TO_HOST_INT32(*clearPixelPtr);

	int x = ctx->DrawBuffer->_Xmin;
	int y = ctx->DrawBuffer->_Ymin;
	uint32 width = ctx->DrawBuffer->_Xmax - x;
	uint32 height = ctx->DrawBuffer->_Ymax - y;
	GLboolean all = (width == ctx->DrawBuffer->Width
		&& height == ctx->DrawBuffer->Height);

	if (all) {
		const int numPixels = mr->fWidth * mr->fHeight;
		if (clearPixel == 0) {
			memset(start, 0, numPixels * pixelSize);
		} else {
			for (int i = 0; i < numPixels; i++) {
				start[i] = clearPixel;
			}
		}
	} else {
		// XXX untested
		start += y * mr->fWidth + x;
		for (uint32 i = 0; i < height; i++) {
			for (uint32 j = 0; j < width; j++) {
				start[j] = clearPixel;
			}
			start += mr->fWidth;
		}
	}
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:43,代码来源:MesaSoftwareRenderer.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 * 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

示例10:

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

示例11: r

void
BIconButton::Draw(BRect updateRect)
{
	rgb_color background;
	if (fCustomBackground)
		background = {120,120,120};
	else
		background = LowColor();

	BRect r(Bounds());

	uint32 flags = 0;
	BBitmap* bitmap = fNormalBitmap;
	if (!IsEnabled()) {
		flags |= BControlLook::B_DISABLED;
		bitmap = fDisabledBitmap;
	}
	if (_HasFlags(STATE_PRESSED) || _HasFlags(STATE_FORCE_PRESSED))
		flags |= BControlLook::B_ACTIVATED;

	if (ShouldDrawBorder()) {
		DrawBorder(r, updateRect, background, flags);
		DrawBackground(r, updateRect, background, flags);
	} else {
		SetHighColor(background);
		FillRect(r);
	}

	if (bitmap && bitmap->IsValid()) {
		if (bitmap->ColorSpace() == B_RGBA32
			|| bitmap->ColorSpace() == B_RGBA32_BIG) {
			SetDrawingMode(B_OP_ALPHA);
			SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		}
		float x = r.left + floorf((r.Width()
			- bitmap->Bounds().Width()) / 2.0 + 0.5);
		float y = r.top + floorf((r.Height()
			- bitmap->Bounds().Height()) / 2.0 + 0.5);
		DrawBitmap(bitmap, BPoint(x, y));
	}
}
开发者ID:Barrett17,项目名称:Faber,代码行数:41,代码来源:IconButton.cpp

示例12: new

BBitmap*
BIconButton::Bitmap() const
{
	BBitmap* bitmap = NULL;
	if (fNormalBitmap && fNormalBitmap->IsValid()) {
		bitmap = new(std::nothrow) BBitmap(fNormalBitmap);
		if (bitmap != NULL && bitmap->IsValid()) {
			// TODO: remove this functionality when we use real transparent
			// bitmaps
			uint8* bits = (uint8*)bitmap->Bits();
			uint32 bpr = bitmap->BytesPerRow();
			uint32 width = bitmap->Bounds().IntegerWidth() + 1;
			uint32 height = bitmap->Bounds().IntegerHeight() + 1;
			color_space format = bitmap->ColorSpace();
			if (format == B_CMAP8) {
				// replace gray with magic transparent index
			} else if (format == B_RGB32) {
				for (uint32 y = 0; y < height; y++) {
					uint8* bitsHandle = bits;
					for (uint32 x = 0; x < width; x++) {
						if (bitsHandle[0] == 216
							&& bitsHandle[1] == 216
							&& bitsHandle[2] == 216) {
							// make this pixel completely transparent
							bitsHandle[3] = 0;
						}
						bitsHandle += 4;
					}
					bits += bpr;
				}
			}
		} else {
			delete bitmap;
			bitmap = NULL;
		}
	}
	return bitmap;
}
开发者ID:Barrett17,项目名称:Faber,代码行数:38,代码来源:IconButton.cpp

示例13:

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

示例14: GetDestImage

void
Scaler::Dither(int32 fromRow, int32 toRow)
{
	BBitmap* src;
	BBitmap* dest;
	intType destW;
	intType x, y;

	uchar* srcBits;
	intType srcBPR;
	uchar* srcDataRow;
	uchar* srcData;

	uchar* destBits;
	intType destBPR;
	uchar* destDataRow;
	uchar* destData;
	const int32 kBPP = 4;
	DitheringColumnData* columnData0;
	DitheringColumnData* columnData;
	DitheringColumnData* cd;
	BScreen screen;
	intType error[3], err[3];

	src = fScaledImage;
	dest = GetDestImage();

	ASSERT(src->ColorSpace() == B_RGB32 || src->ColorSpace() == B_RGBA32);
	ASSERT(dest->ColorSpace() == B_CMAP8);
	ASSERT(src->Bounds().IntegerWidth() == dest->Bounds().IntegerWidth());
	ASSERT(src->Bounds().IntegerHeight() == dest->Bounds().IntegerHeight());

	destW = dest->Bounds().IntegerWidth();

	srcBits = (uchar*)src->Bits();
	srcBPR = src->BytesPerRow();
	destBits = (uchar*)dest->Bits();
	destBPR = dest->BytesPerRow();

	// Allocate space for sentinel at left and right bounds,
	// so that columnData[-1] and columnData[destW+1] can be safely accessed
	columnData0 = new DitheringColumnData[destW+3];
	columnData = columnData0 + 1;

	// clear error
	cd = columnData;
	for (x = destW; x >= 0; x --, cd ++) {
		cd->error[0] = cd->error[1] = cd->error[2] =0;
	}

	srcDataRow = srcBits + fromRow * srcBPR;
	destDataRow = destBits + fromRow * destBPR;
	for (y = fromRow; IsRunning() && y <= toRow; y ++, srcDataRow += srcBPR, destDataRow += destBPR) {
		// left to right
		error[0] = error[1] = error[2] = 0;
		srcData = srcDataRow;
		destData = destDataRow;
		for (x = 0; x <= destW; x ++, srcData += kBPP, destData += 1) {
			rgb_color color, actualColor;
			uint8 index;

			color.red = Limit(srcData[2] + error[0] / 16);
			color.green = Limit(srcData[1] + error[1] / 16);
			color.blue = Limit(srcData[0] + error[2] / 16);

			index = screen.IndexForColor(color);
			actualColor = screen.ColorForIndex(index);

			*destData = index;

			err[0] = color.red - actualColor.red;
			err[1] = color.green -actualColor.green;
			err[2] = color.blue -actualColor.blue;

			// distribute error
			// get error for next pixel
			cd = &columnData[x+1];
			error[0] = cd->error[0] + 7 * err[0];
			error[1] = cd->error[1] + 7 * err[1];
			error[2] = cd->error[2] + 7 * err[2];

			// set error for right pixel below current pixel
			cd->error[0] = err[0];
			cd->error[1] = err[1];
			cd->error[2] = err[2];

			// add error for pixel below current pixel
			cd --;
			cd->error[0] += 5 * err[0];
			cd->error[1] += 5 * err[1];
			cd->error[2] += 5 * err[2];

			// add error for left pixel below current pixel
			cd --;
			cd->error[0] += 3 * err[0];
			cd->error[1] += 3 * err[1];
			cd->error[2] += 3 * err[2];
		}
		// Note: Alogrithm has good results with "left to right" already
		// Optionally remove code to end of block:
//.........这里部分代码省略.........
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:101,代码来源:Filter.cpp

示例15: r

// Draw
void
IconButton::Draw(BRect area)
{
    rgb_color background = LowColor();
    if (MView* parent = dynamic_cast<MView*>(Parent()))
        background = parent->getcolor();
    rgb_color lightShadow, shadow, darkShadow, light;
    BRect r(Bounds());
    BBitmap* bitmap = fNormalBitmap;
    // adjust colors and bitmap according to flags
    if (IsEnabled()) {
        lightShadow = tint_color(background, B_DARKEN_1_TINT);
        shadow = tint_color(background, B_DARKEN_2_TINT);
        darkShadow = tint_color(background, B_DARKEN_4_TINT);
        light = tint_color(background, B_LIGHTEN_MAX_TINT);
        SetHighColor(0, 0, 0, 255);
    } else {
        lightShadow = tint_color(background, 1.11);
        shadow = tint_color(background, B_DARKEN_1_TINT);
        darkShadow = tint_color(background, B_DARKEN_2_TINT);
        light = tint_color(background, B_LIGHTEN_2_TINT);
        bitmap = fDisabledBitmap;
        SetHighColor(tint_color(background, B_DISABLED_LABEL_TINT));
    }
    if (_HasFlags(STATE_PRESSED) || _HasFlags(STATE_FORCE_PRESSED)) {
        if (IsEnabled())  {
//			background = tint_color(background, B_DARKEN_2_TINT);
//			background = tint_color(background, B_LIGHTEN_1_TINT);
            background = tint_color(background, B_DARKEN_1_TINT);
            bitmap = fClickedBitmap;
        } else {
//			background = tint_color(background, B_DARKEN_1_TINT);
//			background = tint_color(background, (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0);
            background = tint_color(background, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
            bitmap = fDisabledClickedBitmap;
        }
        // background
        SetLowColor(background);
        r.InsetBy(2.0, 2.0);
        StrokeLine(r.LeftBottom(), r.LeftTop(), B_SOLID_LOW);
        StrokeLine(r.LeftTop(), r.RightTop(), B_SOLID_LOW);
        r.InsetBy(-2.0, -2.0);
    }
    // draw frame only if tracking
    if (DrawBorder()) {
        if (_HasFlags(STATE_PRESSED) || _HasFlags(STATE_FORCE_PRESSED))
            DrawPressedBorder(r, background, shadow, darkShadow, lightShadow, light);
        else
            DrawNormalBorder(r, background, shadow, darkShadow, lightShadow, light);
        r.InsetBy(2.0, 2.0);
    } else
        _DrawFrame(r, background, background, background, background);
    float width = Bounds().Width();
    float height = Bounds().Height();
    // bitmap
    BRegion originalClippingRegion;
    if (bitmap && bitmap->IsValid()) {
        float x = floorf((width - bitmap->Bounds().Width()) / 2.0 + 0.5);
        float y = floorf((height - bitmap->Bounds().Height()) / 2.0 + 0.5);
        BPoint point(x, y);
        if (_HasFlags(STATE_PRESSED) || _HasFlags(STATE_FORCE_PRESSED))
            point += BPoint(1.0, 1.0);
        if (bitmap->ColorSpace() == B_RGBA32 || bitmap->ColorSpace() == B_RGBA32_BIG) {
            FillRect(r, B_SOLID_LOW);
            SetDrawingMode(B_OP_ALPHA);
            SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
        }
        DrawBitmap(bitmap, point);
        // constrain clipping region
        BRegion region= originalClippingRegion;
        GetClippingRegion(&region);
        region.Exclude(bitmap->Bounds().OffsetByCopy(point));
        ConstrainClippingRegion(&region);
    }
    // background
    SetDrawingMode(B_OP_COPY);
    FillRect(r, B_SOLID_LOW);
    ConstrainClippingRegion(&originalClippingRegion);
    // label
    if (fLabel.CountChars() > 0) {
        SetDrawingMode(B_OP_COPY);
        font_height fh;
        GetFontHeight(&fh);
        float y = Bounds().bottom - 4.0;
        y -= fh.descent;
        float x = (width - StringWidth(fLabel.String())) / 2.0;
        DrawString(fLabel.String(), BPoint(x, y));
    }
}
开发者ID:mmanley,项目名称:Antares,代码行数:90,代码来源:IconButton.cpp


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