2 * Copyright 2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 #include "RAWTranslator.h"
9 #include "TranslatorWindow.h"
11 #include <Application.h>
16 #if SHOW_MODE && TEST_MODE
18 # include <BitmapStream.h>
19 # include <LayoutBuilder.h>
28 #undef B_TRANSLATION_CONTEXT
29 #define B_TRANSLATION_CONTEXT "RAWTranslator main"
32 main(int argc
, char **argv
)
34 BApplication
app("application/x-vnd.Haiku-RAWTranslator");
38 for (int i
= 1; i
< argc
; i
++) {
40 status_t status
= file
.SetTo(argv
[i
], B_READ_ONLY
);
42 fprintf(stderr
, "Cannot read file %s: %s\n", argv
[i
],
50 status
= raw
.Identify();
51 } catch (status_t error
) {
56 fprintf(stderr
, "Could not identify file %s: %s\n",
57 argv
[i
], strerror(status
));
62 raw
.GetMetaInfo(meta
);
64 printf("manufacturer: %s\n", meta
.manufacturer
);
65 printf("model: %s\n", meta
.model
);
66 printf("software: %s\n", meta
.software
);
67 printf("flash used: %g\n", meta
.flash_used
);
68 printf("ISO speed: %g\n", meta
.iso_speed
);
69 if (meta
.shutter
>= 1)
70 printf("shutter: %g sec\n", meta
.shutter
);
72 printf("shutter: 1/%g sec\n", 1 / meta
.shutter
);
73 printf("aperture: %g\n", meta
.aperture
);
74 printf("focal length: %g mm\n", meta
.focal_length
);
75 printf("pixel aspect: %g\n", meta
.pixel_aspect
);
76 printf("flip: %d\n", meta
.flip
);
77 printf("shot order: %ld\n", meta
.shot_order
);
78 printf("DNG version: %ld\n", meta
.dng_version
);
79 printf("Camera White Balance:");
80 for (int32 i
= 0; i
< 4; i
++) {
81 printf(" %g", meta
.camera_multipliers
[i
]);
85 for (int32 i
= 0; i
< (int32
)raw
.CountImages(); i
++) {
89 printf(" [%ld] %s %lu x %lu (%ld bits per sample, compression %ld)\n",
90 i
, data
.is_raw
? "RAW " : "JPEG",
91 data
.width
, data
.height
, data
.bits_per_sample
, data
.compression
);
99 status
= raw
.ReadImageAt(i
, buffer
, bufferSize
);
100 } catch (status_t error
) {
103 if (status
== B_OK
) {
104 BString name
= "/tmp/output";
106 BFile
output(name
.String(),
107 B_CREATE_FILE
| B_ERASE_FILE
| B_WRITE_ONLY
);
108 output
.Write(buffer
, bufferSize
);
111 RAWTranslator translator
;
112 BBitmapStream output
;
115 status_t status
= translator
.DerivedTranslate(&file
, NULL
,
116 NULL
, B_TRANSLATOR_BITMAP
, &output
, 0);
118 status
= output
.DetachBitmap(&bitmap
);
119 if (status
== B_OK
) {
120 BWindow
* window
= new BWindow(BRect(0, 0, 1, 1),
121 B_TRANSLATE("RAW"), B_TITLED_WINDOW
,
122 B_ASYNCHRONOUS_CONTROLS
| B_NOT_RESIZABLE
|
123 B_AUTO_UPDATE_SIZE_LIMITS
);
124 BView
* view
= new BView(window
->Bounds(), NULL
,
125 B_WILL_DRAW
, B_FOLLOW_NONE
);
126 BLayoutBuilder::Group
<>(window
, B_HORIZONTAL
)
131 view
->DrawBitmap(bitmap
, window
->Bounds());
136 wait_for_thread(window
->Thread(), &status
);
146 status_t status
= LaunchTranslatorWindow(new RAWTranslator
,
147 B_TRANSLATE("RAW Settings"));