Started implementing the server side of BScreen()->ReadBitmap().

Colorspace conversion is not done yet so that it only works correct in 32bit modes.
Also drawCursor is not respected yet. Partially fixes bug 197.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16573 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2006-03-02 23:50:06 +00:00
parent d5062208bb
commit 3e2ee69551
3 changed files with 41 additions and 3 deletions

View File

@ -59,7 +59,8 @@ public:
// for screen shots
bool DumpToFile(const char *path);
ServerBitmap* DumpToBitmap();
status_t ReadBitmap(ServerBitmap *bitmap, bool drawCursor,
BRect bounds);
// clipping for all drawing functions, passing a NULL region
// will remove any clipping (drawing allowed everywhere)

View File

@ -2439,8 +2439,11 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
ServerBitmap *bitmap = FindBitmap(bitmapToken);
if (bitmap != NULL) {
fLink.StartMessage(B_OK);
// TODO: Implement for real
if (fDesktop->GetDrawingEngine()->ReadBitmap(bitmap,
drawCursor, bounds) == B_OK) {
fLink.StartMessage(B_OK);
} else
fLink.StartMessage(B_BAD_VALUE);
} else
fLink.StartMessage(B_BAD_VALUE);

View File

@ -16,6 +16,7 @@
#include "DrawState.h"
#include "Painter.h"
#include "PNGDump.h"
#include "ServerBitmap.h"
#include "RenderingBuffer.h"
#include "frame_buffer_support.h"
@ -1135,6 +1136,39 @@ DrawingEngine::DumpToBitmap()
return NULL;
}
status_t
DrawingEngine::ReadBitmap(ServerBitmap *bitmap, bool drawCursor, BRect bounds)
{
if (Lock()) {
RenderingBuffer *buffer = fGraphicsCard->DrawingBuffer();
if (!buffer)
return B_ERROR;
BRect clip(0, 0, buffer->Width() - 1, buffer->Height() - 1);
bounds = bounds & clip;
uint32 width = (bounds.IntegerWidth() + 1) * 4;
uint32 height = bounds.IntegerHeight() + 1;
uint32 srcBytesPerRow = buffer->BytesPerRow();
uint32 dstBytesPerRow = bitmap->BytesPerRow();
uint8 *dst = (uint8 *)bitmap->Bits();
uint8 *src = (uint8 *)buffer->Bits();
src += (uint32)bounds.top * srcBytesPerRow + (uint32)bounds.left * 4;
/* ToDo: handle color conversion */
for (uint32 i = 0; i < height; i++) {
memcpy(dst, src, width);
dst += dstBytesPerRow;
src += srcBytesPerRow;
}
Unlock();
return B_OK;
}
return B_ERROR;
}
// #pragma mark -
BRect