Beispiel #1
0
// create initial bitmap
void MyBitmap::UpdatePixels(unsigned long *pixels, int width, int height)
{
    // if bitmap was never built or bitmap dimension changed
    if(m_hBitmap==0 || width!=m_width || height!=m_height)
    {
        // create a news bitmap
        _CreateBitmap(pixels, width, height);
        return;
    }

    //  create a DC for the screen and create a memory DC compatible to screen DC
    HDC hScrDC = ::GetDC(0);	// Get a DC on the main display
    HDC hMemDC = ::CreateCompatibleDC(hScrDC);

    // select new bitmap into memory DC
    HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemDC, m_hBitmap);

    // set pixels bit
    BITMAPINFO Info;
    _InitBitmapInfo(Info, width, height,32); // negative height means top-bottom
    ::SetDIBits(hMemDC,m_hBitmap,0,height,pixels,&Info,DIB_RGB_COLORS);

    //  select old bitmap back into memory DC and get handle to bitmap of the screen
    ::SelectObject(hMemDC, hOldBitmap);

    // clean up
    ::ReleaseDC(0,hScrDC);
    ::DeleteDC(hMemDC);
}
Beispiel #2
0
void
Activity::FrameResized(float width, float height)
{
	delete fBitmap;
	_CreateBitmap();
	Invalidate();
}
Beispiel #3
0
void 
Activity::Draw(BRect rect)
{
	BRect viewRect = Bounds();
	BRect bitmapRect = fBitmap->Bounds();

	if (bitmapRect != viewRect) {
		delete fBitmap;
		_CreateBitmap();
	}

	_DrawOnBitmap(IsRunning());
	SetDrawingMode(B_OP_COPY);
	DrawBitmap(fBitmap);
}
Beispiel #4
0
// create initial bitmap
void MyBitmap::CreateBitmap(unsigned long *pixels, int width, int height)
{
    _CreateBitmap(pixels, width, height);
}
Beispiel #5
0
void 
Activity::AllAttached()
{
	SetViewColor(B_TRANSPARENT_COLOR);
	_CreateBitmap();
}