-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatformAware.cpp
More file actions
24 lines (22 loc) · 835 Bytes
/
PlatformAware.cpp
File metadata and controls
24 lines (22 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "ConsoleGraphics.h"
void deflateSourceImage(ref<Image> img, Pixel transparentColor, PixelFormat &destPixelFormat) {
for (unsigned j = 0; j < img->height; j++)
for (unsigned i = 0; i < img->width; i++) {
// Check for full transparency
Pixel p = img->getPixel(i, j);
if (p.value == transparentColor.value) {
img->setPixel(i, j, 0);
continue;
}
// Else quantize to the appropriate number of bits
// We'll use the proper bit order when writing the palette/bitmap
img->setPixel(i, j, destPixelFormat.deflate(p));
}
}
void inflateSourceImage(ref<Image> img, PixelFormat &destPixelFormat) {
for (unsigned j = 0; j < img->height; j++)
for (unsigned i = 0; i < img->width; i++) {
Pixel p = img->getPixel(i, j);
img->setPixel(i, j, destPixelFormat.inflate(p));
}
}