1 /******************************************************************************** 2 / 3 / File: TranslatorFormats.h 4 / 5 / Description: Defines for common "lowest common denominator" formats 6 / used in the Translation Kit. 7 / 8 / Copyright 1998, Be Incorporated, All Rights Reserved. 9 / Copyright 1995-1997, Jon Watte 10 / 11 ********************************************************************************/ 12 13 14 #ifndef _TRANSLATOR_FORMATS_H 15 #define _TRANSLATOR_FORMATS_H 16 17 18 #include <GraphicsDefs.h> 19 #include <Rect.h> 20 21 /* extensions used in the extension BMessage. Use of these */ 22 /* is described in the documentation. */ 23 24 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_HEADER_ONLY[]; 25 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_DATA_ONLY[]; 26 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_COMMENT[]; 27 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_TIME[]; 28 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_FRAME[]; 29 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_BITMAP_RECT[]; 30 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_BITMAP_COLOR_SPACE[]; 31 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_BITMAP_PALETTE[]; 32 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_CHANNEL[]; 33 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_MONO[]; 34 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_MARKER[]; 35 _IMPEXP_TRANSLATION extern char B_TRANSLATOR_EXT_SOUND_LOOP[]; 36 37 #if defined(_DATATYPES_COMPATIBLE_) 38 #define kCommentExtension "/comment" 39 #define kTimeExtension "/time" 40 #define kFrameExtension "/frame" 41 #define kBitsRectExtension "bits/Rect" 42 #define kBitsSpaceExtension "bits/space" 43 #define kHeaderExtension "/headerOnly" 44 #define kDataExtension "/dataOnly" 45 #define kNoisChannelExtension "nois/channel" 46 #define kNoisMonoExtension "nois/mono" 47 #define kNoisMarkerExtension "nois/marker" 48 #define kNoisLoopExtension "nois/loop" 49 #endif 50 51 52 /* For each data group, there is a "standard" format that */ 53 /* all translators should support. */ 54 /* These type codes are lower-case because they are already */ 55 /* established standards in the Be developer community. */ 56 enum TranslatorGroups { 57 B_TRANSLATOR_BITMAP = 'bits', /* TranslatorBitmap */ 58 B_TRANSLATOR_PICTURE = 'pict', /* BPicture data */ 59 B_TRANSLATOR_TEXT = 'TEXT', /* B_ASCII_TYPE */ 60 B_TRANSLATOR_SOUND = 'nois', /* TranslatorSound */ 61 B_TRANSLATOR_MIDI = 'midi', /* standard MIDI */ 62 B_TRANSLATOR_MEDIA = 'mhi!', /* a stream of stuff */ 63 B_TRANSLATOR_NONE = 'none', 64 B_TRANSLATOR_ANY_TYPE = 0 65 }; 66 #if defined(_DATATYPES_COMPATIBLE_) 67 #define kAnyType 0 68 #endif 69 70 71 /* some pre-defined data format type codes */ 72 73 enum { 74 /* bitmap formats (B_TRANSLATOR_BITMAP) */ 75 B_GIF_FORMAT = 'GIF ', 76 B_JPEG_FORMAT = 'JPEG', 77 B_PNG_FORMAT = 'PNG ', 78 B_PPM_FORMAT = 'PPM ', 79 B_TGA_FORMAT = 'TGA ', 80 B_BMP_FORMAT = 'BMP ', 81 B_TIFF_FORMAT = 'TIFF', 82 83 /* line drawing formats (B_TRANSLATOR_PICTURE) */ 84 B_DXF_FORMAT = 'DXF ', 85 B_EPS_FORMAT = 'EPS ', 86 B_PICT_FORMAT = 'PICT', /* MacOS PICT file */ 87 88 /* sound file formats (B_TRANSLATOR_SOUND) */ 89 B_WAV_FORMAT = 'WAV ', 90 B_AIFF_FORMAT = 'AIFF', 91 B_CD_FORMAT = 'CD ', /* 44 kHz, stereo, 16 bit, linear, big-endian */ 92 B_AU_FORMAT = 'AU ', /* Sun ulaw */ 93 94 /* text file formats (B_TRANSLATOR_TEXT) */ 95 B_STYLED_TEXT_FORMAT = 'STXT' 96 }; 97 98 99 100 /* This is the standard bitmap format */ 101 /* Note that data is always in big-endian format in the stream! */ 102 struct TranslatorBitmap { 103 uint32 magic; /* B_TRANSLATOR_BITMAP */ 104 BRect bounds; 105 uint32 rowBytes; 106 color_space colors; 107 uint32 dataSize; 108 }; /* data follows, padded to rowBytes */ 109 110 /* This is the standard sound format */ 111 /* Note that data is always in big-endian format in the stream! */ 112 struct TranslatorSound { 113 uint32 magic; /* B_TRANSLATOR_SOUND */ 114 uint32 channels; /* Left should always be first */ 115 float sampleFreq; /* 16 bit linear is assumed */ 116 uint32 numFrames; 117 }; /* data follows */ 118 119 /* This is the standard styled text format */ 120 /* Note that it is of group type text! */ 121 /* Skip any records types you don't know about. */ 122 /* Always big-endian. */ 123 struct TranslatorStyledTextRecordHeader { 124 uint32 magic; 125 uint32 header_size; 126 uint32 data_size; 127 }; /* any number of records */ 128 struct TranslatorStyledTextStreamHeader { 129 #if defined(__cplusplus) 130 enum { 131 STREAM_HEADER_MAGIC = 'STXT' 132 }; 133 #endif 134 TranslatorStyledTextRecordHeader header; 135 int32 version; /* 100 */ 136 }; /* no data for this header */ 137 struct TranslatorStyledTextTextHeader { 138 #if defined(__cplusplus) 139 enum { 140 TEXT_HEADER_MAGIC = 'TEXT' 141 }; 142 #endif 143 TranslatorStyledTextRecordHeader header; 144 int32 charset; /* Always write B_UTF8 for now! */ 145 }; /* text data follows */ 146 struct TranslatorStyledTextStyleHeader { 147 #if defined(__cplusplus) 148 enum { 149 STYLE_HEADER_MAGIC = 'STYL' 150 }; 151 #endif 152 TranslatorStyledTextRecordHeader header; 153 uint32 apply_offset; 154 uint32 apply_length; 155 }; /* flattened R3 BTextView style records for preceding text */ 156 #if 0 157 /* format of the STYL record data (always big-endian) FYI: */ 158 struct { 159 uchar magic[4]; /* 41 6c 69 21 */ 160 uchar version[4]; /* 00 00 00 00 */ 161 int32 count; 162 struct { 163 int32 offset; 164 char family[64]; 165 char style[64]; 166 float size; 167 float shear; /* typically 90.0 */ 168 uint16 face; /* typically 0 */ 169 uint8 red; 170 uint8 green; 171 uint8 blue; 172 uint8 alpha; /* 255 == opaque */ 173 uint16 _reserved_; /* 0 */ 174 } styles[]; 175 }; 176 #endif 177 178 #endif /* _TRANSLATOR_FORMATS_H */ 179 180