* BPrivate::ConvertBits() did not take the source or destination bits length
into account when copying to the same color space (new code isn't that fast, but it works). * BBitmap::ImportBits() did not take the specified offset into account at all. This fixes bug #313. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16812 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
150e5ed532
commit
0ce9ba6ba3
@ -513,8 +513,8 @@ BBitmap::ImportBits(const void *data, int32 length, int32 bpr, int32 offset,
|
||||
if (bpr < 0)
|
||||
bpr = get_bytes_per_row(colorSpace, width);
|
||||
|
||||
return BPrivate::ConvertBits(data, fBasePtr, length, fSize, bpr,
|
||||
fBytesPerRow, colorSpace, fColorSpace, width,
|
||||
return BPrivate::ConvertBits(data, (uint8*)fBasePtr + offset, length,
|
||||
fSize - offset, bpr, fBytesPerRow, colorSpace, fColorSpace, width,
|
||||
fBounds.IntegerHeight() + 1);
|
||||
}
|
||||
|
||||
|
@ -685,8 +685,18 @@ ConvertBits(const srcByte *srcBits, dstByte *dstBits, int32 srcBitsLength,
|
||||
if (srcColorSpace == dstColorSpace && srcBitsPerPixel % 8 == 0) {
|
||||
int32 copyCount = (width * srcBitsPerPixel) >> 3;
|
||||
for (int32 i = 0; i < height; i++) {
|
||||
// make sure we don't write beyond the bits size
|
||||
if (copyCount > srcBitsLength)
|
||||
copyCount = srcBitsLength;
|
||||
if (copyCount > dstBitsLength)
|
||||
copyCount = dstBitsLength;
|
||||
if (copyCount == 0)
|
||||
break;
|
||||
|
||||
memcpy(dstBits, srcBits, copyCount);
|
||||
|
||||
srcBitsLength -= copyCount;
|
||||
dstBitsLength -= copyCount;
|
||||
(char *)srcBits += srcBytesPerRow;
|
||||
(char *)dstBits += dstBytesPerRow;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user