use of com.tom_roush.pdfbox.pdmodel.graphics.state.PDSoftMask in project PdfBox-Android by TomRoush.
the class PageDrawer method showTransparencyGroup.
@Override
public void showTransparencyGroup(PDTransparencyGroup form) throws IOException {
if (!isContentRendered()) {
return;
}
TransparencyGroup group = new TransparencyGroup(form, false, getGraphicsState().getCurrentTransformationMatrix(), null);
// Bitmap image = group.getImage();
// if (image == null)
// {
// image is empty, don't bother
// return;
// }
// graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite());
setClip();
// both the DPI xform and the CTM were already applied to the group, so all we do
// here is draw it directly onto the Graphics2D device at the appropriate position
// PDRectangle bbox = group.getBBox();
// AffineTransform savedTransform = graphics.getTransform();
Matrix m = new Matrix(xform);
float xScale = Math.abs(m.getScalingFactorX());
float yScale = Math.abs(m.getScalingFactorY());
AffineTransform transform = new AffineTransform(xform);
transform.scale(1.0 / xScale, 1.0 / yScale);
if (flipTG) {
// graphics.translate(0, image.getHeight());
// graphics.scale(1, -1);
} else {
// graphics.translate(x * xScale, y * yScale);
}
PDSoftMask softMask = getGraphicsState().getSoftMask();
if (softMask != null) {
// graphics.setPaint(awtPaint);
if (isContentRendered()) {
// graphics.fill(
// new Rectangle2D.Float(0, 0, bbox.getWidth() * xScale, bbox.getHeight() * yScale));
}
} else {
if (isContentRendered()) {
// try
// {
// graphics.drawImage(image, null, null);
// }
// catch (InternalError ie)
// {
// Log.e("PdfBox-Android", "Exception drawing image, see JDK-6689349, " +
// "try rendering into a BufferedImage instead", ie);
// }
}
}
// graphics.setTransform(savedTransform);
}
use of com.tom_roush.pdfbox.pdmodel.graphics.state.PDSoftMask in project PdfBox-Android by TomRoush.
the class PageDrawer method drawBitmap.
private void drawBitmap(Bitmap image, AffineTransform at) throws IOException {
// graphics.setComposite(getGraphicsState().getNonStrokingJavaComposite());
setClip();
AffineTransform imageTransform = new AffineTransform(at);
PDSoftMask softMask = getGraphicsState().getSoftMask();
if (softMask != null) {
imageTransform.scale(1, -1);
imageTransform.translate(0, -1);
// Paint awtPaint = new TexturePaint(image,
// new Rectangle2D.Double(imageTransform.getTranslateX(), imageTransform.getTranslateY(),
// imageTransform.getScaleX(), imageTransform.getScaleY()));
// awtPaint = applySoftMaskToPaint(awtPaint, softMask);
// graphics.setPaint(awtPaint);
RectF unitRect = new RectF(0, 0, 1, 1);
if (isContentRendered()) {
// graphics.fill(at.createTransformedShape(unitRect));
}
} else {
COSBase transfer = getGraphicsState().getTransfer();
if (transfer instanceof COSArray || transfer instanceof COSDictionary) {
image = applyTransferFunction(image, transfer);
}
int width = image.getWidth();
int height = image.getHeight();
imageTransform.scale(1.0 / width, -1.0 / height);
imageTransform.translate(0, -height);
if (isContentRendered()) {
canvas.drawBitmap(image, imageTransform.toMatrix(), paint);
}
}
}
Aggregations