* 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:
Axel Dörfler 2007-04-05 12:15:56 +00:00
parent 09c3a92d0a
commit 9468eca38a
2 changed files with 16 additions and 3 deletions

View File

@ -141,6 +141,10 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
if (outType != B_TRANSLATOR_BITMAP || baseType != 0)
return B_NO_TRANSLATOR;
bool headerOnly = false;
if (settings != NULL)
settings->FindBool(B_TRANSLATOR_EXT_HEADER_ONLY, &headerOnly);
DCRaw raw(*source);
int32 imageIndex = 0;
@ -161,7 +165,7 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
if (imageIndex < 0 || imageIndex >= (int32)raw.CountImages())
status = B_BAD_VALUE;
}
if (status == B_OK)
if (status == B_OK && !headerOnly)
status = raw.ReadImageAt(imageIndex, buffer, bufferSize);
} catch (status_t error) {
status = error;
@ -191,9 +195,17 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
// write out Be's Bitmap header
swap_data(B_UINT32_TYPE, &header, sizeof(TranslatorBitmap),
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)
return bytesWritten;

View File

@ -15,6 +15,7 @@
#if SHOW_MODE && TEST_MODE
# include <Bitmap.h>
# include <BitmapStream.h>
# include <String.h>
# include <View.h>
# include <Window.h>
#endif