Added an ImportBits() function to ServerBitmap and used it in ReadBitmap(). Should work for all colorspaces now.

Magnify does now work correctly, fixed bug 197.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16581 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2006-03-05 12:59:39 +00:00
parent b09e53fae0
commit acfad7920c
3 changed files with 23 additions and 14 deletions

View File

@ -62,6 +62,9 @@ class ServerBitmap {
//! Does a shallow copy of the bitmap passed to it
inline void ShallowCopy(const ServerBitmap *from);
status_t ImportBits(const void *bits, int32 bitsLength,
int32 bytesPerRow, color_space colorSpace);
void PrintToStream();
protected:

View File

@ -8,6 +8,7 @@
#include "ServerBitmap.h"
#include "ColorConversion.h"
#include <new>
#include <stdio.h>
@ -245,6 +246,18 @@ ServerBitmap::_HandleSpace(color_space space, int32 bytesPerRow)
}
status_t
ServerBitmap::ImportBits(const void *bits, int32 bitsLength, int32 bytesPerRow,
color_space colorSpace)
{
if (!bits || bitsLength < 0 || bytesPerRow <= 0)
return B_BAD_VALUE;
return BPrivate::ConvertBits(bits, fBuffer, bytesPerRow, fBytesPerRow,
colorSpace, fSpace, fWidth, fHeight);
}
void
ServerBitmap::PrintToStream()
{

View File

@ -1147,23 +1147,16 @@ DrawingEngine::ReadBitmap(ServerBitmap *bitmap, bool drawCursor, BRect bounds)
BRect clip(0, 0, buffer->Width() - 1, buffer->Height() - 1);
bounds = bounds & clip;
uint32 width = (bounds.IntegerWidth() + 1) * 4;
uint32 height = bounds.IntegerHeight();
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;
int32 bytesPerRow = buffer->BytesPerRow();
int32 bitsLength = bytesPerRow * (bounds.IntegerHeight() + 1);
uint8 *bits = (uint8 *)buffer->Bits();
bits += (uint32)bounds.top * bytesPerRow + (uint32)bounds.left * 4;
/* ToDo: handle color conversion */
for (uint32 i = 0; i < height; i++) {
memcpy(dst, src, width);
dst += dstBytesPerRow;
src += srcBytesPerRow;
}
status_t result = bitmap->ImportBits(bits, bitsLength, bytesPerRow,
buffer->ColorSpace());
Unlock();
return B_OK;
return result;
}
return B_ERROR;