xref: /haiku/src/add-ons/translators/psd/PSDWriter.h (revision 2b01519444fb8e68325783b37e5163bbb3ba44cf)
13459199eSGerasim Troeglazov /*
23459199eSGerasim Troeglazov  * Copyright 2013, Gerasim Troeglazov, 3dEyes@gmail.com. All rights reserved.
33459199eSGerasim Troeglazov  * Distributed under the terms of the MIT License.
43459199eSGerasim Troeglazov  */
53459199eSGerasim Troeglazov 
63459199eSGerasim Troeglazov 
73459199eSGerasim Troeglazov #ifndef PSD_WRITER_H
83459199eSGerasim Troeglazov #define PSD_WRITER_H
93459199eSGerasim Troeglazov 
103459199eSGerasim Troeglazov #include <stdlib.h>
113459199eSGerasim Troeglazov #include <stdio.h>
123459199eSGerasim Troeglazov #include <string.h>
133459199eSGerasim Troeglazov 
143459199eSGerasim Troeglazov #include <Translator.h>
153459199eSGerasim Troeglazov #include <TranslatorFormats.h>
163459199eSGerasim Troeglazov #include <TranslationDefs.h>
173459199eSGerasim Troeglazov #include <GraphicsDefs.h>
183459199eSGerasim Troeglazov #include <InterfaceDefs.h>
193459199eSGerasim Troeglazov #include <String.h>
203459199eSGerasim Troeglazov #include <DataIO.h>
213459199eSGerasim Troeglazov #include <File.h>
223459199eSGerasim Troeglazov #include <ByteOrder.h>
233459199eSGerasim Troeglazov #include <List.h>
243459199eSGerasim Troeglazov 
253459199eSGerasim Troeglazov #include "PSDLoader.h"
265a65c297SGerasim Troeglazov #include "DataArray.h"
273459199eSGerasim Troeglazov 
283459199eSGerasim Troeglazov class PSDWriter {
293459199eSGerasim Troeglazov public:
303459199eSGerasim Troeglazov 					PSDWriter(BPositionIO *stream);
313459199eSGerasim Troeglazov 					~PSDWriter();
323459199eSGerasim Troeglazov 
337983058dSGerasim Troeglazov 	bool			IsReady(void);
347983058dSGerasim Troeglazov 	void			SetCompression(int16 compression);
356d7acad2SGerasim Troeglazov 	void			SetVersion(int16 version);
367983058dSGerasim Troeglazov 	status_t		Encode(BPositionIO *target);
373459199eSGerasim Troeglazov 
383459199eSGerasim Troeglazov private:
396d7acad2SGerasim Troeglazov 	void			_WriteInt64ToStream(BPositionIO *stream, int64);
406d7acad2SGerasim Troeglazov 	void			_WriteUInt64ToStream(BPositionIO *stream, uint64);
413459199eSGerasim Troeglazov 	void			_WriteInt32ToStream(BPositionIO *stream, int32);
423459199eSGerasim Troeglazov 	void			_WriteUInt32ToStream(BPositionIO *stream, uint32);
433459199eSGerasim Troeglazov 	void			_WriteInt16ToStream(BPositionIO *stream, int16);
443459199eSGerasim Troeglazov 	void			_WriteUInt16ToStream(BPositionIO *stream, uint16);
453459199eSGerasim Troeglazov 	void			_WriteInt8ToStream(BPositionIO *stream, int8);
463459199eSGerasim Troeglazov 	void			_WriteUInt8ToStream(BPositionIO *stream, uint8);
473459199eSGerasim Troeglazov 	void			_WriteFillBlockToStream(BPositionIO *stream,
483459199eSGerasim Troeglazov 						uint8 val, size_t count);
493459199eSGerasim Troeglazov 	void			_WriteBlockToStream(BPositionIO *stream,
503459199eSGerasim Troeglazov 						uint8 *block, size_t count);
513459199eSGerasim Troeglazov 
52*2b015194SGerasim Troeglazov 	BDataArray*		_PackBits(uint8 *buff, int32  len);
53*2b015194SGerasim Troeglazov 	status_t		_LoadChannelsFromRGBA32(void);
545a65c297SGerasim Troeglazov 
553459199eSGerasim Troeglazov 	BPositionIO 	*fStream;
567983058dSGerasim Troeglazov 	size_t			fBitmapDataPos;
577983058dSGerasim Troeglazov 
58*2b015194SGerasim Troeglazov 	BDataArray 		psdChannel[4];
59*2b015194SGerasim Troeglazov 	BDataArray 		psdByteCounts[4];
60*2b015194SGerasim Troeglazov 
617983058dSGerasim Troeglazov 	color_space		fColorSpace;
627983058dSGerasim Troeglazov 	int32			fInRowBytes;
637983058dSGerasim Troeglazov 	int16			fChannels;
64*2b015194SGerasim Troeglazov 	int16			fAlphaChannel;
657983058dSGerasim Troeglazov 	int32			fWidth;
667983058dSGerasim Troeglazov 	int32			fHeight;
677983058dSGerasim Troeglazov 	int16			fCompression;
686d7acad2SGerasim Troeglazov 	int16			fVersion;
697983058dSGerasim Troeglazov 
707983058dSGerasim Troeglazov 	bool			fReady;
713459199eSGerasim Troeglazov };
723459199eSGerasim Troeglazov 
733459199eSGerasim Troeglazov 
743459199eSGerasim Troeglazov #endif	/* PSD_WRITER_H */
75