xref: /haiku/src/add-ons/translators/jpeg2000/JPEG2000Translator.h (revision 5f8613a22c9017f233b6968ad7cf10c4df9674a2)
19949213aSStephan Aßmus /*
29949213aSStephan Aßmus 
39949213aSStephan Aßmus Copyright (c) 2003, Marcin 'Shard' Konicki
49949213aSStephan Aßmus All rights reserved.
59949213aSStephan Aßmus 
69949213aSStephan Aßmus Redistribution and use in source and binary forms, with or without
79949213aSStephan Aßmus modification, are permitted provided that the following conditions are met:
89949213aSStephan Aßmus 
99949213aSStephan Aßmus     * Redistributions of source code must retain the above copyright notice,
109949213aSStephan Aßmus       this list of conditions and the following disclaimer.
119949213aSStephan Aßmus     * Redistributions in binary form must reproduce the above copyright notice,
129949213aSStephan Aßmus       this list of conditions and the following disclaimer in the documentation and/or
139949213aSStephan Aßmus       other materials provided with the distribution.
149949213aSStephan Aßmus     * Name "Marcin Konicki", "Shard" or any combination of them,
159949213aSStephan Aßmus       must not be used to endorse or promote products derived from this
169949213aSStephan Aßmus       software without specific prior written permission from Marcin Konicki.
179949213aSStephan Aßmus 
189949213aSStephan Aßmus THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
199949213aSStephan Aßmus ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
209949213aSStephan Aßmus THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
219949213aSStephan Aßmus ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
229949213aSStephan Aßmus BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
239949213aSStephan Aßmus OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
249949213aSStephan Aßmus PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
259949213aSStephan Aßmus OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
269949213aSStephan Aßmus WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
279949213aSStephan Aßmus OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
289949213aSStephan Aßmus EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
299949213aSStephan Aßmus 
309949213aSStephan Aßmus */
319949213aSStephan Aßmus 
329949213aSStephan Aßmus #ifndef _JP2TRANSLATOR_H_
339949213aSStephan Aßmus #define _JP2TRANSLATOR_H_
349949213aSStephan Aßmus 
359949213aSStephan Aßmus 
369949213aSStephan Aßmus #include <Alert.h>
379949213aSStephan Aßmus #include <Application.h>
38c44966dfSJérôme Duval #include <Catalog.h>
399949213aSStephan Aßmus #include <CheckBox.h>
409949213aSStephan Aßmus #include <FindDirectory.h>
419949213aSStephan Aßmus #include <Path.h>
429949213aSStephan Aßmus #include <Slider.h>
439949213aSStephan Aßmus #include <StringView.h>
44bdaaeb0cSStefano Ceccherini #include <TabView.h>
459949213aSStephan Aßmus #include <TranslationKit.h>
469949213aSStephan Aßmus #include <TranslatorAddOn.h>
479949213aSStephan Aßmus 
489949213aSStephan Aßmus #include <stdio.h>
499949213aSStephan Aßmus #include <stdlib.h>
509949213aSStephan Aßmus #include <string.h>
519949213aSStephan Aßmus 
5294a204f0SStephan Aßmus #include "BaseTranslator.h"
53fdfe641dSJérôme Duval #include "jasper/jasper.h"
549949213aSStephan Aßmus 
55*5f8613a2SAugustin Cavalier // jasper includes stdbool
56*5f8613a2SAugustin Cavalier #undef bool
57*5f8613a2SAugustin Cavalier 
589949213aSStephan Aßmus 
59546208a5SOliver Tappe #undef B_TRANSLATION_CONTEXT
60546208a5SOliver Tappe #define B_TRANSLATION_CONTEXT "JPEG2000Translator"
61c44966dfSJérôme Duval 
629949213aSStephan Aßmus // Settings
6394a204f0SStephan Aßmus #define JP2_SETTINGS_FILE	"JPEG2000Translator"
6494a204f0SStephan Aßmus 
6570d59669SSiarzhuk Zharski #define JP2_SET_QUALITY "quality"
6670d59669SSiarzhuk Zharski #define JP2_SET_GRAY1_AS_B_RGB24 "24 from gray1"
6770d59669SSiarzhuk Zharski #define JP2_SET_GRAY8_AS_B_RGB32 "32 from gray8"
6870d59669SSiarzhuk Zharski #define JP2_SET_JPC "jpc"
699949213aSStephan Aßmus 
709949213aSStephan Aßmus // View messages
719949213aSStephan Aßmus #define VIEW_MSG_SET_QUALITY 'JSCQ'
729949213aSStephan Aßmus #define	VIEW_MSG_SET_GRAY1ASRGB24 'JSGR'
739949213aSStephan Aßmus #define	VIEW_MSG_SET_JPC 'JSJC'
749949213aSStephan Aßmus #define	VIEW_MSG_SET_GRAYASRGB32 'JSAC'
759949213aSStephan Aßmus 
76117da2d7SAxel Dörfler 
77117da2d7SAxel Dörfler /*!
78117da2d7SAxel Dörfler 	Slider used in TranslatorView
79117da2d7SAxel Dörfler 	With status showing actual value
80117da2d7SAxel Dörfler */
81117da2d7SAxel Dörfler class SSlider : public BSlider {
829949213aSStephan Aßmus public:
8394a204f0SStephan Aßmus 	SSlider(const char* name, const char* label,
84117da2d7SAxel Dörfler 		BMessage* message, int32 minValue, int32 maxValue,
85117da2d7SAxel Dörfler 		orientation posture = B_HORIZONTAL,
86117da2d7SAxel Dörfler 		thumb_style thumbType = B_BLOCK_THUMB,
87117da2d7SAxel Dörfler 		uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS);
886bda235aSStefano Ceccherini 	const char*	UpdateText() const;
899949213aSStephan Aßmus 
909949213aSStephan Aßmus private:
91117da2d7SAxel Dörfler 	mutable char fStatusLabel[12];
929949213aSStephan Aßmus };
939949213aSStephan Aßmus 
94117da2d7SAxel Dörfler //!	Configuration view for reading settings
9594a204f0SStephan Aßmus class TranslatorReadView : public BView {
969949213aSStephan Aßmus public:
9794a204f0SStephan Aßmus 	TranslatorReadView(const char* name, TranslatorSettings* settings);
9894a204f0SStephan Aßmus 	~TranslatorReadView();
99117da2d7SAxel Dörfler 
100117da2d7SAxel Dörfler 	virtual void	AttachedToWindow();
101117da2d7SAxel Dörfler 	virtual void	MessageReceived(BMessage* message);
1029949213aSStephan Aßmus 
1039949213aSStephan Aßmus private:
10494a204f0SStephan Aßmus 	TranslatorSettings*	fSettings;
105117da2d7SAxel Dörfler 	BCheckBox*		fGrayAsRGB32;
1069949213aSStephan Aßmus };
1079949213aSStephan Aßmus 
108117da2d7SAxel Dörfler //! Configuration view for writing settings
10994a204f0SStephan Aßmus class TranslatorWriteView : public BView {
1109949213aSStephan Aßmus public:
11194a204f0SStephan Aßmus 	TranslatorWriteView(const char* name, TranslatorSettings* settings);
11294a204f0SStephan Aßmus 	~TranslatorWriteView();
113117da2d7SAxel Dörfler 
114117da2d7SAxel Dörfler 	virtual void	AttachedToWindow();
115117da2d7SAxel Dörfler 	virtual void	MessageReceived(BMessage* message);
1169949213aSStephan Aßmus 
1179949213aSStephan Aßmus private:
11894a204f0SStephan Aßmus 	TranslatorSettings*	fSettings;
119117da2d7SAxel Dörfler 	SSlider*		fQualitySlider;
120117da2d7SAxel Dörfler 	BCheckBox*		fGrayAsRGB24;
121117da2d7SAxel Dörfler 	BCheckBox*		fCodeStreamOnly;
1229949213aSStephan Aßmus };
1239949213aSStephan Aßmus 
12494a204f0SStephan Aßmus class TranslatorAboutView : public BView {
1259949213aSStephan Aßmus public:
12694a204f0SStephan Aßmus 	TranslatorAboutView(const char* name);
1279949213aSStephan Aßmus };
1289949213aSStephan Aßmus 
129117da2d7SAxel Dörfler //!	Configuration view
130bdaaeb0cSStefano Ceccherini class TranslatorView : public BTabView {
1319949213aSStephan Aßmus public:
13294a204f0SStephan Aßmus 	TranslatorView(const char* name, TranslatorSettings* settings);
13394a204f0SStephan Aßmus };
13494a204f0SStephan Aßmus 
13594a204f0SStephan Aßmus class JP2Translator : public BaseTranslator {
13694a204f0SStephan Aßmus public:
13794a204f0SStephan Aßmus 	JP2Translator();
13894a204f0SStephan Aßmus 	virtual status_t DerivedIdentify(BPositionIO* inSource,
13994a204f0SStephan Aßmus 		const translation_format* inFormat, BMessage* ioExtension,
14094a204f0SStephan Aßmus 		translator_info* outInfo, uint32 outType);
14194a204f0SStephan Aßmus 
14294a204f0SStephan Aßmus 	virtual status_t DerivedTranslate(BPositionIO* inSource,
14394a204f0SStephan Aßmus 		const translator_info* inInfo, BMessage* ioExtension,
14494a204f0SStephan Aßmus 		uint32 outType, BPositionIO* outDestination, int32 baseType);
14594a204f0SStephan Aßmus 
14694a204f0SStephan Aßmus 	virtual BView* NewConfigView(TranslatorSettings* settings);
14794a204f0SStephan Aßmus 
148117da2d7SAxel Dörfler 
1499949213aSStephan Aßmus private:
1509949213aSStephan Aßmus 	status_t Copy(BPositionIO* in, BPositionIO* out);
1519949213aSStephan Aßmus 	status_t Compress(BPositionIO* in, BPositionIO* out);
1529949213aSStephan Aßmus 	status_t Decompress(BPositionIO* in, BPositionIO* out);
15394a204f0SStephan Aßmus 
15494a204f0SStephan Aßmus 	status_t PopulateInfoFromFormat(translator_info* info,
15594a204f0SStephan Aßmus 		uint32 formatType, translator_id id = 0);
15694a204f0SStephan Aßmus 	status_t PopulateInfoFromFormat(translator_info* info,
15794a204f0SStephan Aßmus 		uint32 formatType, const translation_format* formats,
15894a204f0SStephan Aßmus 		int32 formatCount);
15994a204f0SStephan Aßmus };
16094a204f0SStephan Aßmus 
161fdfe641dSJérôme Duval 
16294a204f0SStephan Aßmus status_t Error(jas_stream_t* stream, jas_image_t* image, jas_matrix_t** pixels,
163fdfe641dSJérôme Duval 	int32 pixels_count, uchar* scanline, status_t error = B_ERROR);
1649949213aSStephan Aßmus 
1659949213aSStephan Aßmus #endif // _JP2TRANSLATOR_H_
166