1 /* 2 * Copyright 2013, Gerasim Troeglazov, 3dEyes@gmail.com. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #ifndef PSD_WRITER_H 8 #define PSD_WRITER_H 9 10 #include <stdlib.h> 11 #include <stdio.h> 12 #include <string.h> 13 14 #include <Translator.h> 15 #include <TranslatorFormats.h> 16 #include <TranslationDefs.h> 17 #include <GraphicsDefs.h> 18 #include <InterfaceDefs.h> 19 #include <String.h> 20 #include <DataIO.h> 21 #include <File.h> 22 #include <ByteOrder.h> 23 #include <List.h> 24 25 #include "PSDLoader.h" 26 #include "DataArray.h" 27 28 class PSDWriter { 29 public: 30 PSDWriter(BPositionIO *stream); 31 ~PSDWriter(); 32 33 bool IsReady(void); 34 void SetCompression(int16 compression); 35 status_t Encode(BPositionIO *target); 36 37 private: 38 void _WriteInt32ToStream(BPositionIO *stream, int32); 39 void _WriteUInt32ToStream(BPositionIO *stream, uint32); 40 void _WriteInt16ToStream(BPositionIO *stream, int16); 41 void _WriteUInt16ToStream(BPositionIO *stream, uint16); 42 void _WriteInt8ToStream(BPositionIO *stream, int8); 43 void _WriteUInt8ToStream(BPositionIO *stream, uint8); 44 void _WriteFillBlockToStream(BPositionIO *stream, 45 uint8 val, size_t count); 46 void _WriteBlockToStream(BPositionIO *stream, 47 uint8 *block, size_t count); 48 49 BDataArray* PackBits(uint8 *buff, int32 len); 50 51 BPositionIO *fStream; 52 size_t fBitmapDataPos; 53 54 color_space fColorSpace; 55 int32 fInRowBytes; 56 int16 fChannels; 57 int32 fWidth; 58 int32 fHeight; 59 int16 fCompression; 60 61 bool fReady; 62 }; 63 64 65 #endif /* PSD_WRITER_H */ 66