(string[] args)
| 121 | public static extern int liq_version(); |
| 122 | |
| 123 | static void Main(string[] args) |
| 124 | { |
| 125 | Console.WriteLine("library version: {0}", liq_version()); |
| 126 | |
| 127 | int width = 3; |
| 128 | int height = 1; |
| 129 | |
| 130 | var attr = liq_attr_create(); |
| 131 | if (attr == IntPtr.Zero) throw new Exception("can't create attr"); |
| 132 | |
| 133 | byte[] bitmap = { // R, G, B, A, R, G, B, A, ... |
| 134 | 111, 222, 33, 255, |
| 135 | 255, 0, 255, 255, |
| 136 | 255, 0, 255, 255, |
| 137 | }; |
| 138 | var img = liq_image_create_rgba(attr, bitmap, width, height, 0); |
| 139 | if (img == IntPtr.Zero) throw new Exception("can't create image"); |
| 140 | |
| 141 | var res = liq_quantize_image(attr, img); |
| 142 | if (res == IntPtr.Zero) throw new Exception("can't quantize image"); |
| 143 | |
| 144 | var buffer_size = width * height; |
| 145 | var remapped = new byte[buffer_size]; |
| 146 | |
| 147 | var err = liq_write_remapped_image(res, img, remapped, (UIntPtr)buffer_size); |
| 148 | if (err != liq_error.LIQ_OK) |
| 149 | { |
| 150 | throw new Exception("remapping error"); |
| 151 | } |
| 152 | |
| 153 | Console.WriteLine("first pixel is {0}th palette entry", remapped[0]); |
| 154 | |
| 155 | liq_palette pal = (liq_palette)Marshal.PtrToStructure(liq_get_palette(res), typeof(liq_palette)); |
| 156 | |
| 157 | Console.WriteLine("palette entries: {0}; red of first entry: {1}", pal.count, pal.entries[0].r); |
| 158 | |
| 159 | liq_image_destroy(img); |
| 160 | liq_result_destroy(res); |
| 161 | liq_attr_destroy(attr); |
| 162 | } |
| 163 | } |
| 164 | } |
nothing calls this directly
no test coverage detected