Actually only allow bytes per row > 0 or B_ANY_BYTES_PER_ROW. Still we don't

actually handle other invalid bpr values like if the width doesn't really fit
into the provided bytes per row for example.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27696 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2008-09-22 19:42:35 +00:00
parent f8b51708a6
commit 56c05e04af
1 changed files with 12 additions and 4 deletions

View File

@ -626,8 +626,12 @@ BBitmap::ImportBits(const void *data, int32 length, int32 bpr, int32 offset,
return B_BAD_VALUE;
int32 width = fBounds.IntegerWidth() + 1;
if (bpr < 0)
if (bpr <= 0) {
if (bpr == B_ANY_BYTES_PER_ROW)
bpr = get_bytes_per_row(colorSpace, width);
else
return B_BAD_VALUE;
}
return BPrivate::ConvertBits(data, (uint8*)fBasePointer + offset, length,
fSize - offset, bpr, fBytesPerRow, colorSpace, fColorSpace, width,
@ -669,8 +673,12 @@ BBitmap::ImportBits(const void *data, int32 length, int32 bpr,
if (!data || length < 0 || width < 0 || height < 0)
return B_BAD_VALUE;
if (bpr < 0)
if (bpr <= 0) {
if (bpr == B_ANY_BYTES_PER_ROW)
bpr = get_bytes_per_row(colorSpace, fBounds.IntegerWidth() + 1);
else
return B_BAD_VALUE;
}
return BPrivate::ConvertBits(data, fBasePointer, length, fSize, bpr,
fBytesPerRow, colorSpace, fColorSpace, from, to, width, height);