gnujpdf - clipping fix (getclip)

PDF export - clipping fix
This commit is contained in:
Jindra Petřík
2021-03-22 17:39:24 +01:00
parent 10fe20ff7c
commit 050b4dce2d
5 changed files with 19 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
package com.jpexs.decompiler.flash.exporters;
import com.jpexs.decompiler.flash.exporters.commonshape.Matrix;
import gnu.jpdf.PDFGraphics;
import java.awt.Color;
import java.awt.Composite;
@@ -17,6 +18,7 @@ import java.awt.Stroke;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.awt.geom.PathIterator;
import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ImageObserver;
@@ -215,7 +217,7 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable {
@Override
public AffineTransform getTransform() {
return imageGraphics.getTransform();
return pdfGraphics.getTransform();
}
@Override
@@ -318,7 +320,7 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable {
@Override
public Shape getClip() {
return imageGraphics.getClip();
return pdfGraphics.getClip();
}
@Override

View File

@@ -25,7 +25,6 @@ import com.jpexs.decompiler.flash.types.FILLSTYLE;
import com.jpexs.decompiler.flash.types.GRADIENT;
import com.jpexs.decompiler.flash.types.GRADRECORD;
import com.jpexs.decompiler.flash.types.LINESTYLE2;
import com.jpexs.decompiler.flash.types.RECT;
import com.jpexs.decompiler.flash.types.RGB;
import com.jpexs.decompiler.flash.types.SHAPE;
import com.jpexs.helpers.SerializableImage;
@@ -564,7 +563,8 @@ public class BitmapExporter extends ShapeExporterBase {
graphics.setComposite(AlphaComposite.SrcOver);
if (fillPaint instanceof MultipleGradientPaint) {
AffineTransform oldAf = graphics.getTransform();
graphics.setClip(path);
Shape prevClip = graphics.getClip();
graphics.clip(path);
Matrix inverse = null;
try {
double scx = fillTransform.getScaleX();
@@ -596,10 +596,11 @@ public class BitmapExporter extends ShapeExporterBase {
}
graphics.setTransform(oldAf);
graphics.setClip(null);
graphics.setClip(prevClip);
} else if (fillPaint instanceof TexturePaint) {
AffineTransform oldAf = graphics.getTransform();
graphics.setClip(path);
Shape prevClip = graphics.getClip();
graphics.clip(path);
Matrix inverse = null;
if (fillRepeat) {
try {
@@ -636,7 +637,7 @@ public class BitmapExporter extends ShapeExporterBase {
}
graphics.setTransform(oldAf);
graphics.setClip(null);
graphics.setClip(prevClip);
} else {
graphics.setPaint(fillPaint);
graphics.fill(path);
@@ -647,7 +648,8 @@ public class BitmapExporter extends ShapeExporterBase {
graphics.setComposite(AlphaComposite.SrcOver);
if (linePaint instanceof MultipleGradientPaint) {
AffineTransform oldAf = graphics.getTransform();
graphics.setClip(strokedShape);
Shape prevClip = graphics.getClip();
graphics.clip(strokedShape);
Matrix inverse = null;
try {
double scx = lineTransform.getScaleX();
@@ -679,10 +681,11 @@ public class BitmapExporter extends ShapeExporterBase {
}
graphics.setTransform(oldAf);
graphics.setClip(null);
graphics.setClip(prevClip);
} else if (linePaint instanceof TexturePaint) {
AffineTransform oldAf = graphics.getTransform();
graphics.setClip(strokedShape);
Shape prevClip = graphics.getClip();
graphics.clip(strokedShape);
Matrix inverse = null;
try {
double scx = lineTransform.getScaleX();
@@ -713,7 +716,7 @@ public class BitmapExporter extends ShapeExporterBase {
}
graphics.setTransform(oldAf);
graphics.setClip(null);
graphics.setClip(prevClip);
} else {
graphics.setPaint(linePaint);
graphics.fill(strokedShape);

View File

@@ -725,6 +725,8 @@ public class Timeline {
if (canUseSameImage && sameImage) {
img = image;
m = mat.clone();
g.setTransform(new AffineTransform());
//g.setClip(null);
//m = m.concatenate(drawMatrix);
}