Patch by Alex Wilson (yourpalal): Convert the JPEG2000 Translator to use the
BaseTranslator framework and layout management. Big coding style clean up, too. Thanks a bunch, great work! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36466 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -48,11 +48,17 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "BaseTranslator.h"
|
||||||
#include "libjasper/jasper.h"
|
#include "libjasper/jasper.h"
|
||||||
|
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
#define SETTINGS_FILE "JPEG2000Translator"
|
#define JP2_SETTINGS_FILE "JPEG2000Translator"
|
||||||
|
|
||||||
|
#define JP2_SET_QUALITY "quality"
|
||||||
|
#define JP2_SET_GRAY1_AS_B_RGB24 "24 from gray1"
|
||||||
|
#define JP2_SET_GRAY8_AS_B_RGB32 "32 from gray8"
|
||||||
|
#define JP2_SET_JPC "jpc"
|
||||||
|
|
||||||
// View messages
|
// View messages
|
||||||
#define VIEW_MSG_SET_QUALITY 'JSCQ'
|
#define VIEW_MSG_SET_QUALITY 'JSCQ'
|
||||||
@@ -62,102 +68,97 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
// View labels
|
// View labels
|
||||||
#define VIEW_LABEL_QUALITY "Output quality"
|
#define VIEW_LABEL_QUALITY "Output quality"
|
||||||
#define VIEW_LABEL_GRAY1ASRGB24 "Write black-and-white images as RGB24"
|
|
||||||
#define VIEW_LABEL_JPC "Output only codestream (.jpc)"
|
#define VIEW_LABEL_JPC "Output only codestream (.jpc)"
|
||||||
|
#define VIEW_LABEL_GRAY1ASRGB24 "Write black-and-white images as RGB24"
|
||||||
#define VIEW_LABEL_GRAYASRGB32 "Read greyscale images as RGB32"
|
#define VIEW_LABEL_GRAYASRGB32 "Read greyscale images as RGB32"
|
||||||
|
|
||||||
|
|
||||||
//! Settings storage structure
|
|
||||||
struct jpeg_settings {
|
|
||||||
// compression
|
|
||||||
jpr_uchar_t Quality; // default: 25
|
|
||||||
bool JPC; // default: false // compress to JPC or JP2?
|
|
||||||
bool B_GRAY1_as_B_RGB24; // default: false // copress gray 1 as rgb24 or grayscale?
|
|
||||||
// decompression
|
|
||||||
bool B_GRAY8_as_B_RGB32; // default: true
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Slider used in TranslatorView
|
Slider used in TranslatorView
|
||||||
With status showing actual value
|
With status showing actual value
|
||||||
*/
|
*/
|
||||||
class SSlider : public BSlider {
|
class SSlider : public BSlider {
|
||||||
public:
|
public:
|
||||||
SSlider(BRect frame, const char *name, const char *label,
|
SSlider(const char* name, const char* label,
|
||||||
BMessage *message, int32 minValue, int32 maxValue,
|
BMessage* message, int32 minValue, int32 maxValue,
|
||||||
orientation posture = B_HORIZONTAL,
|
orientation posture = B_HORIZONTAL,
|
||||||
thumb_style thumbType = B_BLOCK_THUMB,
|
thumb_style thumbType = B_BLOCK_THUMB,
|
||||||
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS);
|
const char* UpdateText() const;
|
||||||
const char* UpdateText() const;
|
|
||||||
void ResizeToPreferred();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable char fStatusLabel[12];
|
mutable char fStatusLabel[12];
|
||||||
};
|
|
||||||
|
|
||||||
//! Basic view class with resizing to needed size
|
|
||||||
class SView : public BView {
|
|
||||||
public:
|
|
||||||
SView(BRect rect, const char* name);
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Configuration view for reading settings
|
//! Configuration view for reading settings
|
||||||
class TranslatorReadView : public SView {
|
class TranslatorReadView : public BView {
|
||||||
public:
|
public:
|
||||||
TranslatorReadView(BRect rect, const char* name, jpeg_settings* settings);
|
TranslatorReadView(const char* name, TranslatorSettings* settings);
|
||||||
|
~TranslatorReadView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jpeg_settings* fSettings;
|
TranslatorSettings* fSettings;
|
||||||
BCheckBox* fGrayAsRGB32;
|
BCheckBox* fGrayAsRGB32;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Configuration view for writing settings
|
//! Configuration view for writing settings
|
||||||
class TranslatorWriteView : public SView {
|
class TranslatorWriteView : public BView {
|
||||||
public:
|
public:
|
||||||
TranslatorWriteView(BRect rect, const char* name, jpeg_settings* settings);
|
TranslatorWriteView(const char* name, TranslatorSettings* settings);
|
||||||
|
~TranslatorWriteView();
|
||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jpeg_settings* fSettings;
|
TranslatorSettings* fSettings;
|
||||||
SSlider* fQualitySlider;
|
SSlider* fQualitySlider;
|
||||||
BCheckBox* fGrayAsRGB24;
|
BCheckBox* fGrayAsRGB24;
|
||||||
BCheckBox* fCodeStreamOnly;
|
BCheckBox* fCodeStreamOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TranslatorAboutView : public SView {
|
class TranslatorAboutView : public BView {
|
||||||
public:
|
public:
|
||||||
TranslatorAboutView(BRect rect, const char* name);
|
TranslatorAboutView(const char* name);
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Configuration view
|
//! Configuration view
|
||||||
class TranslatorView : public BTabView {
|
class TranslatorView : public BTabView {
|
||||||
public:
|
public:
|
||||||
TranslatorView(BRect rect, const char *name);
|
TranslatorView(const char* name, TranslatorSettings* settings);
|
||||||
virtual ~TranslatorView();
|
|
||||||
|
|
||||||
private:
|
|
||||||
jpeg_settings fSettings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Window used for configuration
|
class JP2Translator : public BaseTranslator {
|
||||||
class TranslatorWindow : public BWindow {
|
public:
|
||||||
public:
|
JP2Translator();
|
||||||
TranslatorWindow(bool quitOnClose = true);
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
status_t Copy(BPositionIO* in, BPositionIO* out);
|
||||||
|
status_t Compress(BPositionIO* in, BPositionIO* out);
|
||||||
|
status_t Decompress(BPositionIO* in, BPositionIO* out);
|
||||||
|
|
||||||
|
status_t PopulateInfoFromFormat(translator_info* info,
|
||||||
|
uint32 formatType, translator_id id = 0);
|
||||||
|
status_t PopulateInfoFromFormat(translator_info* info,
|
||||||
|
uint32 formatType, const translation_format* formats,
|
||||||
|
int32 formatCount);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
status_t Error(jas_stream_t* stream, jas_image_t* image, jas_matrix_t** pixels,
|
||||||
// Main functions of translator :)
|
int32 pixels_count, jpr_uchar_t* scanline, status_t error = B_ERROR);
|
||||||
status_t Copy(BPositionIO *in, BPositionIO *out);
|
|
||||||
status_t Compress(BPositionIO *in, BPositionIO *out);
|
|
||||||
status_t Decompress(BPositionIO *in, BPositionIO *out);
|
|
||||||
status_t Error(jas_stream_t *stream, jas_image_t *image, jas_matrix_t **pixels, int32 pixels_count, jpr_uchar_t *scanline, status_t error = B_ERROR);
|
|
||||||
|
|
||||||
#endif // _JP2TRANSLATOR_H_
|
#endif // _JP2TRANSLATOR_H_
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
|||||||
|
|
||||||
SubDirSysHdrs [ FDirName $(SUBDIR) libjasper ] ;
|
SubDirSysHdrs [ FDirName $(SUBDIR) libjasper ] ;
|
||||||
|
|
||||||
|
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ;
|
||||||
|
#for BaseTranslator.h and friends
|
||||||
|
|
||||||
# Exclude unwanted formats
|
# Exclude unwanted formats
|
||||||
CCFLAGS += -DEXCLUDE_MIF_SUPPORT
|
CCFLAGS += -DEXCLUDE_MIF_SUPPORT
|
||||||
-DEXCLUDE_PNM_SUPPORT
|
-DEXCLUDE_PNM_SUPPORT
|
||||||
@@ -66,7 +69,7 @@ Translator JPEG2000Translator :
|
|||||||
|
|
||||||
$(jasper_files)
|
$(jasper_files)
|
||||||
|
|
||||||
: be translation $(TARGET_LIBSUPC++)
|
: be translation libtranslatorsutils.a $(TARGET_LIBSUPC++)
|
||||||
: true
|
: true
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user