* Implemented support for the "header only" extension.
* Added missing header when compiling RAWTranslator in test mode for Haiku. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20575 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -141,6 +141,10 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
if (outType != B_TRANSLATOR_BITMAP || baseType != 0)
|
if (outType != B_TRANSLATOR_BITMAP || baseType != 0)
|
||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
|
|
||||||
|
bool headerOnly = false;
|
||||||
|
if (settings != NULL)
|
||||||
|
settings->FindBool(B_TRANSLATOR_EXT_HEADER_ONLY, &headerOnly);
|
||||||
|
|
||||||
DCRaw raw(*source);
|
DCRaw raw(*source);
|
||||||
|
|
||||||
int32 imageIndex = 0;
|
int32 imageIndex = 0;
|
||||||
@@ -161,7 +165,7 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
if (imageIndex < 0 || imageIndex >= (int32)raw.CountImages())
|
if (imageIndex < 0 || imageIndex >= (int32)raw.CountImages())
|
||||||
status = B_BAD_VALUE;
|
status = B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
if (status == B_OK)
|
if (status == B_OK && !headerOnly)
|
||||||
status = raw.ReadImageAt(imageIndex, buffer, bufferSize);
|
status = raw.ReadImageAt(imageIndex, buffer, bufferSize);
|
||||||
} catch (status_t error) {
|
} catch (status_t error) {
|
||||||
status = error;
|
status = error;
|
||||||
@@ -191,9 +195,17 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
// write out Be's Bitmap header
|
// write out Be's Bitmap header
|
||||||
swap_data(B_UINT32_TYPE, &header, sizeof(TranslatorBitmap),
|
swap_data(B_UINT32_TYPE, &header, sizeof(TranslatorBitmap),
|
||||||
B_SWAP_HOST_TO_BENDIAN);
|
B_SWAP_HOST_TO_BENDIAN);
|
||||||
target->Write(&header, sizeof(TranslatorBitmap));
|
ssize_t bytesWritten = target->Write(&header, sizeof(TranslatorBitmap));
|
||||||
|
if (bytesWritten < B_OK)
|
||||||
|
return bytesWritten;
|
||||||
|
|
||||||
ssize_t bytesWritten = target->Write(buffer, dataSize);
|
if ((size_t)bytesWritten != sizeof(TranslatorBitmap))
|
||||||
|
return B_IO_ERROR;
|
||||||
|
|
||||||
|
if (headerOnly)
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
|
bytesWritten = target->Write(buffer, dataSize);
|
||||||
if (bytesWritten < B_OK)
|
if (bytesWritten < B_OK)
|
||||||
return bytesWritten;
|
return bytesWritten;
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#if SHOW_MODE && TEST_MODE
|
#if SHOW_MODE && TEST_MODE
|
||||||
# include <Bitmap.h>
|
# include <Bitmap.h>
|
||||||
# include <BitmapStream.h>
|
# include <BitmapStream.h>
|
||||||
|
# include <String.h>
|
||||||
# include <View.h>
|
# include <View.h>
|
||||||
# include <Window.h>
|
# include <Window.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user