* Use buffered I/O instead of stream directly since you cannot know the
caller does it for you (ShowImage apparently does). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28663 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2007-2008, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "ConfigView.h"
|
#include "ConfigView.h"
|
||||||
#include "RAW.h"
|
#include "RAW.h"
|
||||||
|
|
||||||
|
#include <BufferIO.h>
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <TranslatorRoster.h>
|
#include <TranslatorRoster.h>
|
||||||
|
|
||||||
@@ -117,7 +118,8 @@ RAWTranslator::DerivedIdentify(BPositionIO *stream,
|
|||||||
if (outType != B_TRANSLATOR_BITMAP)
|
if (outType != B_TRANSLATOR_BITMAP)
|
||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
|
|
||||||
DCRaw raw(*stream);
|
BBufferIO io(stream, 128 * 1024, false);
|
||||||
|
DCRaw raw(io);
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -177,7 +179,7 @@ RAWTranslator::_ProgressMonitor(const char* message, float percentage,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
RAWTranslator::DerivedTranslate(BPositionIO* source,
|
RAWTranslator::DerivedTranslate(BPositionIO* stream,
|
||||||
const translator_info* info, BMessage* settings,
|
const translator_info* info, BMessage* settings,
|
||||||
uint32 outType, BPositionIO* target, int32 baseType)
|
uint32 outType, BPositionIO* target, int32 baseType)
|
||||||
{
|
{
|
||||||
@@ -186,16 +188,17 @@ 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;
|
||||||
|
|
||||||
DCRaw raw(*source);
|
BBufferIO io(stream, 1024 * 1024, false);
|
||||||
|
DCRaw raw(io);
|
||||||
|
|
||||||
bool headerOnly = false;
|
bool headerOnly = false;
|
||||||
|
|
||||||
progress_data progressData;
|
progress_data progressData;
|
||||||
BMessenger monitor;
|
BMessenger monitor;
|
||||||
|
|
||||||
if (settings != NULL) {
|
if (settings != NULL) {
|
||||||
settings->FindBool(B_TRANSLATOR_EXT_HEADER_ONLY, &headerOnly);
|
settings->FindBool(B_TRANSLATOR_EXT_HEADER_ONLY, &headerOnly);
|
||||||
|
|
||||||
bool half;
|
bool half;
|
||||||
if (settings->FindBool("raw:half_size", &half) == B_OK && half)
|
if (settings->FindBool("raw:half_size", &half) == B_OK && half)
|
||||||
raw.SetHalfSize(true);
|
raw.SetHalfSize(true);
|
||||||
@@ -218,7 +221,7 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
status = raw.Identify();
|
status = raw.Identify();
|
||||||
|
|
||||||
if (status == B_OK && settings) {
|
if (status == B_OK && settings) {
|
||||||
// Check if a document index has been specified
|
// Check if a document index has been specified
|
||||||
if (settings->FindInt32(kDocumentIndex, &imageIndex) == B_OK)
|
if (settings->FindInt32(kDocumentIndex, &imageIndex) == B_OK)
|
||||||
imageIndex--;
|
imageIndex--;
|
||||||
else
|
else
|
||||||
@@ -280,7 +283,7 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
header.null = 0;
|
header.null = 0;
|
||||||
memcpy(exifBuffer, &header, sizeof(header));
|
memcpy(exifBuffer, &header, sizeof(header));
|
||||||
|
|
||||||
if (source->ReadAt(exifOffset, exifBuffer + 16, exifLength)
|
if (io.ReadAt(exifOffset, exifBuffer + 16, exifLength)
|
||||||
== (ssize_t)exifLength)
|
== (ssize_t)exifLength)
|
||||||
settings->AddData("exif", B_RAW_TYPE, exifBuffer, exifLength + 16);
|
settings->AddData("exif", B_RAW_TYPE, exifBuffer, exifLength + 16);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user