Replaced applications of BBitmap::SetBits() by BBitmap::ImportBits().
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@978 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -802,8 +802,10 @@ BAppFileInfo::GetIconForType(const char *type, BBitmap *icon,
|
||||
error = B_ERROR;
|
||||
if (otherColorSpace) {
|
||||
// other color space than stored in attribute
|
||||
if (error == B_OK)
|
||||
icon->SetBits(buffer, attrSize, 0, B_CMAP8);
|
||||
if (error == B_OK) {
|
||||
error = icon->ImportBits(buffer, attrSize, B_ANY_BYTES_PER_ROW,
|
||||
0, B_CMAP8);
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
@@ -889,8 +891,9 @@ BAppFileInfo::SetIconForType(const char *type, const BBitmap *icon,
|
||||
if (otherColorSpace) {
|
||||
BBitmap bitmap(bounds, B_CMAP8);
|
||||
error = bitmap.InitCheck();
|
||||
if (error == B_OK)
|
||||
error = bitmap.ImportBits(icon);
|
||||
if (error == B_OK) {
|
||||
bitmap.SetBits(icon->Bits(), 0, attrSize, B_CMAP8);
|
||||
error = _WriteData(attribute, resourceID, attrType,
|
||||
bitmap.Bits(), attrSize, true);
|
||||
}
|
||||
|
||||
@@ -283,8 +283,10 @@ BNodeInfo::GetIcon(BBitmap *icon, icon_size k) const
|
||||
}
|
||||
if (otherColorSpace) {
|
||||
// other color space than stored in attribute
|
||||
if (error == B_OK)
|
||||
icon->SetBits(buffer, attrSize, 0, B_CMAP8);
|
||||
if (error == B_OK) {
|
||||
error = icon->ImportBits(buffer, attrSize, B_ANY_BYTES_PER_ROW,
|
||||
0, B_CMAP8);
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
@@ -351,8 +353,9 @@ BNodeInfo::SetIcon(const BBitmap *icon, icon_size k)
|
||||
if (otherColorSpace) {
|
||||
BBitmap bitmap(bounds, B_CMAP8);
|
||||
error = bitmap.InitCheck();
|
||||
if (error == B_OK)
|
||||
error = bitmap.ImportBits(icon);
|
||||
if (error == B_OK) {
|
||||
bitmap.SetBits(icon->Bits(), 0, attrSize, B_CMAP8);
|
||||
written = fNode->WriteAttr(attribute, attrType, 0,
|
||||
bitmap.Bits(), attrSize);
|
||||
}
|
||||
|
||||
@@ -270,8 +270,8 @@ get_icon_for_type(const char *type, const char *fileType, BBitmap *icon,
|
||||
err = (err == attrSize) ? B_OK : B_FILE_ERROR;
|
||||
if (otherColorSpace) {
|
||||
if (!err) {
|
||||
icon->SetBits(buffer, attrSize, 0, B_CMAP8);
|
||||
err = icon->InitCheck();
|
||||
err = icon->ImportBits(buffer, attrSize, B_ANY_BYTES_PER_ROW,
|
||||
0, B_CMAP8);
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
@@ -374,33 +374,8 @@ get_icon_data(const BBitmap *icon, icon_size which, void **data, int32 *dataSize
|
||||
icon8 = new(nothrow) BBitmap(bounds, B_CMAP8);
|
||||
if (!icon8)
|
||||
err = B_NO_MEMORY;
|
||||
if (!err) {
|
||||
switch (icon->ColorSpace()) {
|
||||
case B_RGB32:
|
||||
{
|
||||
// Set each pixel individually, since SetBits() for B_RGB32 takes
|
||||
// 24-bit rgb pixel data...
|
||||
char *bgra = (char*)icon->Bits();
|
||||
for (int32 i = 0; i*4+3 < icon->BitsLength(); bgra += 4, i++) {
|
||||
char rgb[3];
|
||||
rgb[0] = bgra[2]; // red
|
||||
rgb[1] = bgra[1]; // green
|
||||
rgb[2] = bgra[0]; // blue
|
||||
icon8->SetBits(rgb, 3, i, B_RGB32);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case B_GRAY1:
|
||||
{
|
||||
icon8->SetBits(icon->Bits(), icon->BitsLength(), 0, B_GRAY1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
err = B_BAD_VALUE;
|
||||
}
|
||||
if (!err)
|
||||
err = icon8->InitCheck(); // I don't think this is actually useful, even if SetBits() fails...
|
||||
}
|
||||
if (!err)
|
||||
err = icon8->ImportBits(icon);
|
||||
if (!err) {
|
||||
srcData = icon8->Bits();
|
||||
*dataSize = icon8->BitsLength();
|
||||
|
||||
Reference in New Issue
Block a user