本文整理汇总了C++中BBitmap::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ BBitmap::Unlock方法的具体用法?C++ BBitmap::Unlock怎么用?C++ BBitmap::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBitmap
的用法示例。
在下文中一共展示了BBitmap::Unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: _updateBitmap
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;
}
示例3: BBitmap
static BBitmap*
MakeActuatorBitmap(bool lit)
{
BBitmap* map = new BBitmap(ICON_BITMAP_RECT, ICON_BITMAP_SPACE, true);
const rgb_color yellow = {255, 255, 0};
const rgb_color red = {200, 200, 200};
const rgb_color black = {0, 0, 0};
const BPoint points[10] = {
BPoint(8, 0), BPoint(9.8, 5.8), BPoint(16, 5.8),
BPoint(11, 9.0), BPoint(13, 16), BPoint(8, 11),
BPoint(3, 16), BPoint(5, 9.0), BPoint(0, 5.8),
BPoint(6.2, 5.8) };
BView* view = new BView(BRect(0, 0, 16, 16), NULL, B_FOLLOW_ALL_SIDES, 0L);
map->AddChild(view);
map->Lock();
view->SetHighColor(B_TRANSPARENT_32_BIT);
view->FillRect(ICON_BITMAP_RECT);
view->SetHighColor(lit ? yellow : red);
view->FillPolygon(points, 10);
view->SetHighColor(black);
view->StrokePolygon(points, 10);
map->Unlock();
map->RemoveChild(view);
delete view;
return map;
}
示例4: rect
HSPictureButton::HSPictureButton(BRect frame, BBitmap* off, BBitmap* on,
BMessage* message, const char* helpMessage, const char* longHelpMessage,
uint32 behavior, uint32 mode, uint32 flags)
: BPictureButton(frame, "?", NULL, NULL, message, behavior, mode, flags)
, fLongHelpMessage(longHelpMessage)
{
if (helpMessage)
SetToolTip(helpMessage);
BRect rect(0, 0, 0, 0);
BBitmap* offScreen = new BBitmap(rect, B_RGB_32_BIT, true);
BView* offView = new BView(rect, "", B_FOLLOW_ALL, 0);
offScreen->AddChild(offView);
offScreen->Lock();
offView->SetHighColor(255, 0, 0);
offView->SetLowColor(0, 0, 120);
offView->SetDrawingMode(B_OP_COPY);
offView->BeginPicture(new BPicture());
offView->DrawBitmap(on, BPoint(0, 0));
SetEnabledOn(offView->EndPicture());
offView->BeginPicture(new BPicture());
offView->DrawBitmap(off, BPoint(0, 0));
SetEnabledOff(offView->EndPicture());
offScreen->Unlock();
delete offScreen;
}
示例5: Draw
void CounterView::Draw (BRect updateRect)
{
BRect MovingRect (
m_MovingDotPoint.x,
m_MovingDotPoint.y,
m_MovingDotPoint.x + m_MovingDotSize,
m_MovingDotPoint.y + m_MovingDotSize);
char TempString [40];
if (m_BackingBitmap != NULL)
{
m_BackingBitmap->Lock ();
m_BackingView.SetHighColor (60, 60, 255, 8);
m_BackingView.FillRect (m_BndRect);
m_BackingView.SetHighColor (255, 255, 0, 255);
m_BackingView.MovePenTo (m_TextStartPoint);
sprintf (TempString, "%d", m_CurrentCount);
m_BackingView.DrawString (TempString);
m_BackingView.FillRect (MovingRect);
m_BackingView.Sync ();
m_BackingBitmap->Unlock ();
MovePenTo (0, 0);
DrawBitmap (m_BackingBitmap);
}
}
示例6: FillRect
void BochsView::FillRect(BRect r, pattern p)
{
backing_store->Lock();
backing_view->FillRect(r,p);
backing_store->Unlock();
Invalidate(r);
}
示例7: make_bitmap
BBitmap* SwatchView::make_bitmap(void)
{
BRect rect(0.0, 0.0, 12.0, 12.0);
BBitmap *bitmap = new BBitmap(rect, B_RGB32, true);
BView *view = new BView(rect, "", B_FOLLOW_NONE, B_WILL_DRAW);
bitmap->Lock();
bitmap->AddChild(view);
view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(m_color);
view->FillRect(rect);
view->SetDrawingMode(B_OP_COPY);
view->SetHighColor(0, 0, 0, 255);
view->StrokeRect(rect);
view->Sync();
bitmap->RemoveChild(view);
delete view;
bitmap->Unlock();
return bitmap;
}
示例8: BView
/***********************************************************
* Make disable state picture.
***********************************************************/
BPicture*
HToolbarButton::MakeDisablePicture(BBitmap *in)
{
HToolbar *toolbar = cast_as(Parent(),HToolbar);
BRect buttonRect = toolbar->ButtonRect();
BView *view = new BView(BRect(0,0,buttonRect.Width(),buttonRect.Height())
,"offview",0,0);
BBitmap *bitmap = new BBitmap(view->Bounds(), in->ColorSpace(), true);
BPicture *pict;
bitmap->AddChild(view);
bitmap->Lock();
view->BeginPicture(new BPicture);
view->SetHighColor(bgcolor);
view->FillRect(view->Bounds());
DrawString(view,fName.String(),false,false);
view->SetDrawingMode(B_OP_BLEND);
DrawBitmap(view,in);
pict = view->EndPicture();
bitmap->Unlock();
delete bitmap;
return pict;
}
示例9: CreateIcon
BBitmap* MainView::CreateIcon(const rgb_color colorIn)
{
BRect rect(0, 0, 15, 15);
BBitmap* toReturn = new BBitmap(rect, B_CMAP8, true);
BView* drawing = new BView(rect,
"drawer",
B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW);
if (!drawing || !toReturn) { return NULL; }
toReturn->AddChild(drawing);
if (toReturn->Lock()) {
drawing->SetHighColor(kWhite);
drawing->FillRect(rect);
drawing->SetHighColor(kBlack);
drawing->SetPenSize(1);
drawing->StrokeRect(rect);
drawing->SetHighColor(colorIn);
drawing->FillRect(rect.InsetBySelf(1, 1));
drawing->Sync();
toReturn->Unlock();
}
toReturn->RemoveChild(drawing);
delete drawing;
return toReturn;
}
示例10: 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;
}
示例11: CreateIcon
/*!
* \brief Create the square icon filled with submitted color.
* \param[in] color The color of the requested icon.
* \param[in] toChange If there is an allocated item, it may be changed.
* If the submitted pointer is not NULL (which is default),
* this BBitmap is tested for dimensions match, and if dimensions
* allow, its contents are replaced with new icon. Else, old icon
* is deleted, and a new is created. In this case, both the
* "toChange" pointer and returned pointer point to the same
* BBitmap.
*/
BBitmap* CategoryMenuItem::CreateIcon(const rgb_color colorIn, BBitmap* toChange )
{
font_height fh;
BFont plainFont( be_plain_font );
plainFont.GetHeight( &fh );
int squareSize = ceilf( fh.ascent + fh.descent + fh.leading - 2 ); //!< Side of the square.
BRect rect(0, 0, squareSize, squareSize );
BBitmap* toReturn = NULL;
if ( !toChange ) // Checking availability of the input
{
toReturn = new BBitmap(rect, B_RGB32, true);
} else {
// It would be a good idea to check also the color space,
// but it may be changed by the BBitmap itself, so...
if ( ceilf ( ( toChange->Bounds() ).Width() ) != squareSize )
{
delete toChange;
toChange = new BBitmap(rect, B_RGB32, true);
if ( !toChange )
{
/* Panic! */
exit(1);
}
}
toReturn = toChange;
}
BView* drawing = new BView( rect,
"Drawer",
B_FOLLOW_LEFT | B_FOLLOW_TOP,
B_WILL_DRAW);
if (!drawing || !toReturn) { return NULL; }
toReturn->AddChild(drawing);
if (toReturn->Lock()) {
// Clean the area
drawing->SetHighColor( ui_color( B_DOCUMENT_BACKGROUND_COLOR ) );
drawing->FillRect(rect);
// Draw the black square
drawing->SetHighColor( ui_color( B_DOCUMENT_TEXT_COLOR ) );
drawing->SetPenSize(1);
drawing->StrokeRect(rect);
// Fill the inside of the square
drawing->SetHighColor( colorIn );
drawing->FillRect(rect.InsetBySelf(1, 1));
// Flush the actions to BBitmap
drawing->Sync();
toReturn->Unlock();
}
toReturn->RemoveChild(drawing); // Cleanup
delete drawing;
return toReturn;
} // <-- end of function CategoryMenuItem::CreateIcon
示例12: DrawBitmap
void BochsView::DrawBitmap(const BBitmap *aBitmap, BPoint where)
{
backing_store->Lock();
backing_view->DrawBitmap(aBitmap,where);
backing_store->Unlock();
BRect r = aBitmap->Bounds();
r.OffsetBy(where);
Invalidate(r);
}
示例13: message
void
IconView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
{
if (fTracking && !fDragging && fIcon != NULL
&& (abs((int32)(where.x - fDragPoint.x)) > 3
|| abs((int32)(where.y - fDragPoint.y)) > 3)) {
// Start drag
BMessage message(B_SIMPLE_DATA);
::Icon* icon = fIconData;
if (fHasRef || fHasType) {
icon = new ::Icon;
if (fHasRef)
icon->SetTo(fRef, fType.Type());
else if (fHasType)
icon->SetTo(fType);
}
icon->CopyTo(message);
if (icon != fIconData)
delete icon;
BBitmap *dragBitmap = new BBitmap(fIcon->Bounds(), B_RGBA32, true);
dragBitmap->Lock();
BView *view
= new BView(dragBitmap->Bounds(), B_EMPTY_STRING, B_FOLLOW_NONE, 0);
dragBitmap->AddChild(view);
view->SetHighColor(B_TRANSPARENT_COLOR);
view->FillRect(dragBitmap->Bounds());
view->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
view->SetDrawingMode(B_OP_ALPHA);
view->SetHighColor(0, 0, 0, 160);
view->DrawBitmap(fIcon);
view->Sync();
dragBitmap->Unlock();
DragMessage(&message, dragBitmap, B_OP_ALPHA,
fDragPoint - BitmapRect().LeftTop(), this);
fDragging = true;
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
}
if (dragMessage != NULL && !fDragging && AcceptsDrag(dragMessage)) {
bool dropTarget = transit == B_ENTERED_VIEW || transit == B_INSIDE_VIEW;
if (dropTarget != fDropTarget) {
fDropTarget = dropTarget;
Invalidate();
}
} else if (fDropTarget) {
fDropTarget = false;
Invalidate();
}
}
示例14: rect
BBitmap *DragonView::_MakeDragBitmap( void )
{
// If the currently displayed bitmap is too large to drag around,
// we'll just drag around a rectangle.
BRect drag_rect = _bits->Bounds();
if( drag_rect.Width() > _drag_max_size.x ||
drag_rect.Height() > _drag_max_size.y ) return NULL;
// If we've got a PNG image, we'll assume that it's got
// "interesting" alpha information. The ones that are built
// into DragonDrop's resources all have "interesting" alpha
// channels.
if( _image_is_png ) {
BBitmap *drag_me = new BBitmap( _bits );
memcpy( drag_me->Bits(), _bits->Bits(), _bits->BitsLength() );
return drag_me;
}
// If you've made it here, we'll need to build a semi-transparent image
// to drag around. This magic is from Pavel Cisler, and it ensures that
// you've got a drag bitmap that's translucent.
BRect rect( _bits->Bounds() );
BBitmap *bitmap = new BBitmap( rect, B_RGBA32, true );
BView *view = new BView( rect, "drag view", B_FOLLOW_NONE, 0 );
bitmap->Lock();
bitmap->AddChild( view );
BRegion new_clip;
new_clip.Set( rect );
view->ConstrainClippingRegion( &new_clip );
view->SetHighColor( 0, 0, 0, 0 );
view->FillRect( rect );
view->SetDrawingMode( B_OP_ALPHA );
view->SetHighColor( 0, 0, 0, 128 );
view->SetBlendingMode( B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE );
view->DrawBitmap( _bits );
view->Sync();
bitmap->Unlock();
return bitmap;
}
示例15: rect
/*
* Make inside state picture.
*/
BPicture*
HToolbarButton::MakeInsidePicture(BBitmap *in)
{
HToolbar *toolbar = cast_as(Parent(),HToolbar);
BRect buttonRect = toolbar->ButtonRect();
BView *view = new BView(BRect(0,0,buttonRect.Width(),buttonRect.Height())
,"offview",0,0);
BBitmap *bitmap = new BBitmap(view->Bounds(), in->ColorSpace(), true);
BPicture *pict;
bitmap->AddChild(view);
bitmap->Lock();
view->SetDrawingMode(B_OP_ALPHA);
view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
view->BeginPicture(new BPicture);
DrawBitmap(view,in);
DrawString(view,fName.String());
//view->SetHighColor(White);
//view->FillRect(BRect(0,0,0,22));
//view->FillRect(BRect(0,0,22,0));
//view->SetHighColor(BeShadow);
//view->FillRect(BRect(21,0,21,21));
//view->FillRect(BRect(0,21,21,21));
BRect rect(Bounds());
view->SetDrawingMode(B_OP_OVER);
rect.InsetBy(1,1);
view->BeginLineArray(5);
view->AddLine(rect.LeftTop(), rect.LeftBottom(),
tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT));
view->AddLine(rect.LeftTop(), rect.RightTop(),
tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT));
view->AddLine(rect.LeftBottom(), rect.RightBottom(),
tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
rect.bottom--;
view->AddLine(rect.LeftBottom(), rect.RightBottom(),
tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
view->AddLine(rect.RightTop(), rect.RightBottom(),
tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
view->EndLineArray();
view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
view->StrokeRect(Bounds());
pict = view->EndPicture();
bitmap->Unlock();
delete bitmap;
return pict;
}