Skip to content

Commit

Permalink
BAM Converter: Trim filter should not produce empty frames
Browse files Browse the repository at this point in the history
Fixes issues with fully transparent frames.
  • Loading branch information
Argent77 committed Jun 27, 2024
1 parent a0760da commit dcd18c3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/org/infinity/gui/converter/BamFilterTransformTrim.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ private PseudoBamFrameEntry applyEffect(PseudoBamFrameEntry entry) {

// calculating the properties of the resulting image
int left = 0, right = width - 1, top = 0, bottom = height - 1;
boolean edgeLeft = !cbEdges.get(Edge.Left).isSelected(), edgeRight = !cbEdges.get(Edge.Right).isSelected(),
edgeTop = !cbEdges.get(Edge.Top).isSelected(), edgeBottom = !cbEdges.get(Edge.Bottom).isSelected();
boolean edgeLeft = !cbEdges.get(Edge.Left).isSelected();
boolean edgeRight = !cbEdges.get(Edge.Right).isSelected();
boolean edgeTop = !cbEdges.get(Edge.Top).isSelected();
boolean edgeBottom = !cbEdges.get(Edge.Bottom).isSelected();
while ((left < right || top < bottom) && (!edgeLeft || !edgeRight || !edgeTop || !edgeBottom)) {
int ofs, step;
// checking top edge
Expand Down Expand Up @@ -404,6 +406,14 @@ private PseudoBamFrameEntry applyEffect(PseudoBamFrameEntry entry) {
}
}

// preventing empty frames
if (right < left) {
left = right = 0;
}
if (bottom < top) {
top = bottom = 0;
}

// creating new image
int margin = ((Integer) spinnerMargin.getValue());
int dstX = 0;
Expand Down

0 comments on commit dcd18c3

Please sign in to comment.