As part of PR #157, a change was made to BadgeImage.java to increase the width of scaled images by 25%. This was done to counteract images getting shrunk horizontally by 25%. A couple of attempts were made to replace the scaling logic, but the results came out the same.
new_width = (new_height * original_width * 125 / 100) / original_height;
Investigate what is shrinking the width of these scaled images and fix. This code is related to printing physical badges and so it will not be needed further for this year.
Here is the original version of drawStretchedImage, which has the same shrinking problem:
void drawStretchedImage(Image image, Rectangle boundingArea) {
if (image == null) return;
double imageWidth = image.getWidth(null);
double imageHeight = image.getHeight(null);
double widthRatio = area.getWidth() / imageWidth;
double heightRatio = area.getHeight() / imageHeight;
double ratio = Math.min(widthRatio, heightRatio);
int newWidth = (int) (imageWidth * ratio);
int newHeight = (int) (imageHeight * ratio);
Rectangle scaledArea = new Rectangle(
area.x + (area.width - newWidth)/2,
area.y + (area.height - newHeight)/2,
newWidth,
newHeight);
drawImage(image, scaledArea);
}
As part of PR #157, a change was made to BadgeImage.java to increase the width of scaled images by 25%. This was done to counteract images getting shrunk horizontally by 25%. A couple of attempts were made to replace the scaling logic, but the results came out the same.
new_width = (new_height * original_width * 125 / 100) / original_height;
Investigate what is shrinking the width of these scaled images and fix. This code is related to printing physical badges and so it will not be needed further for this year.
Here is the original version of drawStretchedImage, which has the same shrinking problem: