Skip to content

Commit

Permalink
Fix LibrePDF#450 : avoid creating new graphic state if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
douglas-six authored and asturio committed Nov 9, 2020
1 parent a0ce725 commit 0abe991
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions openpdf/src/main/java/com/lowagie/text/pdf/PdfContentByte.java
Original file line number Diff line number Diff line change
Expand Up @@ -2347,11 +2347,14 @@ public void setColorFill(Color color) {
}
}

private int lastAlpha = 1;
private void saveColorFill(ExtendedColor extendedColor) {
PdfGState gState = new PdfGState();
gState.setFillOpacity(extendedColor.getAlpha() / MAX_INT_COLOR_VALUE);
setGState(gState);

if (lastAlpha != extendedColor.getAlpha()) {
PdfGState gState = new PdfGState();
gState.setFillOpacity(extendedColor.getAlpha() / MAX_INT_COLOR_VALUE);
setGState(gState);
lastAlpha = extendedColor.getAlpha();
}
if (state != null) state.colorFill = extendedColor;
}

Expand Down

0 comments on commit 0abe991

Please sign in to comment.