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 void SetVersion(int16 version); 36 status_t Encode(BPositionIO *target); 37 38 private: 39 void _WriteInt64ToStream(BPositionIO *stream, int64); 40 void _WriteUInt64ToStream(BPositionIO *stream, uint64); 41 void _WriteInt32ToStream(BPositionIO *stream, int32); 42 void _WriteUInt32ToStream(BPositionIO *stream, uint32); 43 void _WriteInt16ToStream(BPositionIO *stream, int16); 44 void _WriteUInt16ToStream(BPositionIO *stream, uint16); 45 void _WriteInt8ToStream(BPositionIO *stream, int8); 46 void _WriteUInt8ToStream(BPositionIO *stream, uint8); 47 void _WriteFillBlockToStream(BPositionIO *stream, 48 uint8 val, size_t count); 49 void _WriteBlockToStream(BPositionIO *stream, 50 uint8 *block, size_t count); 51 52 BDataArray* _PackBits(uint8 *buff, int32 len); 53 status_t _LoadChannelsFromRGBA32(void); 54 55 BPositionIO *fStream; 56 size_t fBitmapDataPos; 57 58 BDataArray psdChannel[4]; 59 BDataArray psdByteCounts[4]; 60 61 color_space fColorSpace; 62 int32 fInRowBytes; 63 int16 fChannels; 64 int16 fAlphaChannel; 65 int32 fWidth; 66 int32 fHeight; 67 int16 fCompression; 68 int16 fVersion; 69 70 bool fReady; 71 }; 72 73 74 #endif /* PSD_WRITER_H */ 75