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:
@@ -62,6 +62,9 @@ class ServerBitmap {
|
|||||||
//! Does a shallow copy of the bitmap passed to it
|
//! Does a shallow copy of the bitmap passed to it
|
||||||
inline void ShallowCopy(const ServerBitmap *from);
|
inline void ShallowCopy(const ServerBitmap *from);
|
||||||
|
|
||||||
|
status_t ImportBits(const void *bits, int32 bitsLength,
|
||||||
|
int32 bytesPerRow, color_space colorSpace);
|
||||||
|
|
||||||
void PrintToStream();
|
void PrintToStream();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "ServerBitmap.h"
|
#include "ServerBitmap.h"
|
||||||
|
#include "ColorConversion.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#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
|
void
|
||||||
ServerBitmap::PrintToStream()
|
ServerBitmap::PrintToStream()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1147,23 +1147,16 @@ DrawingEngine::ReadBitmap(ServerBitmap *bitmap, bool drawCursor, BRect bounds)
|
|||||||
BRect clip(0, 0, buffer->Width() - 1, buffer->Height() - 1);
|
BRect clip(0, 0, buffer->Width() - 1, buffer->Height() - 1);
|
||||||
bounds = bounds & clip;
|
bounds = bounds & clip;
|
||||||
|
|
||||||
uint32 width = (bounds.IntegerWidth() + 1) * 4;
|
int32 bytesPerRow = buffer->BytesPerRow();
|
||||||
uint32 height = bounds.IntegerHeight();
|
int32 bitsLength = bytesPerRow * (bounds.IntegerHeight() + 1);
|
||||||
uint32 srcBytesPerRow = buffer->BytesPerRow();
|
uint8 *bits = (uint8 *)buffer->Bits();
|
||||||
uint32 dstBytesPerRow = bitmap->BytesPerRow();
|
bits += (uint32)bounds.top * bytesPerRow + (uint32)bounds.left * 4;
|
||||||
uint8 *dst = (uint8 *)bitmap->Bits();
|
|
||||||
uint8 *src = (uint8 *)buffer->Bits();
|
|
||||||
src += (uint32)bounds.top * srcBytesPerRow + (uint32)bounds.left * 4;
|
|
||||||
|
|
||||||
/* ToDo: handle color conversion */
|
status_t result = bitmap->ImportBits(bits, bitsLength, bytesPerRow,
|
||||||
for (uint32 i = 0; i < height; i++) {
|
buffer->ColorSpace());
|
||||||
memcpy(dst, src, width);
|
|
||||||
dst += dstBytesPerRow;
|
|
||||||
src += srcBytesPerRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
Unlock();
|
Unlock();
|
||||||
return B_OK;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|||||||
Reference in New Issue
Block a user