Skip to content

Commit

Permalink
Reduce memory garbage created while drawing MaxiCode symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
gredler committed Jul 30, 2024
1 parent b563607 commit 45d2531
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/uk/org/okapibarcode/output/Java2DRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,16 @@ public void render(Symbol symbol) {
g2d.drawString(text.text, x, y);
}

for (Hexagon hexagon : symbol.getHexagons()) {
if (!symbol.getHexagons().isEmpty()) {
Polygon polygon = new Polygon();
for (int j = 0; j < 6; j++) {
polygon.addPoint((int) ((hexagon.pointX[j] * magnification) + marginX),
(int) ((hexagon.pointY[j] * magnification) + marginY));
for (Hexagon hexagon : symbol.getHexagons()) {
for (int j = 0; j < 6; j++) {
polygon.addPoint((int) ((hexagon.pointX[j] * magnification) + marginX),
(int) ((hexagon.pointY[j] * magnification) + marginY));
}
g2d.fill(polygon);
polygon.reset();
}
g2d.fill(polygon);
}

List< Circle > target = symbol.getTarget();
Expand Down

0 comments on commit 45d2531

Please sign in to comment.