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


C++ BBitmap类代码示例

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


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

示例1: BBitmap

 //------------------------------------------------------------------------
 bool platform_support::create_img(unsigned idx, unsigned width, unsigned height)
 {
     if(idx < max_images)
     {
         if(width  == 0) width  = m_specific->fApp->Window()->View()->Bitmap()->Bounds().IntegerWidth() + 1;
         if(height == 0) height = m_specific->fApp->Window()->View()->Bitmap()->Bounds().IntegerHeight() + 1;
         BBitmap* bitmap = new BBitmap(BRect(0.0, 0.0, width - 1, height - 1), 0, B_RGBA32);;
         if (bitmap && bitmap->IsValid()) {
             delete m_specific->fImages[idx];
             m_specific->fImages[idx] = bitmap;
             attach_buffer_to_BBitmap(m_rbuf_img[idx], bitmap, m_flip_y);
             return true;
         } else {
             delete bitmap;
         }
     }
     return false;
 }
开发者ID:4over7,项目名称:matplotlib,代码行数:19,代码来源:agg_platform_support.cpp

示例2: Bounds

void
PictureView::Draw(BRect updateRect)
{
	BRect rect = Bounds();

	// Draw the outer frame
	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	if (IsFocus() && Window() && Window()->IsActive())
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
	else
		SetHighColor(tint_color(base, B_DARKEN_3_TINT));
	StrokeRect(rect);

	if (fFocusChanging) {
		// focus frame is already redraw, stop here
		return;
	}

	BBitmap* picture = fPicture ? fPicture : fDefaultPicture;
	if (picture != NULL) {
		// scale to fit and center picture in frame
		BRect frame = rect.InsetByCopy(kPictureMargin, kPictureMargin);
		BRect srcRect = picture->Bounds();
		BSize size = frame.Size();
		if (srcRect.Width() > srcRect.Height())
			size.height = srcRect.Height() * size.width / srcRect.Width();
		else
			size.width = srcRect.Width() * size.height / srcRect.Height();

		fPictureRect = BLayoutUtils::AlignInFrame(frame, size,
			BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));

		SetDrawingMode(B_OP_ALPHA);
		if (picture == fDefaultPicture) {
			SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
			SetHighColor(0, 0, 0, 24);
		}

 		DrawBitmapAsync(picture, srcRect, fPictureRect,
 			B_FILTER_BITMAP_BILINEAR);

		SetDrawingMode(B_OP_OVER);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:44,代码来源:PictureView.cpp

示例3: strcpy

BBitmap *bitmap (char *title)
{
	strcpy (title, "Grabbed");
	BBitmap *b = new BBitmap (BRect (0, 0, 127, 127), B_RGB_32_BIT, true);
	BView *v = new BView (BRect (0, 0, 127, 127), "bg", 0, 0);
	b->Lock();
	b->AddChild (v);
	rgb_color fg, bg;
	fg.red = 255; fg.green = 255; fg.blue = 255; fg.alpha = 255;
	bg.red = 0;   bg.green = 0;   bg.blue = 0;   bg.alpha = 127;
	v->SetHighColor (fg);
	v->SetLowColor (bg);
	v->FillRect (BRect (0, 0, 127, 127), B_MIXED_COLORS);
	v->Sync();
	b->RemoveChild (v);
	b->Unlock();
	delete v;
	return (b);
}
开发者ID:gedrin,项目名称:Becasso,代码行数:19,代码来源:CaptureTest.cpp

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

示例5: printf

void
PreviewView::UpdateBitmap()
{
	if (Window() == NULL)
		printf("window is null\n");
	if (fChanged && Window() != NULL) {
		BBitmap *bitmap;
		fChanged = false;
		BScreen screen(Window());
		screen.GetBitmap(&bitmap, false, &fCoordRect);		
	
		if (bitmap != NULL) {
			fBitmapView->SetViewBitmap(bitmap, bitmap->Bounds(),
				fBitmapView->Bounds(),
				B_FOLLOW_TOP|B_FOLLOW_LEFT, 0);
			Invalidate();
		}
	}
}
开发者ID:jscipione,项目名称:BeScreenCapture,代码行数:19,代码来源:PreviewView.cpp

示例6: CALLED

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

示例7: ScaleRectToFit

void
BitmapView::ConstrainBitmap(void)
{
	if (!fBitmap || fMaxWidth < 1 || fMaxHeight < 1)
		return;
	
	BRect r = ScaleRectToFit(fBitmap->Bounds(), BRect(0, 0, fMaxWidth - 1, fMaxHeight - 1));
	r.OffsetTo(0, 0);
	
	BBitmap *scaled = new BBitmap(r, fBitmap->ColorSpace(), true);
	BView *view = new BView(r, "drawview", 0, 0);
	
	scaled->Lock();
	scaled->AddChild(view);
	view->DrawBitmap(fBitmap, fBitmap->Bounds(), scaled->Bounds());
	scaled->Unlock();
	
	delete fBitmap;
	fBitmap = new BBitmap(scaled, false);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:20,代码来源:BitmapView.cpp

示例8: LowColor

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

示例9: DrawItem

void ContactItem::DrawItem(BView *owner, BRect itemRect, bool drawEverything)
{
	BString name = m_contact->FriendlyName();
	Status *status = m_contact->GetStatus();
	//draw status icon
	BBitmap *statusBitmap = status->GetStatusIcon();
	
	owner->SetDrawingMode(B_OP_OVER);
	float bitmapWidth = (statusBitmap->Bounds()).Width();
	BRect fillRect = itemRect;
	itemRect.left += bitmapWidth;

	//if selected
	if(IsSelected())
		owner->SetHighColor(ui_color(B_MENU_SELECTION_BACKGROUND_COLOR));
	else
		owner->SetHighColor(255,255,255);	
	owner->FillRect(fillRect);
	
	owner->SetDrawingMode(B_OP_ALPHA);
	if (statusBitmap)
		owner->DrawBitmap(statusBitmap, itemRect.LeftTop() + BPoint(0.0f,1.0f));
	
	//draw name(with emoticons)
	float textHeight = 12.0f;			
	BFont normal;
	owner->SetFont(&normal);
	owner->SetHighColor(0,0,0);
	owner->SetDrawingMode(B_OP_ALPHA);
	owner->DrawString(name.String(), itemRect.LeftTop() + BPoint(bitmapWidth + 5.0f, 1.0f + textHeight));
	//draw personal message, if available
	if (m_contact->HasPersonalMessage())
	{
		owner->DrawString(" - ");
		BFont italic;
		italic.SetFace(B_ITALIC_FACE); 
		owner->SetFont(&italic);	
		BString personalMessage = m_contact->PersonalMessage();
		owner->DrawString(personalMessage.String());
	}
}
开发者ID:HaikuArchives,项目名称:Bme,代码行数:41,代码来源:ContactItem.cpp

示例10: r

void
ShowImageWindow::_ResizeWindowToImage()
{
	BBitmap* bitmap = fImageView->Bitmap();
	BScreen screen;
	if (bitmap == NULL || !screen.IsValid())
		return;

	// TODO: use View::GetPreferredSize() instead?
	BRect r(bitmap->Bounds());
	float width = r.Width() + B_V_SCROLL_BAR_WIDTH;
	float height = r.Height() + 1 + fBar->Frame().Height()
		+ B_H_SCROLL_BAR_HEIGHT;

	BRect frame = screen.Frame();
	const float windowBorder = 5;
	// dimensions so that window does not reach outside of screen
	float maxWidth = frame.Width() + 1 - windowBorder - Frame().left;
	float maxHeight = frame.Height() + 1 - windowBorder - Frame().top;

	// We have to check size limits manually, otherwise
	// menu bar will be too short for small images.

	float minW, maxW, minH, maxH;
	GetSizeLimits(&minW, &maxW, &minH, &maxH);
	if (maxWidth > maxW)
		maxWidth = maxW;
	if (maxHeight > maxH)
		maxHeight = maxH;
	if (width < minW)
		width = minW;
	if (height < minH)
		height = minH;

	if (width > maxWidth)
		width = maxWidth;
	if (height > maxHeight)
		height = maxHeight;

	ResizeTo(width, height);
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:41,代码来源:ShowImageWindow.cpp

示例11: BitmapRect

void CounterView::FrameResized (float width, float height)
{
  BRect BitmapRect (0, 0, width, height);
  char  TempString [40];

  m_BndRect = Bounds ();

  m_MovingDotSize = (int) (height / 20);
  if (m_MovingDotSize < 1)
    m_MovingDotSize = 1;
  m_MoveSpeed = m_MovingDotSize / 2.0;
  
  // Resize the offscreen bitmap and its view.

  if (m_BackingBitmap != NULL)
  {
    m_BackingBitmap->RemoveChild (&m_BackingView);
    delete m_BackingBitmap;
    m_BackingBitmap = NULL;
  }

  m_BackingView.ResizeTo (width, height);

  m_BackingBitmap = new BBitmap (BitmapRect, B_RGBA32, true /* Accepts subviews */);
  if (!m_BackingBitmap->IsValid ())
  {
    delete m_BackingBitmap;
    m_BackingBitmap = NULL;
  }
  else
  {
    m_BackingBitmap->AddChild (&m_BackingView);
    m_BackingBitmap->Lock ();
    m_BackingView.SetDrawingMode (B_OP_ALPHA);
    m_BackingView.SetFontSize (height * 0.8);
    sprintf (TempString, "%d", m_CurrentCount);
    m_TextStartPoint.x = width / 2 - m_BackingView.StringWidth (TempString) / 2;
    m_TextStartPoint.y = height / 2 + height * 0.25;
    m_BackingBitmap->Unlock ();
  }
}
开发者ID:kallisti5,项目名称:VNCServer,代码行数:41,代码来源:UserAppMessageMonitor.cpp

示例12: file

BBitmap *GetCicnFromResource(const char *theResource)
{	
	// Get application info
	app_info info;
	
	be_app->GetAppInfo(&info);
	BFile file(&info.ref, O_RDONLY);	
	if (file.InitCheck())
		return NULL;
	
	size_t 		size;
	cicn 		*icon;
	
	BResources res; 
	status_t err; 
	if ( (err = res.SetTo(&file)) != B_NO_ERROR ) 
		return NULL;
		
	icon = (cicn *)res.FindResource('cicn', theResource, &size);
	if (!icon)			
		return NULL;
			
	// 	Swap bytes if needed.  We do this because the resources are currently
	// 	built on Macintosh BeOS
	if (B_HOST_IS_LENDIAN)
	{
		status_t retVal;
		retVal = swap_data(B_INT16_TYPE, &icon->width, sizeof(int16), B_SWAP_BENDIAN_TO_HOST);		
		retVal = swap_data(B_INT16_TYPE, &icon->height, sizeof(int16), B_SWAP_BENDIAN_TO_HOST);
	}
	
	// Get cicn bounding rect
	BRect bounds(0, 0, icon->width-1, icon->height-1);
		
	// Load bitmap
	BBitmap *bitmap = new BBitmap(bounds, B_COLOR_8_BIT);
	ASSERT(bitmap);
	bitmap->SetBits(&icon->data, size - sizeof(int16)*2, 0, B_COLOR_8_BIT);
	
	return (bitmap);	
}
开发者ID:ModeenF,项目名称:UltraDV,代码行数:41,代码来源:ResourceManager.cpp

示例13: r

void
AGGView::FrameResized(float width, float height)
{
    BRect r(0.0, 0.0, width, height);
    BBitmap* bitmap = new BBitmap(r, 0, pix_format_to_color_space(fFormat));
    if (bitmap->IsValid()) {
        delete fBitmap;
        fBitmap = bitmap;
           attach_buffer_to_BBitmap(fAGG->rbuf_window(), fBitmap, fFlipY);

        fAGG->trans_affine_resizing((int)width + 1,
                                    (int)height + 1);

        // pass the event on to AGG
        fAGG->on_resize((int)width + 1, (int)height + 1);
        
        fRedraw = true;
        Invalidate();
    } else
        delete bitmap;
}
开发者ID:Rodeo314,项目名称:vasFMC,代码行数:21,代码来源:agg_platform_support.cpp

示例14: view

BBitmap*
PictureView::_CopyPicture(uint8 alpha)
{
	bool hasAlpha = alpha != 255;

	if (!fPicture)
		return NULL;

	BRect rect = fPictureRect.OffsetToCopy(B_ORIGIN);
	BView view(rect, NULL, B_FOLLOW_NONE, B_WILL_DRAW);
	BBitmap* bitmap = new(nothrow) BBitmap(rect, hasAlpha ? B_RGBA32
		: fPicture->ColorSpace(), true);
	if (bitmap == NULL || !bitmap->IsValid()) {
		delete bitmap;
		return NULL;
	}

	if (bitmap->Lock()) {
		bitmap->AddChild(&view);
		if (hasAlpha) {
			view.SetHighColor(0, 0, 0, 0);
			view.FillRect(rect);
			view.SetDrawingMode(B_OP_ALPHA);
			view.SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
			view.SetHighColor(0, 0, 0, alpha);
		}
		view.DrawBitmap(fPicture, fPicture->Bounds().OffsetToCopy(B_ORIGIN),
			rect, B_FILTER_BITMAP_BILINEAR);
		view.Sync();
		bitmap->RemoveChild(&view);
		bitmap->Unlock();
	}

	return bitmap;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:35,代码来源:PictureView.cpp

示例15: D_METHOD

void MediaJack::_updateBitmap()
{
	D_METHOD(("MediaJack::_updateBitmap()\n"));

	if (m_bitmap)
	{
		delete m_bitmap;
	}
	BBitmap *tempBitmap = new BBitmap(Frame().OffsetToCopy(0.0, 0.0), B_CMAP8, true);
	tempBitmap->Lock();
	{
		BView *tempView = new BView(tempBitmap->Bounds(), "", B_FOLLOW_NONE, 0);
		tempBitmap->AddChild(tempView);
		tempView->SetOrigin(0.0, 0.0);

		MediaRoutingView* mediaView = dynamic_cast<MediaRoutingView*>(view());
		int32 layout = mediaView ? mediaView->getLayout() : MediaRoutingView::M_ICON_VIEW;

		_drawInto(tempView, tempView->Bounds(), layout);

		tempView->Sync();
		tempBitmap->RemoveChild(tempView);
		delete tempView;
	}
	tempBitmap->Unlock();
	m_bitmap = new BBitmap(tempBitmap);
	delete tempBitmap;
}
开发者ID:mariuz,项目名称:haiku,代码行数:28,代码来源:MediaJack.cpp


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