xref: /haiku/src/add-ons/translators/icns/ICNSLoader.h (revision 25a7b01d15612846f332751841da3579db313082)
1*122e78a5Sthreedeyes /*
2*122e78a5Sthreedeyes  * Copyright 2012, Gerasim Troeglazov, 3dEyes@gmail.com. All rights reserved.
3*122e78a5Sthreedeyes  * Distributed under the terms of the MIT License.
4*122e78a5Sthreedeyes  */
5*122e78a5Sthreedeyes 
6*122e78a5Sthreedeyes #ifndef ICNS_LOADER_H
7*122e78a5Sthreedeyes #define ICNS_LOADER_H
8*122e78a5Sthreedeyes 
9*122e78a5Sthreedeyes #include <stdlib.h>
10*122e78a5Sthreedeyes #include <stdio.h>
11*122e78a5Sthreedeyes #include <string.h>
12*122e78a5Sthreedeyes 
13*122e78a5Sthreedeyes #include <Translator.h>
14*122e78a5Sthreedeyes #include <TranslatorFormats.h>
15*122e78a5Sthreedeyes #include <TranslationDefs.h>
16*122e78a5Sthreedeyes #include <GraphicsDefs.h>
17*122e78a5Sthreedeyes #include <InterfaceDefs.h>
18*122e78a5Sthreedeyes #include <DataIO.h>
19*122e78a5Sthreedeyes #include <File.h>
20*122e78a5Sthreedeyes #include <ByteOrder.h>
21*122e78a5Sthreedeyes #include <List.h>
22*122e78a5Sthreedeyes 
23*122e78a5Sthreedeyes extern "C" {
24*122e78a5Sthreedeyes #include "icns.h"
25*122e78a5Sthreedeyes }
26*122e78a5Sthreedeyes 
27*122e78a5Sthreedeyes #define IS_SPUPPORTED_TYPE(type) ((type) == ICNS_1024x1024_32BIT_ARGB_DATA || \
28*122e78a5Sthreedeyes 								  (type) == ICNS_512x512_32BIT_ARGB_DATA || \
29*122e78a5Sthreedeyes 								  (type) == ICNS_256x256_32BIT_ARGB_DATA || \
30*122e78a5Sthreedeyes 								  (type) == ICNS_128X128_32BIT_DATA || \
31*122e78a5Sthreedeyes 								  (type) == ICNS_48x48_32BIT_DATA || \
32*122e78a5Sthreedeyes 								  (type) == ICNS_32x32_32BIT_DATA || \
33*122e78a5Sthreedeyes 								  (type) == ICNS_16x16_32BIT_DATA)
34*122e78a5Sthreedeyes 
35*122e78a5Sthreedeyes icns_type_t ICNSFormat(float width, float height, color_space colors);
36*122e78a5Sthreedeyes 
37*122e78a5Sthreedeyes class ICNSLoader {
38*122e78a5Sthreedeyes public:
39*122e78a5Sthreedeyes 					ICNSLoader(BPositionIO *stream);
40*122e78a5Sthreedeyes 					~ICNSLoader();
41*122e78a5Sthreedeyes 
42*122e78a5Sthreedeyes 	int				IconsCount(void);
43*122e78a5Sthreedeyes 	int 			GetIcon(BPositionIO *target, int index);
44*122e78a5Sthreedeyes 	bool			IsLoaded(void);
45*122e78a5Sthreedeyes private:
46*122e78a5Sthreedeyes 	icns_family_t*	fIconFamily;
47*122e78a5Sthreedeyes 	int				fIconsCount;
48*122e78a5Sthreedeyes 	size_t			fStreamSize;
49*122e78a5Sthreedeyes 	BList			fFormatList;
50*122e78a5Sthreedeyes 	bool			fLoaded;
51*122e78a5Sthreedeyes };
52*122e78a5Sthreedeyes 
53*122e78a5Sthreedeyes class ICNSSaver {
54*122e78a5Sthreedeyes public:
55*122e78a5Sthreedeyes 					ICNSSaver(BPositionIO *stream, uint32 rowBytes,
56*122e78a5Sthreedeyes 						icns_type_t type);
57*122e78a5Sthreedeyes 					~ICNSSaver();
58*122e78a5Sthreedeyes 
59*122e78a5Sthreedeyes 	int 			SaveData(BPositionIO *target);
60*122e78a5Sthreedeyes 	bool			IsCreated(void);
61*122e78a5Sthreedeyes private:
62*122e78a5Sthreedeyes 	icns_family_t*	fIconFamily;
63*122e78a5Sthreedeyes 	bool			fCreated;
64*122e78a5Sthreedeyes 
65*122e78a5Sthreedeyes };
66*122e78a5Sthreedeyes 
67*122e78a5Sthreedeyes 
68*122e78a5Sthreedeyes #endif	/* ICNS_LOADER_H */
69