* Initial and very basic version of a RAW image translator.

* Based on Dave Coffin's fabuluous dcraw - it's basically the same thing in C++,
  but follows common sense programming rules a bit more :-).
* Current version probably only supports PENTAX RAW format, though.
* Still lots of places left to clean up.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20404 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-03-22 18:43:45 +00:00
parent 63cd2925a0
commit 8260e407c5
11 changed files with 3783 additions and 0 deletions
+1
View File
@@ -8,6 +8,7 @@ SubInclude HAIKU_TOP src add-ons translators jpeg2000 ;
SubInclude HAIKU_TOP src add-ons translators libtiff ;
SubInclude HAIKU_TOP src add-ons translators png ;
SubInclude HAIKU_TOP src add-ons translators ppm ;
SubInclude HAIKU_TOP src add-ons translators raw ;
SubInclude HAIKU_TOP src add-ons translators rtf ;
SubInclude HAIKU_TOP src add-ons translators sgi ;
SubInclude HAIKU_TOP src add-ons translators stxt ;
@@ -0,0 +1,77 @@
/*
* Copyright 2005-2007, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "ConfigView.h"
#include "RAWTranslator.h"
#include <StringView.h>
#include <CheckBox.h>
#include <stdio.h>
#include <string.h>
ConfigView::ConfigView(const BRect &frame, uint32 resize, uint32 flags)
: BView(frame, "RAWTranslator Settings", resize, flags)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
font_height fontHeight;
be_bold_font->GetHeight(&fontHeight);
float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
BRect rect(10, 10, 200, 10 + height);
BStringView *stringView = new BStringView(rect, "title", "RAW Images");
stringView->SetFont(be_bold_font);
stringView->ResizeToPreferred();
AddChild(stringView);
rect.OffsetBy(0, height + 10);
char version[256];
sprintf(version, "Version %d.%d.%d, %s",
int(B_TRANSLATION_MAJOR_VERSION(RAW_TRANSLATOR_VERSION)),
int(B_TRANSLATION_MINOR_VERSION(RAW_TRANSLATOR_VERSION)),
int(B_TRANSLATION_REVISION_VERSION(RAW_TRANSLATOR_VERSION)),
__DATE__);
stringView = new BStringView(rect, "version", version);
stringView->ResizeToPreferred();
AddChild(stringView);
GetFontHeight(&fontHeight);
height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
rect.OffsetBy(0, height + 5);
stringView = new BStringView(rect, "copyright", B_UTF8_COPYRIGHT "2007 Haiku Inc.");
stringView->ResizeToPreferred();
AddChild(stringView);
rect.OffsetBy(0, height + 20);
BCheckBox *checkBox = new BCheckBox(rect, "color", "Write 32 bit images on true color input", NULL);
checkBox->ResizeToPreferred();
AddChild(checkBox);
rect.OffsetBy(0, height + 10);
checkBox = new BCheckBox(rect, "size", "Enforce valid icon sizes", NULL);
checkBox->ResizeToPreferred();
checkBox->SetValue(1);
AddChild(checkBox);
rect.OffsetBy(0, height + 15);
stringView = new BStringView(rect, "valid1", "Valid icon sizes are 16, 32, or 48");
stringView->ResizeToPreferred();
AddChild(stringView);
rect.OffsetBy(0, height + 5);
stringView = new BStringView(rect, "valid2", "pixel in either direction.");
stringView->ResizeToPreferred();
AddChild(stringView);
}
ConfigView::~ConfigView()
{
}
+19
View File
@@ -0,0 +1,19 @@
/*
* Copyright 2004-2007, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef CONFIG_VIEW_H
#define CONFIG_VIEW_H
#include <View.h>
class ConfigView : public BView {
public:
ConfigView(const BRect &frame, uint32 resize = B_FOLLOW_ALL,
uint32 flags = B_WILL_DRAW);
virtual ~ConfigView();
};
#endif /* CONFIG_VIEW_H */
+26
View File
@@ -0,0 +1,26 @@
SubDir HAIKU_TOP src add-ons translators raw ;
SetSubDirSupportedPlatformsBeOSCompatible ;
# Include code from shared translator directory
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons translators shared ] ;
Translator RAWTranslator :
# RawTranslator classes
main.cpp
RAWTranslator.cpp
ConfigView.cpp
RAW.cpp
# shared classes
BaseTranslator.cpp
TranslatorSettings.cpp
TranslatorWindow.cpp
: be translation
;
Package haiku-translationkit-cvs :
RAWTranslator
: boot home config add-ons Translators
;
File diff suppressed because it is too large Load Diff
+170
View File
@@ -0,0 +1,170 @@
/*
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef RAW_H
#define RAW_H
#include "ReadHelper.h"
struct jhead;
struct tiff_tag;
struct image_meta_info {
char manufacturer[64];
char model[128];
char software[64];
float flash_used;
float iso_speed;
float shutter;
float aperture;
float focal_length;
double pixel_aspect;
uint32 raw_width;
uint32 raw_height;
int flip;
uint32 dng_version;
uint32 shot_order;
int32 black;
double maximum;
float camera_multipliers[4];
float pre_multipliers[4];
float rgb_camera[3][4]; /* RGB from camera color */
time_t timestamp;
};
struct image_data_info {
uint32 width;
uint32 height;
uint32 output_width;
uint32 output_height;
uint32 bits_per_sample;
uint32 compression;
uint32 photometric_interpretation;
uint32 flip;
uint32 samples;
uint32 bytes;
off_t data_offset;
bool is_raw;
};
class DCRaw {
public:
DCRaw(BPositionIO& stream);
~DCRaw();
status_t Identify();
status_t ReadImageAt(uint32 index, uint8*& outputBuffer,
size_t& bufferSize);
void GetMetaInfo(image_meta_info& metaInfo) const;
uint32 CountImages() const;
status_t ImageAt(uint32 index, image_data_info& info) const;
private:
int32 _AllocateImage();
image_data_info& _Raw();
image_data_info& _Thumb();
void _CorrectIndex(uint32& index) const;
uint16& _Bayer(int32 column, int32 row);
int32 _FilterCoefficient(int32 column, int32 row);
int32 _FlipIndex(uint32 row, uint32 col, uint32 flip);
// image manipulation and conversion
void _ScaleColors();
void _WaveletDenoise();
void _PreInterpolate();
void _CameraToCIELab(ushort cam[4], float lab[3]);
void _CameraXYZCoefficients(double cam_xyz[4][3]);
void _AdobeCoefficients(char* manufacturer, char* model);
void _BorderInterpolate(uint32 border);
void _AHDInterpolate();
void _PseudoInverse(double (*in)[3], double (*out)[3], uint32 size);
void _ConvertToRGB();
void _GammaLookUpTable(uchar* lut);
void _ParseThumbTag(off_t baseOffset, uint32 offsetTag, uint32 lengthTag);
void _ParseManufacturerTag(off_t baseOffset);
void _ParseEXIF(off_t baseOffset);
// Lossless JPEG
void _InitDecoder();
uchar *_MakeDecoder(const uchar* source, int level);
void _InitDecodeBits();
uint32 _GetDecodeBits(uint32 numBits);
status_t _LosslessJPEGInit(struct jhead* jh, bool infoOnly);
int _LosslessJPEGDiff(struct decode *dindex);
void _LosslessJPEGRow(struct jhead *jh, int jrow);
// RAW Loader
void _LoadRAWPacked12();
// Image writers
void _WriteJPEG(image_data_info& image, uint8* outputBuffer);
void _WriteRGB32(image_data_info& image, uint8* outputBuffer);
// TIFF
time_t _ParseTIFFTimestamp(bool reversed);
void _ParseTIFFTag(off_t baseOffset, tiff_tag& tag, off_t& offset);
status_t _ParseTIFFImageFileDirectory(off_t baseOffset, uint32 offset);
status_t _ParseTIFFImageFileDirectory(off_t baseOffset);
status_t _ParseTIFF(off_t baseOffset);
TReadHelper fRead;
image_meta_info fMeta;
image_data_info* fImages;
uint32 fNumImages;
int32 fRawIndex;
int32 fThumbIndex;
uint32 fDNGVersion;
uint16 (*fImageData)[4];
// output image data
int32 fThreshold;
int32 fShrink;
bool fHalfSize;
bool fUseCameraWhiteBalance;
bool fUseAutoWhiteBalance;
bool fRawColor;
bool fUseGamma;
float fBrightness;
int32 fOutputColor;
int32 fHighlight;
int32 fDocumentMode;
uint32 fOutputWidth;
uint32 fOutputHeight;
uint32 fInputWidth;
uint32 fInputHeight;
int32 fTopMargin;
int32 fLeftMargin;
uint32 fUniqueID;
uint32 fColors;
uint16 fWhite[8][8];
float fUserMultipliers[4];
uint32* fOutputProfile;
uint32 fOutputBitsPerSample;
int32 (*fHistogram)[4];
float* cbrt;
float xyz_cam[3][4];
// TODO: find better names for these...
// Lossless JPEG
decode* fDecodeBuffer;
decode* fSecondDecode;
decode* fFreeDecode;
int fDecodeLeaf;
uint32 fDecodeBits;
uint32 fDecodeBitsRead;
bool fDecodeBitsReset;
bool fDecodeBitsZeroAfterMax;
uint32 fFilters;
uint32 fEXIFFilters;
off_t fCurveOffset;
};
#endif // RAW_H
@@ -0,0 +1,225 @@
/*
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "RAWTranslator.h"
#include "ConfigView.h"
#include "RAW.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
// Extensions that ShowImage supports
const char *kDocumentCount = "/documentCount";
const char *kDocumentIndex = "/documentIndex";
// The input formats that this translator supports.
translation_format sInputFormats[] = {
{
RAW_IMAGE_FORMAT,
B_TRANSLATOR_BITMAP,
RAW_IN_QUALITY,
RAW_IN_CAPABILITY,
"image/x-vnd.adobe-dng",
"Adobe Digital Negative"
},
{
RAW_IMAGE_FORMAT,
B_TRANSLATOR_BITMAP,
RAW_IN_QUALITY,
RAW_IN_CAPABILITY,
"image/x-vnd.photo-raw",
"Digital Photo RAW image"
},
};
// The output formats that this translator supports.
translation_format sOutputFormats[] = {
{
B_TRANSLATOR_BITMAP,
B_TRANSLATOR_BITMAP,
BITS_OUT_QUALITY,
BITS_OUT_CAPABILITY,
"x-be-bitmap",
"Be Bitmap image"
},
};
// Default settings for the Translator
static TranSetting sDefaultSettings[] = {
{B_TRANSLATOR_EXT_HEADER_ONLY, TRAN_SETTING_BOOL, false},
{B_TRANSLATOR_EXT_DATA_ONLY, TRAN_SETTING_BOOL, false}
};
const uint32 kNumInputFormats = sizeof(sInputFormats) / sizeof(translation_format);
const uint32 kNumOutputFormats = sizeof(sOutputFormats) / sizeof(translation_format);
const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting);
RAWTranslator::RAWTranslator()
: BaseTranslator("Raw Images", "Raw Image Translator",
RAW_TRANSLATOR_VERSION,
sInputFormats, kNumInputFormats,
sOutputFormats, kNumOutputFormats,
"RawTranslator_Settings",
sDefaultSettings, kNumDefaultSettings,
B_TRANSLATOR_BITMAP, RAW_IMAGE_FORMAT)
{
}
RAWTranslator::~RAWTranslator()
{
}
status_t
RAWTranslator::DerivedIdentify(BPositionIO *stream,
const translation_format *format, BMessage *settings,
translator_info *info, uint32 outType)
{
if (!outType)
outType = B_TRANSLATOR_BITMAP;
if (outType != B_TRANSLATOR_BITMAP)
return B_NO_TRANSLATOR;
DCRaw raw(*stream);
status_t status;
try {
status = raw.Identify();
} catch (status_t error) {
status = error;
}
if (status < B_OK)
return B_NO_TRANSLATOR;
image_meta_info meta;
raw.GetMetaInfo(meta);
if (settings) {
int32 count = raw.CountImages();
// Add page count to ioExtension
settings->RemoveName(kDocumentCount);
settings->AddInt32(kDocumentCount, count);
// Check if a document index has been specified
int32 index;
if (settings->FindInt32(kDocumentIndex, &index) == B_OK)
index--;
else
index = 0;
if (index < 0 || index >= count)
return B_NO_TRANSLATOR;
}
info->type = RAW_IMAGE_FORMAT;
info->group = B_TRANSLATOR_BITMAP;
info->quality = RAW_IN_QUALITY;
info->capability = RAW_IN_CAPABILITY;
snprintf(info->name, sizeof(info->name), "%s RAW image", meta.manufacturer);
strcpy(info->MIME, "image/x-vnd.photo-raw");
return B_OK;
}
status_t
RAWTranslator::DerivedTranslate(BPositionIO* source,
const translator_info* info, BMessage* settings,
uint32 outType, BPositionIO* target, int32 baseType)
{
if (!outType)
outType = B_TRANSLATOR_BITMAP;
if (outType != B_TRANSLATOR_BITMAP || baseType != 0)
return B_NO_TRANSLATOR;
DCRaw raw(*source);
int32 imageIndex = 0;
uint8* buffer = NULL;
size_t bufferSize;
status_t status;
try {
status = raw.Identify();
if (status == B_OK && settings) {
// Check if a document index has been specified
if (settings->FindInt32(kDocumentIndex, &imageIndex) == B_OK)
imageIndex--;
else
imageIndex = 0;
if (imageIndex < 0 || imageIndex >= (int32)raw.CountImages())
status = B_BAD_VALUE;
}
if (status == B_OK)
status = raw.ReadImageAt(imageIndex, buffer, bufferSize);
} catch (status_t error) {
status = error;
}
if (status < B_OK)
return B_NO_TRANSLATOR;
image_meta_info meta;
raw.GetMetaInfo(meta);
image_data_info data;
raw.ImageAt(imageIndex, data);
if (!data.is_raw)
return B_NO_TRANSLATOR;
uint32 dataSize = data.output_width * 4 * data.output_height;
TranslatorBitmap header;
header.magic = B_TRANSLATOR_BITMAP;
header.bounds.Set(0, 0, data.output_width - 1, data.output_height - 1);
header.rowBytes = data.output_width * 4;
header.colors = B_RGB32;
header.dataSize = dataSize;
// 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(buffer, dataSize);
if (bytesWritten < B_OK)
return bytesWritten;
if ((size_t)bytesWritten != dataSize)
return B_IO_ERROR;
return B_OK;
}
BView *
RAWTranslator::NewConfigView(TranslatorSettings *settings)
{
return new ConfigView(BRect(0, 0, 225, 175));
}
// #pragma mark -
BTranslator *
make_nth_translator(int32 n, image_id you, uint32 flags, ...)
{
if (n != 0)
return NULL;
return new RAWTranslator();
}
@@ -0,0 +1,51 @@
/*
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef RAW_TRANSLATOR_H
#define RAW_TRANSLATOR_H
#include "BaseTranslator.h"
#include <Translator.h>
#include <TranslatorFormats.h>
#include <TranslationDefs.h>
#include <GraphicsDefs.h>
#include <InterfaceDefs.h>
#include <DataIO.h>
#include <File.h>
#include <ByteOrder.h>
#define RAW_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(0, 1, 0)
#define RAW_IMAGE_FORMAT 'RAWI'
#define RAW_IN_QUALITY 0.95
#define RAW_IN_CAPABILITY 0.95
#define BITS_IN_QUALITY 1
#define BITS_IN_CAPABILITY 1
#define RAW_OUT_QUALITY 0.8
#define RAW_OUT_CAPABILITY 0.8
#define BITS_OUT_QUALITY 1
#define BITS_OUT_CAPABILITY 0.9
class RAWTranslator : public BaseTranslator {
public:
RAWTranslator();
virtual ~RAWTranslator();
virtual status_t DerivedIdentify(BPositionIO *inSource,
const translation_format *inFormat, BMessage *ioExtension,
translator_info *outInfo, uint32 outType);
virtual status_t DerivedTranslate(BPositionIO *inSource,
const translator_info *inInfo, BMessage *ioExtension,
uint32 outType, BPositionIO *outDestination, int32 baseType);
virtual BView *NewConfigView(TranslatorSettings *settings);
};
#endif // RAW_TRANSLATOR_H
+179
View File
@@ -0,0 +1,179 @@
/*
* Copyright 2004-2007, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef READ_HELPER_H
#define READ_HELPER_H
#include "TIFF.h"
#include <BufferIO.h>
#include <ByteOrder.h>
template<class T>
inline void
byte_swap(T &/*data*/)
{
// Specialize for data types which actually swap
// printf("DEAD MEAT!\n");
// exit(1);
}
template<>
inline void
byte_swap(float &data)
{
data = __swap_float(data);
}
template<>
inline void
byte_swap(int32 &data)
{
data = __swap_int32(data);
}
template<>
inline void
byte_swap(uint32 &data)
{
data = __swap_int32(data);
}
template<>
inline void
byte_swap(int16 &data)
{
data = __swap_int16(data);
}
template<>
inline void
byte_swap(uint16 &data)
{
data = __swap_int16(data);
}
class TReadHelper {
public:
TReadHelper(BPositionIO& stream)
:
fStream(&stream, 65536, false),
fError(B_OK),
fSwap(false)
{
}
template<class T> inline void
operator()(T &data)
{
fError = fStream.Read((void *)&data, sizeof(T));
if (fError > B_OK) {
if (IsSwapping())
byte_swap(data);
return;
}
if (fError == 0)
fError = B_ERROR;
throw fError;
}
template<class T> inline void
operator()(T data, size_t length)
{
fError = fStream.Read((void *)data, length);
if (fError < (ssize_t)length)
fError = B_ERROR;
if (fError >= B_OK)
return;
throw fError;
}
template<class T> inline T
Next()
{
T value;
fError = fStream.Read((void *)&value, sizeof(T));
if (fError > B_OK) {
if (IsSwapping())
byte_swap(value);
return value;
}
if (fError == 0)
fError = B_ERROR;
throw fError;
}
inline uint32
Next(uint16 type)
{
if (type == TIFF_UINT16_TYPE || type == TIFF_INT16_TYPE)
return Next<uint16>();
return Next<uint32>();
}
inline double
NextDouble(uint16 type)
{
switch (type) {
case TIFF_UINT16_TYPE:
return Next<uint16>();
case TIFF_UINT32_TYPE:
return Next<uint32>();
case TIFF_UFRACTION_TYPE:
{
double value = Next<uint32>();
return value / Next<uint32>();
}
case TIFF_INT16_TYPE:
return Next<int16>();
case TIFF_INT32_TYPE:
return Next<int32>();
case TIFF_FRACTION_TYPE:
{
double value = Next<int32>();
return value / Next<int32>();
}
case TIFF_FLOAT_TYPE:
return Next<float>();
case TIFF_DOUBLE_TYPE:
return Next<double>();
default:
return Next<uint8>();
}
}
status_t Status()
{ return fError >= B_OK ? B_OK : fError; };
off_t Seek(off_t offset, int32 mode)
{ return fStream.Seek(offset, mode); }
off_t Position()
{ return fStream.Position(); }
void SetSwap(bool yesNo) { fSwap = yesNo; };
bool IsSwapping() { return fSwap; };
BPositionIO& Stream() { return fStream; }
private:
BBufferIO fStream;
status_t fError;
bool fSwap;
};
#endif // READ_HELPER_H
+29
View File
@@ -0,0 +1,29 @@
/*
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef TIFF_H
#define TIFF_H
#include <SupportDefs.h>
enum types {
TIFF_UINT16_TYPE = 3,
TIFF_UINT32_TYPE,
TIFF_UFRACTION_TYPE,
TIFF_INT16_TYPE = 8,
TIFF_INT32_TYPE,
TIFF_FRACTION_TYPE,
TIFF_FLOAT_TYPE,
TIFF_DOUBLE_TYPE,
};
struct tiff_tag {
uint16 tag;
uint16 type;
uint32 length;
};
#endif // TIFF_H
+147
View File
@@ -0,0 +1,147 @@
/*
* Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include "RAWTranslator.h"
#include "RAW.h"
#include "TranslatorWindow.h"
#include <Application.h>
#define TEST_MODE 0
#if TEST_MODE
# include <Bitmap.h>
# include <BitmapStream.h>
# include <View.h>
# include <Window.h>
#endif
#include <stdio.h>
#include <string.h>
int
main(int argc, char **argv)
{
BApplication app("application/x-vnd.haiku-raw-translator");
#if TEST_MODE
if (argc > 1) {
for (int i = 1; i < argc; i++) {
BFile file;
status_t status = file.SetTo(argv[i], B_READ_ONLY);
if (status != B_OK) {
fprintf(stderr, "Cannot read file %s: %s\n", argv[i],
strerror(status));
continue;
}
DCRaw raw(file);
try {
status = raw.Identify();
} catch (status_t error) {
status = error;
}
if (status < B_OK) {
fprintf(stderr, "Could not identify file %s: %s\n",
argv[i], strerror(status));
continue;
}
image_meta_info meta;
raw.GetMetaInfo(meta);
printf("manufacturer: %s\n", meta.manufacturer);
printf("model: %s\n", meta.model);
printf("software: %s\n", meta.software);
printf("flash used: %g\n", meta.flash_used);
printf("ISO speed: %g\n", meta.iso_speed);
printf("shutter: ");
if (meta.shutter >= 1)
printf("%g sec\n", meta.shutter);
else
printf("1/%g sec\n", 1 / meta.shutter);
printf("aperture: %g\n", meta.aperture);
printf("focal length: %g mm\n", meta.focal_length);
printf("pixel aspect: %g\n", meta.pixel_aspect);
printf("flip: %d\n", meta.flip);
printf("shot order: %ld\n", meta.shot_order);
printf("DNG version: %ld\n", meta.dng_version);
printf("Camera White Balance:");
for (int32 i = 0; i < 4; i++) {
printf(" %g", meta.camera_multipliers[i]);
}
putchar('\n');
for (int32 i = 0; i < (int32)raw.CountImages(); i++) {
image_data_info data;
raw.ImageAt(i, data);
printf(" [%ld] %s %lu x %lu (%ld bits per sample, compression %ld)\n",
i, data.is_raw ? "RAW " : "JPEG",
data.width, data.height, data.bits_per_sample, data.compression);
if (!data.is_raw) {
// write data to file
uint8* buffer;
size_t bufferSize;
try {
status = raw.ReadImageAt(i, buffer, bufferSize);
} catch (status_t error) {
status = error;
}
if (status == B_OK) {
BString name = "/tmp/output";
name << i << ".jpg";
BFile output(name.String(),
B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY);
output.Write(buffer, bufferSize);
}
} else {
RAWTranslator translator;
BBitmapStream output;
BBitmap* bitmap;
status_t status = translator.DerivedTranslate(&file, NULL,
NULL, B_TRANSLATOR_BITMAP, &output, 0);
if (status == B_OK)
status = output.DetachBitmap(&bitmap);
if (status == B_OK) {
BWindow* window = new BWindow(BRect(50, 50,
bitmap->Bounds().Width() + 50,
bitmap->Bounds().Height() + 50),
"RAW", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS
| B_NOT_RESIZABLE);
BView* view = new BView(window->Bounds(), NULL,
B_WILL_DRAW, B_FOLLOW_NONE);
window->AddChild(view);
window->Show();
snooze(300000);
window->Lock();
view->DrawBitmap(bitmap, window->Bounds());
view->Sync();
window->Unlock();
delete bitmap;
wait_for_thread(window->Thread(), &status);
}
}
}
}
return 0;
}
#endif
status_t status = LaunchTranslatorWindow(new RAWTranslator, "RAW Settings",
BRect(0, 0, 225, 175));
if (status != B_OK)
return 1;
app.Run();
return 0;
}