1 /*****************************************************************************/ 2 // PNGTranslator 3 // Written by Michael Wilber, Haiku Translation Kit Team 4 // 5 // PNGTranslator.h 6 // 7 // This BTranslator based object is for opening and writing 8 // PNG images. 9 // 10 // 11 // Copyright (c) 2003 Haiku Project 12 // 13 // Permission is hereby granted, free of charge, to any person obtaining a 14 // copy of this software and associated documentation files (the "Software"), 15 // to deal in the Software without restriction, including without limitation 16 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 17 // and/or sell copies of the Software, and to permit persons to whom the 18 // Software is furnished to do so, subject to the following conditions: 19 // 20 // The above copyright notice and this permission notice shall be included 21 // in all copies or substantial portions of the Software. 22 // 23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 // DEALINGS IN THE SOFTWARE. 30 /*****************************************************************************/ 31 32 #ifndef PNG_TRANSLATOR_H 33 #define PNG_TRANSLATOR_H 34 35 #include <Translator.h> 36 #include <TranslatorFormats.h> 37 #include <TranslationDefs.h> 38 #include <GraphicsDefs.h> 39 #include <InterfaceDefs.h> 40 #include <DataIO.h> 41 #include <File.h> 42 #include <ByteOrder.h> 43 #include <fs_attr.h> 44 #include "BaseTranslator.h" 45 46 // PNG Translator Settings 47 #define PNG_SETTING_INTERLACE "png /interlace" 48 49 #define PNG_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VERSION(1,0,0) 50 51 #define PNG_IN_QUALITY 0.8 52 #define PNG_IN_CAPABILITY 0.8 53 #define PNG_OUT_QUALITY 0.8 54 #define PNG_OUT_CAPABILITY 0.5 55 56 #define BBT_IN_QUALITY 0.8 57 #define BBT_IN_CAPABILITY 0.6 58 #define BBT_OUT_QUALITY 0.5 59 #define BBT_OUT_CAPABILITY 0.4 60 61 62 class PNGTranslator : public BaseTranslator { 63 public: 64 PNGTranslator(); 65 66 virtual status_t DerivedIdentify(BPositionIO *inSource, 67 const translation_format *inFormat, BMessage *ioExtension, 68 translator_info *outInfo, uint32 outType); 69 70 virtual status_t DerivedTranslate(BPositionIO *inSource, 71 const translator_info *inInfo, BMessage *ioExtension, 72 uint32 outType, BPositionIO *outDestination, int32 baseType); 73 74 virtual BView *NewConfigView(TranslatorSettings *settings); 75 76 protected: 77 virtual ~PNGTranslator(); 78 // this is protected because the object is deleted by the 79 // Release() function instead of being deleted directly by 80 // the user 81 82 private: 83 status_t translate_from_png_to_bits(BPositionIO *inSource, 84 BPositionIO *outDestination); 85 86 status_t translate_from_png(BPositionIO *inSource, uint32 outType, 87 BPositionIO *outDestination); 88 89 status_t translate_from_bits_to_png(BPositionIO *inSource, 90 BPositionIO *outDestination); 91 }; 92 93 #endif // #ifndef PNG_TRANSLATOR_H 94