1 /*
2 Prepare indices into our pixel format.
3 
4 Synthesizer engine pixel contains mask pixelel and map pixelels
5 (Not just the color and alpha pixelels.)
6 
7 IN: Image format (RGB, RGBA, Grey, etc.)
8 OUT: global index variables.
9 
10 Not depend on Gimp
11 
12   Copyright (C) 2010, 2011  Lloyd Konneker
13 
14   This program is free software; you can redistribute it and/or modify
15   it under the terms of the GNU General Public License as published by
16   the Free Software Foundation; either version 2 of the License, or
17   (at your option) any later version.
18 
19   This program is distributed in the hope that it will be useful,
20   but WITHOUT ANY WARRANTY; without even the implied warranty of
21   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22   GNU General Public License for more details.
23 
24   You should have received a copy of the GNU General Public License
25   along with this program; if not, write to the Free Software
26   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 */
28 
29 
30 #ifndef __SYNTH_IMAGE_FORMAT_INDICIES_H__
31 #define __SYNTH_IMAGE_FORMAT_INDICIES_H__
32 
33 /*
34 bpp i.e. count of bytes (channels) per pixel or index thereof.
35 bpp is bytes per pixel
36 bip is byte index within pixel.
37 See data layout in resynth_types.h
38 */
39 typedef unsigned char TPixelelIndex;
40 
41 /*
42 Struct of indices of pixelels within pixels in internal image format.
43 Also flags.
44 One is used for the target, one for the source.
45 */
46 typedef struct indicesStruct {
47   TPixelelIndex colorEndBip; /* Index of last color pixelels in target/context image. */
48   TPixelelIndex alpha_bip;      /* Index of target alpha pixelel */
49   TPixelelIndex map_start_bip;  /* Index of map pixelels */
50   TPixelelIndex map_end_bip;
51 
52   TPixelelIndex img_match_bpp; /* bpp to match in image. */
53   TPixelelIndex map_match_bpp; /* bpp to match in map. */
54   TPixelelIndex total_bpp;     /* Total pixelels */
55 
56   gboolean isAlphaTarget; // Does target have alpha?
57   gboolean isAlphaSource; // Does source have alpha?
58 } TFormatIndices;
59 
60 extern unsigned int
61 countPixelelsPerPixelForFormat(
62   TImageFormat format // IN
63   );
64 
65 extern int
66 prepareImageFormatIndicesFromFormatType(
67   TFormatIndices* indices,  // OUT
68   TImageFormat format // IN
69   );
70 
71 extern void
72 prepareImageFormatIndices(
73   TFormatIndices* indices,  // OUT
74   guint count_color_channels_target,  // Must be same count in source
75   guint count_color_channels_map,
76   gboolean is_alpha_target,
77   gboolean is_alpha_source,
78   gboolean isMap
79   );
80 
81 extern void
82 prepareDefaultFormatIndices(
83   TFormatIndices* formatIndices
84   );
85 
86 #endif /* __SYNTH_IMAGE_FORMAT_H__ */
87 
88