Patch by Alex Wilson (yourpalal): Converting the JPEG Translator to using the
same BaseTranslator framework as many other translators are already using and converting it to using layout management for the interface. Great work! Thanks a lot! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36465 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -50,6 +50,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <jpeglib.h>
|
#include <jpeglib.h>
|
||||||
|
|
||||||
|
#include "BaseTranslator.h"
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
#define SETTINGS_FILE "JPEGTranslator"
|
#define SETTINGS_FILE "JPEGTranslator"
|
||||||
@@ -76,21 +77,17 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define VIEW_LABEL_PHOTOSHOPCMYK "Use CMYK code with 0 for 100% ink coverage"
|
#define VIEW_LABEL_PHOTOSHOPCMYK "Use CMYK code with 0 for 100% ink coverage"
|
||||||
#define VIEW_LABEL_SHOWREADERRORBOX "Show warning messages"
|
#define VIEW_LABEL_SHOWREADERRORBOX "Show warning messages"
|
||||||
|
|
||||||
|
// strings for use in TranslatorSettings
|
||||||
|
#define JPEG_SET_SMOOTHING "smoothing"
|
||||||
|
#define JPEG_SET_QUALITY "quality"
|
||||||
|
#define JPEG_SET_PROGRESSIVE "progressive"
|
||||||
|
#define JPEG_SET_OPT_COLORS "optimize"
|
||||||
|
#define JPEG_SET_SMALL_FILES "filesSmaller"
|
||||||
|
#define JPEG_SET_GRAY1_AS_RGB24 "gray"
|
||||||
|
#define JPEG_SET_ALWAYS_RGB32 "always"
|
||||||
|
#define JPEG_SET_PHOTOSHOP_CMYK "cmyk"
|
||||||
|
#define JPEG_SET_SHOWREADWARNING "readWarning"
|
||||||
|
|
||||||
//! Settings storage structure
|
|
||||||
struct jpeg_settings {
|
|
||||||
// compression
|
|
||||||
uchar Smoothing; // default: 0
|
|
||||||
uchar Quality; // default: 95
|
|
||||||
bool Progressive; // default: true
|
|
||||||
bool OptimizeColors; // default: true
|
|
||||||
bool SmallerFile; // default: false only used if (OptimizeColors == true)
|
|
||||||
bool B_GRAY1_as_B_RGB24; // default: false if false gray1 converted to gray8, else to rgb24
|
|
||||||
// decompression
|
|
||||||
bool Always_B_RGB32; // default: true
|
|
||||||
bool PhotoshopCMYK; // default: true
|
|
||||||
bool ShowReadWarningBox; // default: true
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -99,52 +96,75 @@ struct jpeg_settings {
|
|||||||
*/
|
*/
|
||||||
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);
|
|
||||||
virtual const char* UpdateText() const;
|
virtual const char* UpdateText() const;
|
||||||
void ResizeToPreferred();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable char fStatusLabel[12];
|
mutable char fStatusLabel[12];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SView : public BView {
|
class JPEGTranslator : public BaseTranslator {
|
||||||
public:
|
|
||||||
SView(BRect frame, const char *name);
|
|
||||||
virtual void AttachedToWindow();
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Configuration view for reading settings
|
|
||||||
class TranslatorReadView : public SView {
|
|
||||||
public:
|
public:
|
||||||
TranslatorReadView(BRect frame, const char* name, jpeg_settings* settings);
|
JPEGTranslator();
|
||||||
|
|
||||||
|
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,
|
||||||
|
const jmp_buf* longJumpBuffer);
|
||||||
|
status_t Decompress(BPositionIO* in, BPositionIO* out,
|
||||||
|
BMessage* ioExtension, const jmp_buf* longJumpBuffer);
|
||||||
|
status_t Error(j_common_ptr cinfo, status_t error = B_ERROR);
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TranslatorReadView : public BView {
|
||||||
|
public:
|
||||||
|
TranslatorReadView(const char* name, TranslatorSettings* settings);
|
||||||
|
virtual ~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* fAlwaysRGB32;
|
BCheckBox* fAlwaysRGB32;
|
||||||
BCheckBox* fPhotoshopCMYK;
|
BCheckBox* fPhotoshopCMYK;
|
||||||
BCheckBox* fShowErrorBox;
|
BCheckBox* fShowErrorBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//! Configuration view for writing settings
|
class TranslatorWriteView : public BView {
|
||||||
class TranslatorWriteView : public SView {
|
|
||||||
public:
|
public:
|
||||||
TranslatorWriteView(BRect frame, const char* name, jpeg_settings* settings);
|
TranslatorWriteView(const char* name, TranslatorSettings* settings);
|
||||||
|
virtual ~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;
|
||||||
SSlider* fSmoothingSlider;
|
SSlider* fSmoothingSlider;
|
||||||
BCheckBox* fProgress;
|
BCheckBox* fProgress;
|
||||||
@@ -153,25 +173,21 @@ class TranslatorWriteView : public SView {
|
|||||||
BCheckBox* fGrayAsRGB24;
|
BCheckBox* fGrayAsRGB24;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TranslatorAboutView : public SView {
|
|
||||||
|
class TranslatorAboutView : public BView {
|
||||||
public:
|
public:
|
||||||
TranslatorAboutView(BRect frame, const char* name);
|
TranslatorAboutView(const char* name);
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Configuration view
|
|
||||||
class TranslatorView : public BTabView {
|
class TranslatorView : public BTabView {
|
||||||
public:
|
public:
|
||||||
TranslatorView(BRect frame, const char *name);
|
TranslatorView(const char* name, TranslatorSettings* settings);
|
||||||
virtual ~TranslatorView();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
jpeg_settings fSettings;
|
BView* fAboutView;
|
||||||
};
|
BView* fReadView;
|
||||||
|
BView* fWriteView;
|
||||||
//! Window used for configuration
|
|
||||||
class TranslatorWindow : public BWindow {
|
|
||||||
public:
|
|
||||||
TranslatorWindow(bool quitOnClose = true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -190,7 +206,7 @@ EXTERN(void) be_jpeg_stdio_dest(j_compress_ptr cinfo, BPositionIO *outfile); //
|
|||||||
// (so user can decide to show dialog-boxes or not)
|
// (so user can decide to show dialog-boxes or not)
|
||||||
//---------------------------------------------------
|
//---------------------------------------------------
|
||||||
EXTERN(struct jpeg_error_mgr *) be_jpeg_std_error (struct jpeg_error_mgr * err,
|
EXTERN(struct jpeg_error_mgr *) be_jpeg_std_error (struct jpeg_error_mgr * err,
|
||||||
jpeg_settings * settings, const jmp_buf* longJumpBuffer);
|
TranslatorSettings * settings, const jmp_buf* longJumpBuffer);
|
||||||
// implemented in "be_jerror.cpp"
|
// implemented in "be_jerror.cpp"
|
||||||
|
|
||||||
#endif // _JPEGTRANSLATOR_H_
|
#endif // _JPEGTRANSLATOR_H_
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
|
|||||||
SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) raw ] ;
|
SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) raw ] ;
|
||||||
# for TIFF.h and ReadHelper.h
|
# for TIFF.h and ReadHelper.h
|
||||||
|
|
||||||
|
SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) shared ] ;
|
||||||
|
#for BaseTranslator.h and friends
|
||||||
|
|
||||||
UseLibraryHeaders jpeg ;
|
UseLibraryHeaders jpeg ;
|
||||||
|
|
||||||
Translator JPEGTranslator :
|
Translator JPEGTranslator :
|
||||||
@@ -13,8 +16,7 @@ Translator JPEGTranslator :
|
|||||||
be_jerror.cpp
|
be_jerror.cpp
|
||||||
exif_parser.cpp
|
exif_parser.cpp
|
||||||
JPEGTranslator.cpp
|
JPEGTranslator.cpp
|
||||||
|
: be translation libtranslatorsutils.a libjpeg.so $(TARGET_LIBSTDC++)
|
||||||
: be translation libjpeg.so $(TARGET_LIBSTDC++)
|
|
||||||
: true
|
: true
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,9 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <jconfig.h>
|
#include <jconfig.h>
|
||||||
#include <jerror.h>
|
#include <jerror.h>
|
||||||
|
|
||||||
// JPEGTtanslator settings header to get SETTINGS struct
|
// JPEGTtanslator settings header to get settings stuff
|
||||||
#include "JPEGTranslator.h"
|
#include "JPEGTranslator.h"
|
||||||
|
#include "TranslatorSettings.h"
|
||||||
|
|
||||||
|
|
||||||
// Since Translator doesn't use it's own error table, we can use error_mgr's
|
// Since Translator doesn't use it's own error table, we can use error_mgr's
|
||||||
@@ -109,16 +110,18 @@ be_output_message (j_common_ptr cinfo)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
GLOBAL(struct jpeg_error_mgr *)
|
GLOBAL(struct jpeg_error_mgr *)
|
||||||
be_jpeg_std_error (struct jpeg_error_mgr * err, jpeg_settings *settings,
|
be_jpeg_std_error (struct jpeg_error_mgr * err, TranslatorSettings* settings,
|
||||||
const jmp_buf* longJumpBuffer)
|
const jmp_buf* longJumpBuffer)
|
||||||
{
|
{
|
||||||
|
settings->Acquire();
|
||||||
jpeg_std_error(err);
|
jpeg_std_error(err);
|
||||||
|
|
||||||
err->error_exit = be_error_exit;
|
err->error_exit = be_error_exit;
|
||||||
err->output_message = be_output_message;
|
err->output_message = be_output_message;
|
||||||
|
|
||||||
err->ShowReadWarnings = settings->ShowReadWarningBox;
|
err->ShowReadWarnings = settings->SetGetBool(JPEG_SET_SHOWREADWARNING, NULL);
|
||||||
memcpy(&(err->long_jump_buffer), longJumpBuffer, sizeof(jmp_buf));
|
memcpy(&(err->long_jump_buffer), longJumpBuffer, sizeof(jmp_buf));
|
||||||
|
|
||||||
|
settings->Release();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user