Fixed warnings, minor cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12120 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-03-29 15:58:27 +00:00
parent b2b5acff33
commit 0f89f0ae14
+13 -15
View File
@@ -1,8 +1,7 @@
/*****************************************************************************/ /*****************************************************************************/
// File: BitmapStream.cpp // Copyright (c) 2002-2005 Haiku Project
// Class: BBitmapStream //
// Reimplemented by: Travis Smith, Michael Wilber, Translation Kit Team // Reimplemented by: Travis Smith, Michael Wilber, Translation Kit Team
// Reimplementation: 2002-04
// //
// Description: BPositionIO based object to read/write bitmap format to/from // Description: BPositionIO based object to read/write bitmap format to/from
// a BBitmap object. // a BBitmap object.
@@ -10,8 +9,6 @@
// The BTranslationUtils class uses this object and makes it // The BTranslationUtils class uses this object and makes it
// easy for users to load bitmaps. // easy for users to load bitmaps.
// //
// Copyright (c) 2002 OpenBeOS Project
//
// Original Version: Copyright 1998, Be Incorporated, All Rights Reserved. // Original Version: Copyright 1998, Be Incorporated, All Rights Reserved.
// Copyright 1995-1997, Jon Watte // Copyright 1995-1997, Jon Watte
// //
@@ -145,14 +142,14 @@ BBitmapStream::ReadAt(off_t pos, void *buffer, size_t size)
if (pos < sizeof(TranslatorBitmap)) { if (pos < sizeof(TranslatorBitmap)) {
toRead = sizeof(TranslatorBitmap) - pos; toRead = sizeof(TranslatorBitmap) - pos;
source = (reinterpret_cast<uint8 *> (fpBigEndianHeader)) + pos; source = (reinterpret_cast<uint8 *>(fpBigEndianHeader)) + pos;
} else { } else {
toRead = fSize - pos; toRead = fSize - pos;
source = (reinterpret_cast<uint8 *> (fBitmap->Bits())) + pos - source = (reinterpret_cast<uint8 *>(fBitmap->Bits())) + pos -
sizeof(TranslatorBitmap); sizeof(TranslatorBitmap);
} }
if (toRead > size) if (toRead > (ssize_t)size)
toRead = size; toRead = (ssize_t)size;
memcpy(buffer, source, toRead); memcpy(buffer, source, toRead);
return toRead; return toRead;
@@ -223,21 +220,22 @@ BBitmapStream::WriteAt(off_t pos, const void *data, size_t size)
if (B_HOST_IS_LENDIAN) if (B_HOST_IS_LENDIAN)
SwapHeader(fpBigEndianHeader, &fHeader); SwapHeader(fpBigEndianHeader, &fHeader);
if (fBitmap && ((fBitmap->Bounds() != fHeader.bounds) || if (fBitmap
(fBitmap->ColorSpace() != fHeader.colors) || && (fBitmap->Bounds() != fHeader.bounds
(fBitmap->BytesPerRow() != fHeader.rowBytes))) { || fBitmap->ColorSpace() != fHeader.colors
|| (uint32)fBitmap->BytesPerRow() != fHeader.rowBytes)) {
if (!fDetached) if (!fDetached)
// if someone detached, we don't delete // if someone detached, we don't delete
delete fBitmap; delete fBitmap;
fBitmap = NULL; fBitmap = NULL;
} }
if (!fBitmap) { if (!fBitmap) {
if ((fHeader.bounds.left > 0.0) || (fHeader.bounds.top > 0.0)) if (fHeader.bounds.left > 0.0 || fHeader.bounds.top > 0.0)
DEBUGGER("non-origin bounds!"); DEBUGGER("non-origin bounds!");
fBitmap = new BBitmap(fHeader.bounds, fHeader.colors); fBitmap = new BBitmap(fHeader.bounds, fHeader.colors);
if (!fBitmap) if (!fBitmap)
return B_ERROR; return B_ERROR;
if (fBitmap->BytesPerRow() != fHeader.rowBytes) if ((uint32)fBitmap->BytesPerRow() != fHeader.rowBytes)
return B_MISMATCHED_VALUES; return B_MISMATCHED_VALUES;
} }
if (fBitmap) if (fBitmap)