- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- int pixel = rgba8_to_argb(data[(y * width + x) * 4 + 0],
- data[(y * width + x) * 4 + 1],
- data[(y * width + x) * 4 + 2],
- data[(y * width + x) * 4 + 3]);
- pixelData[y * width + x] = pixel;
+ if (m_numChannels == 4) {
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ int pixel = rgba8_to_argb(data[(y * width + x) * 4 + 0],
+ data[(y * width + x) * 4 + 1],
+ data[(y * width + x) * 4 + 2],
+ data[(y * width + x) * 4 + 3]);
+ pixelData[y * width + x] = pixel;
+ }
+ }
+ } else if (m_numChannels == 1) {
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ int pixel = rgba8_to_argb(data[y * width + x],
+ data[y * width + x],
+ data[y * width + x],
+ 255);
+ pixelData[y * width + x] = pixel;
+ }