1 // BitmapView.cpp 2 3 #include <stdio.h> 4 5 #include <Bitmap.h> 6 7 #include "BitmapView.h" 8 9 // constructor 10 BitmapView::BitmapView(BRect frame, const char* name, 11 BBitmap* bitmap) 12 : BView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), 13 fBitmap(bitmap) 14 { 15 SetViewColor(B_TRANSPARENT_32_BIT); 16 SetHighColor(255, 0, 0, 255); 17 } 18 19 // destructor 20 BitmapView::~BitmapView() 21 { 22 delete fBitmap; 23 } 24 25 // Draw 26 void 27 BitmapView::Draw(BRect updateRect) 28 { 29 if (fBitmap) { 30 if (fBitmap->ColorSpace() == B_RGBA32) { 31 // draw the bitmap with pixel alpha 32 // against a red background 33 FillRect(updateRect); 34 SetDrawingMode(B_OP_ALPHA); 35 SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); 36 } 37 DrawBitmap(fBitmap, Bounds().LeftTop()); 38 } 39 } 40 41 // MouseDown 42 void 43 BitmapView::MouseDown(BPoint where) 44 { 45 } 46 47 // MouseUp 48 void 49 BitmapView::MouseUp(BPoint where) 50 { 51 } 52 53 // MouseMoved 54 void 55 BitmapView::MouseMoved(BPoint where, uint32 transit, 56 const BMessage* dragMessage) 57 { 58 } 59