-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathQoir.cs
303 lines (217 loc) · 9.08 KB
/
Qoir.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
// SPDX-FileCopyrightText: © 2023-2024 YorVeX, https://github.com/YorVeX
// SPDX-License-Identifier: MIT
using ClangSharp;
using System.Runtime.InteropServices;
namespace QoirLib
{
public unsafe partial struct qoir_size_result_struct
{
[NativeTypeName("const char *")]
public sbyte* status_message;
[NativeTypeName("size_t")]
public nuint value;
}
public partial struct qoir_pixel_configuration_struct
{
[NativeTypeName("qoir_pixel_format")]
public uint pixfmt;
[NativeTypeName("uint32_t")]
public uint width_in_pixels;
[NativeTypeName("uint32_t")]
public uint height_in_pixels;
}
public unsafe partial struct qoir_pixel_buffer_struct
{
[NativeTypeName("qoir_pixel_configuration")]
public qoir_pixel_configuration_struct pixcfg;
[NativeTypeName("uint8_t *")]
public byte* data;
[NativeTypeName("size_t")]
public nuint stride_in_bytes;
}
public partial struct qoir_rectangle_struct
{
[NativeTypeName("int32_t")]
public int x0;
[NativeTypeName("int32_t")]
public int y0;
[NativeTypeName("int32_t")]
public int x1;
[NativeTypeName("int32_t")]
public int y1;
}
public unsafe partial struct qoir_decode_pixel_configuration_result_struct
{
[NativeTypeName("const char *")]
public sbyte* status_message;
[NativeTypeName("qoir_pixel_configuration")]
public qoir_pixel_configuration_struct dst_pixcfg;
}
public partial struct qoir_decode_buffer_struct
{
[NativeTypeName("struct (anonymous struct at QoirLibCs.h:327:3)")]
public _private_impl_e__Struct private_impl;
public unsafe partial struct _private_impl_e__Struct
{
[NativeTypeName("uint8_t[16384]")]
public fixed byte ops[16384];
[NativeTypeName("uint8_t[16388]")]
public fixed byte literals[16388];
}
}
public unsafe partial struct qoir_decode_result_struct
{
[NativeTypeName("const char *")]
public sbyte* status_message;
public void* owned_memory;
[NativeTypeName("qoir_pixel_buffer")]
public qoir_pixel_buffer_struct dst_pixbuf;
[NativeTypeName("const uint8_t *")]
public byte* metadata_cicp_ptr;
[NativeTypeName("size_t")]
public nuint metadata_cicp_len;
[NativeTypeName("const uint8_t *")]
public byte* metadata_iccp_ptr;
[NativeTypeName("size_t")]
public nuint metadata_iccp_len;
[NativeTypeName("const uint8_t *")]
public byte* metadata_exif_ptr;
[NativeTypeName("size_t")]
public nuint metadata_exif_len;
[NativeTypeName("const uint8_t *")]
public byte* metadata_xmp_ptr;
[NativeTypeName("size_t")]
public nuint metadata_xmp_len;
}
public unsafe partial struct qoir_decode_options_struct
{
[NativeTypeName("void *(*)(void *, size_t)")]
public delegate* unmanaged[Cdecl]<void*, nuint, void*> contextual_malloc_func;
[NativeTypeName("void (*)(void *, void *)")]
public delegate* unmanaged[Cdecl]<void*, void*, void> contextual_free_func;
public void* memory_func_context;
[NativeTypeName("qoir_decode_buffer *")]
public qoir_decode_buffer_struct* decbuf;
[NativeTypeName("qoir_pixel_buffer")]
public qoir_pixel_buffer_struct pixbuf;
[NativeTypeName("qoir_pixel_format")]
public uint pixfmt;
[NativeTypeName("qoir_rectangle")]
public qoir_rectangle_struct dst_clip_rectangle;
[NativeTypeName("qoir_rectangle")]
public qoir_rectangle_struct src_clip_rectangle;
[NativeTypeName("bool")]
public byte use_dst_clip_rectangle;
[NativeTypeName("bool")]
public byte use_src_clip_rectangle;
[NativeTypeName("int32_t")]
public int offset_x;
[NativeTypeName("int32_t")]
public int offset_y;
}
public partial struct qoir_encode_buffer_struct
{
[NativeTypeName("struct (anonymous struct at QoirLibCs.h:411:3)")]
public _private_impl_e__Struct private_impl;
public unsafe partial struct _private_impl_e__Struct
{
[NativeTypeName("uint8_t[20544]")]
public fixed byte ops[20544];
[NativeTypeName("uint8_t[16388]")]
public fixed byte literals[16388];
}
}
public unsafe partial struct qoir_encode_result_struct
{
[NativeTypeName("const char *")]
public sbyte* status_message;
public void* owned_memory;
[NativeTypeName("uint8_t *")]
public byte* dst_ptr;
[NativeTypeName("size_t")]
public nuint dst_len;
}
public unsafe partial struct qoir_encode_options_struct
{
[NativeTypeName("void *(*)(void *, size_t)")]
public delegate* unmanaged[Cdecl]<void*, nuint, void*> contextual_malloc_func;
[NativeTypeName("void (*)(void *, void *)")]
public delegate* unmanaged[Cdecl]<void*, void*, void> contextual_free_func;
public void* memory_func_context;
[NativeTypeName("qoir_encode_buffer *")]
public qoir_encode_buffer_struct* encbuf;
[NativeTypeName("const uint8_t *")]
public byte* metadata_cicp_ptr;
[NativeTypeName("size_t")]
public nuint metadata_cicp_len;
[NativeTypeName("const uint8_t *")]
public byte* metadata_iccp_ptr;
[NativeTypeName("size_t")]
public nuint metadata_iccp_len;
[NativeTypeName("const uint8_t *")]
public byte* metadata_exif_ptr;
[NativeTypeName("size_t")]
public nuint metadata_exif_len;
[NativeTypeName("const uint8_t *")]
public byte* metadata_xmp_ptr;
[NativeTypeName("size_t")]
public nuint metadata_xmp_len;
[NativeTypeName("uint32_t")]
public uint lossiness;
[NativeTypeName("bool")]
public byte dither;
}
public static unsafe partial class Qoir
{
[DllImport("QoirLib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("qoir_decode_result")]
public static extern qoir_decode_result_struct qoir_decode([NativeTypeName("const uint8_t *")] byte* src_ptr, [NativeTypeName("const size_t")] nuint src_len, [NativeTypeName("const qoir_decode_options *")] qoir_decode_options_struct* options);
[DllImport("QoirLib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("qoir_encode_result")]
public static extern qoir_encode_result_struct qoir_encode([NativeTypeName("const qoir_pixel_buffer *")] qoir_pixel_buffer_struct* src_pixbuf, [NativeTypeName("const qoir_encode_options *")] qoir_encode_options_struct* options);
[NativeTypeName("#define QOIR_PIXEL_ALPHA_TRANSPARENCY__OPAQUE 0x01")]
public const int QOIR_PIXEL_ALPHA_TRANSPARENCY__OPAQUE = 0x01;
[NativeTypeName("#define QOIR_PIXEL_ALPHA_TRANSPARENCY__NONPREMULTIPLIED_ALPHA 0x02")]
public const int QOIR_PIXEL_ALPHA_TRANSPARENCY__NONPREMULTIPLIED_ALPHA = 0x02;
[NativeTypeName("#define QOIR_PIXEL_ALPHA_TRANSPARENCY__PREMULTIPLIED_ALPHA 0x03")]
public const int QOIR_PIXEL_ALPHA_TRANSPARENCY__PREMULTIPLIED_ALPHA = 0x03;
[NativeTypeName("#define QOIR_PIXEL_COLOR_MODEL__BGRA 0x00")]
public const int QOIR_PIXEL_COLOR_MODEL__BGRA = 0x00;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__MASK_FOR_ALPHA_TRANSPARENCY 0x03")]
public const int QOIR_PIXEL_FORMAT__MASK_FOR_ALPHA_TRANSPARENCY = 0x03;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__MASK_FOR_COLOR_MODEL 0x0C")]
public const int QOIR_PIXEL_FORMAT__MASK_FOR_COLOR_MODEL = 0x0C;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__INVALID 0x00")]
public const int QOIR_PIXEL_FORMAT__INVALID = 0x00;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__BGRX 0x01")]
public const int QOIR_PIXEL_FORMAT__BGRX = 0x01;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__BGRA_NONPREMUL 0x02")]
public const int QOIR_PIXEL_FORMAT__BGRA_NONPREMUL = 0x02;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__BGRA_PREMUL 0x03")]
public const int QOIR_PIXEL_FORMAT__BGRA_PREMUL = 0x03;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__BGR 0x11")]
public const int QOIR_PIXEL_FORMAT__BGR = 0x11;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__RGBX 0x21")]
public const int QOIR_PIXEL_FORMAT__RGBX = 0x21;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__RGBA_NONPREMUL 0x22")]
public const int QOIR_PIXEL_FORMAT__RGBA_NONPREMUL = 0x22;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__RGBA_PREMUL 0x23")]
public const int QOIR_PIXEL_FORMAT__RGBA_PREMUL = 0x23;
[NativeTypeName("#define QOIR_PIXEL_FORMAT__RGB 0x31")]
public const int QOIR_PIXEL_FORMAT__RGB = 0x31;
[NativeTypeName("#define QOIR_TILE_MASK 0x3F")]
public const int QOIR_TILE_MASK = 0x3F;
[NativeTypeName("#define QOIR_TILE_SIZE 0x40")]
public const int QOIR_TILE_SIZE = 0x40;
[NativeTypeName("#define QOIR_TILE_SHIFT 6")]
public const int QOIR_TILE_SHIFT = 6;
[NativeTypeName("#define QOIR_LITERALS_PRE_PADDING 4")]
public const int QOIR_LITERALS_PRE_PADDING = 4;
[NativeTypeName("#define QOIR_TS2 (QOIR_TILE_SIZE * QOIR_TILE_SIZE)")]
public const int QOIR_TS2 = (0x40 * 0x40);
[NativeTypeName("#define QOIR_LZ4_BLOCK_DECODE_MAX_INCL_SRC_LEN 0x00FFFFFF")]
public const int QOIR_LZ4_BLOCK_DECODE_MAX_INCL_SRC_LEN = 0x00FFFFFF;
[NativeTypeName("#define QOIR_LZ4_BLOCK_ENCODE_MAX_INCL_SRC_LEN 0x7E000000")]
public const int QOIR_LZ4_BLOCK_ENCODE_MAX_INCL_SRC_LEN = 0x7E000000;
}
}