1 module psd.res;
2 import asdf;
3 
4 
5 
6 //
7 //          LAYER
8 //
9 
10 
11 /**
12     Photoshop blending modes
13 */
14 enum BlendingMode : string {
15     PassThrough = "pass",
16     Normal = "norm",
17     Dissolve = "diss",
18     Darken = "dark",
19     Multiply = "mul ",
20     ColorBurn = "idiv",
21     LinearBurn = "lbrn",
22     DarkerColor = "dkCl",
23     Lighten = "lite",
24     Screen = "scrn",
25     ColorDodge = "div ",
26     LinearDodge = "lddg",
27     LighterColor = "lgCl",
28     Overlay = "over",
29     SoftLight = "sLit",
30     HardLight = "hLit",
31     VividLight = "vLit",
32     LinearLight = "lLit",
33     PinLight = "pLit",
34     HardMix = "hMix",
35     Difference = "diff",
36     Exclusion = "smud",
37     Subtract = "fsub",
38     Divide = "fdiv",
39     Hue = "hue ",
40     Saturation = "sat ",
41     Color = "colr",
42     Luminosity = "lum "
43 }
44 
45 /**
46     Flags for a layer
47 */
48 enum LayerFlags : ubyte {
49     TransProtect    = 0b00000001,
50     Visible         = 0b00000010,
51     Obsolete        = 0b00000100,
52     ModernDoc       = 0b00001000,
53     PixelIrrel      = 0b00010000,
54 
55     /**
56         Special mask used for getting whether a layer is a group layer
57         flags & GroupMask = 24, for a layer group.
58     */
59     GroupMask       = 0b00011000
60 }
61 
62 /**
63     Information about color channels
64 */
65 struct ChannelInfo {
66     /**
67         ID of channel
68     */
69     short id;
70 
71     /**
72         Length of data in color channel
73     */
74     uint dataLength;
75 
76     /**
77         Gets whether the channel is a mask
78     */
79     bool isMask() {
80         return id < -1;
81     }
82 
83     /**
84         Gets whether the channel is an alpha channel
85     */
86     bool isAlpha() {
87         return id == -1;
88     }
89 }
90 
91 /**
92     Information about a layer
93 */
94 struct LayerInfo {
95 
96     /**
97         Name of the layer
98     */
99     string name;
100     
101     /**
102         Y/Top coordinate
103     */
104     uint y;
105     
106     /**
107         X/Left coordinate
108     */
109     uint x;
110 
111     /**
112         Y+Height/Bottom coordinate
113     */
114     uint bottom;
115 
116     /**
117         X+Width/Right coordinate
118     */
119     uint right;
120 }
121 
122 struct LayerExtInfo {
123     string id;
124     ubyte[] data;
125 }
126 
127 
128 
129 //
130 //          LAYER DATA
131 //
132 
133 /**
134     The compression used by the layer
135 */
136 enum LayerCompression : ubyte {
137     RAW = 0x00,
138     RLE = 0x01,
139     ZIP0 = 0x02,
140     ZIP1 = 0x03
141 }
142 
143 /**
144     Data for a layer
145 */
146 struct LayerData {
147 
148     /**
149         Compression scheme used
150     */
151     LayerCompression compression;
152 
153     /**
154         Original bits per channel
155     */
156     ubyte bpc;
157 
158     /**
159         Amount of channels
160     */
161     ushort channels;
162 
163     /**
164         Width of layer data
165     */
166     uint width;
167 
168     /**
169         Height of layer data
170     */
171     uint height;
172 
173     /**
174         8 bit RGBA data
175     */
176     ubyte[] data;
177 }