printer: fix orientation of resulting image (#324)

## Link to GitHub Issue, if one exists
n/a

## Description of change
Rotate the printer output so that it's the correct orientation
(portrait, not landscape).

## Testing
Tested via test image, and also in-game, for LP and SDVX.
This commit is contained in:
bicarus-dev
2025-05-09 09:48:59 -07:00
committed by GitHub
parent 66b3de8e5c
commit 58481a035b
+22 -2
View File
@@ -326,7 +326,7 @@ namespace games::shared {
memcpy(image_data, pBandImage->baseAddr, (size_t) (image_width * image_height * 3)); memcpy(image_data, pBandImage->baseAddr, (size_t) (image_width * image_height * 3));
// convert BGR to RGB // convert BGR to RGB
log_info("printer", "converting BGR to RGB..."); log_misc("printer", "converting BGR to RGB...");
for (int pixel = 0; pixel < image_width * image_height; pixel++) { for (int pixel = 0; pixel < image_width * image_height; pixel++) {
int index = pixel * 3; int index = pixel * 3;
uint8_t tmp = image_data[index]; uint8_t tmp = image_data[index];
@@ -334,7 +334,26 @@ namespace games::shared {
image_data[index + 2] = tmp; image_data[index + 2] = tmp;
} }
if (avs::game::is_model({"KLP", "KFC"})) {
// rotate image clockwise
log_misc("printer", "rotate clockwise...");
auto rotated = new uint8_t[image_width * image_height * 3];
for (int x = 0; x < image_width; x++) {
for (int y = 0; y < image_height; y++) {
int index1 = (y * image_width + x) * 3;
int index2 = (x * image_height + y) * 3;
rotated[index2 + 0] = image_data[index1 + 0];
rotated[index2 + 1] = image_data[index1 + 1];
rotated[index2 + 2] = image_data[index1 + 2];
}
}
delete[] image_data;
image_data = rotated;
std::swap(image_width, image_height);
} else {
// flip horizontally // flip horizontally
log_misc("printer", "flip horizontally...");
for (int x = 0; x < image_width / 2; x++) { for (int x = 0; x < image_width / 2; x++) {
for (int y = 0; y < image_height; y++) { for (int y = 0; y < image_height; y++) {
int index1 = (y * image_width + x) * 3; int index1 = (y * image_width + x) * 3;
@@ -350,9 +369,10 @@ namespace games::shared {
image_data[index2 + 2] = b; image_data[index2 + 2] = b;
} }
} }
}
// iterate folders // iterate folders
log_info("printer", "writing files..."); log_misc("printer", "writing files...");
for (const auto &path : PRINTER_PATH) { for (const auto &path : PRINTER_PATH) {
for (const auto &format : PRINTER_FORMAT) { for (const auto &format : PRINTER_FORMAT) {