| 115 | ~Impl() { moduleFree(); } |
| 116 | |
| 117 | VBitmap createBitmap(unsigned char *data, int width, int height, |
| 118 | int channel) |
| 119 | { |
| 120 | // premultiply alpha |
| 121 | if (channel == 4) |
| 122 | convertToBGRAPremul(data, width, height); |
| 123 | else |
| 124 | convertToBGRA(data, width, height); |
| 125 | |
| 126 | // create a bitmap of same size. |
| 127 | VBitmap result = |
| 128 | VBitmap(width, height, VBitmap::Format::ARGB32_Premultiplied); |
| 129 | |
| 130 | // copy the data to bitmap buffer |
| 131 | memcpy(result.data(), data, width * height * 4); |
| 132 | |
| 133 | // free the image data |
| 134 | imageFree(data); |
| 135 | |
| 136 | return result; |
| 137 | } |
| 138 | |
| 139 | VBitmap load(const char *fileName) |
| 140 | { |