19949213aSStephan Aßmus /* 29949213aSStephan Aßmus 39949213aSStephan Aßmus Copyright (c) 2002-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 #ifndef _JPEGTRANSLATOR_H_ 329949213aSStephan Aßmus #define _JPEGTRANSLATOR_H_ 339949213aSStephan Aßmus 349949213aSStephan Aßmus 359949213aSStephan Aßmus #include <Alert.h> 369949213aSStephan Aßmus #include <Application.h> 379949213aSStephan Aßmus #include <CheckBox.h> 389949213aSStephan Aßmus #include <FindDirectory.h> 399949213aSStephan Aßmus #include <Path.h> 409949213aSStephan Aßmus #include <Slider.h> 419949213aSStephan Aßmus #include <StringView.h> 42*b20d13f4SStefano Ceccherini #include <TabView.h> 439949213aSStephan Aßmus #include <TranslationKit.h> 449949213aSStephan Aßmus #include <TranslatorAddOn.h> 459949213aSStephan Aßmus 46dbc936acSStephan Aßmus #include <setjmp.h> 479949213aSStephan Aßmus #include <stdio.h> 489949213aSStephan Aßmus #include <stdlib.h> 499949213aSStephan Aßmus #include <string.h> 509949213aSStephan Aßmus 519949213aSStephan Aßmus #include <jpeglib.h> 529949213aSStephan Aßmus 539949213aSStephan Aßmus 549949213aSStephan Aßmus // Settings 55117da2d7SAxel Dörfler #define SETTINGS_FILE "JPEGTranslator" 569949213aSStephan Aßmus 579949213aSStephan Aßmus // View messages 589949213aSStephan Aßmus #define VIEW_MSG_SET_QUALITY 'JSCQ' 599949213aSStephan Aßmus #define VIEW_MSG_SET_SMOOTHING 'JSCS' 609949213aSStephan Aßmus #define VIEW_MSG_SET_PROGRESSIVE 'JSCP' 619949213aSStephan Aßmus #define VIEW_MSG_SET_OPTIMIZECOLORS 'JSBQ' 629949213aSStephan Aßmus #define VIEW_MSG_SET_SMALLERFILE 'JSSF' 639949213aSStephan Aßmus #define VIEW_MSG_SET_GRAY1ASRGB24 'JSGR' 649949213aSStephan Aßmus #define VIEW_MSG_SET_ALWAYSRGB32 'JSAC' 659949213aSStephan Aßmus #define VIEW_MSG_SET_PHOTOSHOPCMYK 'JSPC' 669949213aSStephan Aßmus #define VIEW_MSG_SET_SHOWREADERRORBOX 'JSEB' 679949213aSStephan Aßmus 689949213aSStephan Aßmus // View labels 699949213aSStephan Aßmus #define VIEW_LABEL_QUALITY "Output quality" 709949213aSStephan Aßmus #define VIEW_LABEL_SMOOTHING "Output smoothing strength" 719949213aSStephan Aßmus #define VIEW_LABEL_PROGRESSIVE "Use progressive compression" 729949213aSStephan Aßmus #define VIEW_LABEL_OPTIMIZECOLORS "Prevent colors 'washing out'" 739949213aSStephan Aßmus #define VIEW_LABEL_SMALLERFILE "Make file smaller (sligthtly worse quality)" 749949213aSStephan Aßmus #define VIEW_LABEL_GRAY1ASRGB24 "Write Black&White images as RGB24" 759949213aSStephan Aßmus #define VIEW_LABEL_ALWAYSRGB32 "Read Greyscale images as RGB32" 769949213aSStephan Aßmus #define VIEW_LABEL_PHOTOSHOPCMYK "Use CMYK code with 0 for 100% ink coverage" 779949213aSStephan Aßmus #define VIEW_LABEL_SHOWREADERRORBOX "Show warning messages" 789949213aSStephan Aßmus 799949213aSStephan Aßmus 808687ff64SAxel Dörfler //! Settings storage structure 81d8e2fb50SAxel Dörfler struct jpeg_settings { 829949213aSStephan Aßmus // compression 839949213aSStephan Aßmus uchar Smoothing; // default: 0 849949213aSStephan Aßmus uchar Quality; // default: 95 859949213aSStephan Aßmus bool Progressive; // default: true 869949213aSStephan Aßmus bool OptimizeColors; // default: true 879949213aSStephan Aßmus bool SmallerFile; // default: false only used if (OptimizeColors == true) 889949213aSStephan Aßmus bool B_GRAY1_as_B_RGB24; // default: false if false gray1 converted to gray8, else to rgb24 899949213aSStephan Aßmus // decompression 909949213aSStephan Aßmus bool Always_B_RGB32; // default: true 919949213aSStephan Aßmus bool PhotoshopCMYK; // default: true 929949213aSStephan Aßmus bool ShowReadWarningBox; // default: true 939949213aSStephan Aßmus }; 949949213aSStephan Aßmus 958687ff64SAxel Dörfler 968687ff64SAxel Dörfler /*! 978687ff64SAxel Dörfler Slider used in TranslatorView 988687ff64SAxel Dörfler With status showing actual value 998687ff64SAxel Dörfler */ 100d8e2fb50SAxel Dörfler class SSlider : public BSlider { 1019949213aSStephan Aßmus public: 1028687ff64SAxel Dörfler SSlider(BRect frame, const char *name, const char *label, 1038687ff64SAxel Dörfler BMessage *message, int32 minValue, int32 maxValue, 1048687ff64SAxel Dörfler orientation posture = B_HORIZONTAL, 1058687ff64SAxel Dörfler thumb_style thumbType = B_BLOCK_THUMB, 1068687ff64SAxel Dörfler uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, 1078687ff64SAxel Dörfler uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS); 108*b20d13f4SStefano Ceccherini virtual const char* UpdateText() const; 1099949213aSStephan Aßmus void ResizeToPreferred(); 1109949213aSStephan Aßmus 1119949213aSStephan Aßmus private: 1128687ff64SAxel Dörfler mutable char fStatusLabel[12]; 1139949213aSStephan Aßmus }; 1149949213aSStephan Aßmus 115*b20d13f4SStefano Ceccherini 116d8e2fb50SAxel Dörfler class SView : public BView { 1179949213aSStephan Aßmus public: 118*b20d13f4SStefano Ceccherini SView(BRect frame, const char *name); 119*b20d13f4SStefano Ceccherini virtual void AttachedToWindow(); 1209949213aSStephan Aßmus }; 1219949213aSStephan Aßmus 1228687ff64SAxel Dörfler //! Configuration view for reading settings 123d8e2fb50SAxel Dörfler class TranslatorReadView : public SView { 1249949213aSStephan Aßmus public: 125*b20d13f4SStefano Ceccherini TranslatorReadView(BRect frame, const char* name, jpeg_settings* settings); 1268687ff64SAxel Dörfler 1278687ff64SAxel Dörfler virtual void AttachedToWindow(); 1288687ff64SAxel Dörfler virtual void MessageReceived(BMessage* message); 1299949213aSStephan Aßmus 1309949213aSStephan Aßmus private: 131d8e2fb50SAxel Dörfler jpeg_settings* fSettings; 1328687ff64SAxel Dörfler BCheckBox* fAlwaysRGB32; 1338687ff64SAxel Dörfler BCheckBox* fPhotoshopCMYK; 1348687ff64SAxel Dörfler BCheckBox* fShowErrorBox; 1359949213aSStephan Aßmus }; 1369949213aSStephan Aßmus 137*b20d13f4SStefano Ceccherini 1388687ff64SAxel Dörfler //! Configuration view for writing settings 139d8e2fb50SAxel Dörfler class TranslatorWriteView : public SView { 1409949213aSStephan Aßmus public: 141*b20d13f4SStefano Ceccherini TranslatorWriteView(BRect frame, const char* name, jpeg_settings* settings); 1428687ff64SAxel Dörfler 1438687ff64SAxel Dörfler virtual void AttachedToWindow(); 1448687ff64SAxel Dörfler virtual void MessageReceived(BMessage* message); 1459949213aSStephan Aßmus 1469949213aSStephan Aßmus private: 147d8e2fb50SAxel Dörfler jpeg_settings* fSettings; 1488687ff64SAxel Dörfler SSlider* fQualitySlider; 1498687ff64SAxel Dörfler SSlider* fSmoothingSlider; 1508687ff64SAxel Dörfler BCheckBox* fProgress; 1518687ff64SAxel Dörfler BCheckBox* fOptimizeColors; 1528687ff64SAxel Dörfler BCheckBox* fSmallerFile; 1538687ff64SAxel Dörfler BCheckBox* fGrayAsRGB24; 1549949213aSStephan Aßmus }; 1559949213aSStephan Aßmus 156d8e2fb50SAxel Dörfler class TranslatorAboutView : public SView { 1579949213aSStephan Aßmus public: 158*b20d13f4SStefano Ceccherini TranslatorAboutView(BRect frame, const char* name); 1599949213aSStephan Aßmus }; 1609949213aSStephan Aßmus 1618687ff64SAxel Dörfler //! Configuration view 162*b20d13f4SStefano Ceccherini class TranslatorView : public BTabView { 1639949213aSStephan Aßmus public: 164*b20d13f4SStefano Ceccherini TranslatorView(BRect frame, const char *name); 1658687ff64SAxel Dörfler virtual ~TranslatorView(); 166d8e2fb50SAxel Dörfler 1678687ff64SAxel Dörfler virtual void AttachedToWindow(); 168*b20d13f4SStefano Ceccherini virtual void Select(int32 index); 1699949213aSStephan Aßmus 1709949213aSStephan Aßmus private: 171d8e2fb50SAxel Dörfler jpeg_settings fSettings; 1729949213aSStephan Aßmus }; 1739949213aSStephan Aßmus 174117da2d7SAxel Dörfler //! Window used for configuration 175d8e2fb50SAxel Dörfler class TranslatorWindow : public BWindow { 1769949213aSStephan Aßmus public: 177d8e2fb50SAxel Dörfler TranslatorWindow(bool quitOnClose = true); 1789949213aSStephan Aßmus }; 1799949213aSStephan Aßmus 1809949213aSStephan Aßmus 1819949213aSStephan Aßmus //--------------------------------------------------- 1829949213aSStephan Aßmus // "Initializers" for jpeglib 1839949213aSStephan Aßmus // based on default ones, 1849949213aSStephan Aßmus // modified to work on BPositionIO instead of FILE 1859949213aSStephan Aßmus //--------------------------------------------------- 1869949213aSStephan Aßmus EXTERN(void) be_jpeg_stdio_src(j_decompress_ptr cinfo, BPositionIO *infile); // from "be_jdatasrc.cpp" 1879949213aSStephan Aßmus EXTERN(void) be_jpeg_stdio_dest(j_compress_ptr cinfo, BPositionIO *outfile); // from "be_jdatadst.cpp" 1889949213aSStephan Aßmus 1899949213aSStephan Aßmus //--------------------------------------------------- 1909949213aSStephan Aßmus // Error output functions 1919949213aSStephan Aßmus // based on the one from jerror.c 1929949213aSStephan Aßmus // modified to use settings 1939949213aSStephan Aßmus // (so user can decide to show dialog-boxes or not) 1949949213aSStephan Aßmus //--------------------------------------------------- 195b91634cbSStephan Aßmus EXTERN(struct jpeg_error_mgr *) be_jpeg_std_error (struct jpeg_error_mgr * err, 196b91634cbSStephan Aßmus jpeg_settings * settings, const jmp_buf* longJumpBuffer); 197b91634cbSStephan Aßmus // implemented in "be_jerror.cpp" 198117da2d7SAxel Dörfler 1999949213aSStephan Aßmus #endif // _JPEGTRANSLATOR_H_ 200