-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscaling.cpp
More file actions
17 lines (17 loc) · 742 Bytes
/
scaling.cpp
File metadata and controls
17 lines (17 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "scaling.h"
#include "faces.h"
void scaleBitmap(const uint16_t* source, uint8_t* destination, int srcWidth, int srcHeight, int destWidth, int destHeight) {
for (int y = 0; y < destHeight; ++y) {
for (int x = 0; x < destWidth; ++x) {
int srcX = x * srcWidth / destWidth;
int srcY = y * srcHeight / destHeight;
int bitIndex = srcY * (srcWidth / 8) + srcX / 8;
int bit = (source[bitIndex] >> (7 - (srcX % 8))) & 0x01;
if (bit) {
destination[y * (destWidth / 8) + x / 8] |= (1 << (7 - (x % 8)));
} else {
destination[y * (destWidth / 8) + x / 8] &= ~(1 << (7 - (x % 8)));
}
}
}
}