else if (paint instanceof TexturePaint)
{
try
{
final TexturePaint tp = (TexturePaint)paint;
final BufferedImage img = tp.getImage();
final Rectangle2D rect = tp.getAnchorRect();
final com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null);
final PdfPatternPainter pattern = cb.createPattern(image.getWidth(), image.getHeight());
final AffineTransform inverse = this.normalizeMatrix();
inverse.translate(rect.getX(), rect.getY());
inverse.scale(rect.getWidth() / image.getWidth(), -rect.getHeight() / image.getHeight());
final double[] mx = new double[6];
inverse.getMatrix(mx);
pattern.setPatternMatrix((float)mx[0], (float)mx[1], (float)mx[2], (float)mx[3], (float)mx[4], (float)mx[5]) ;
image.setAbsolutePosition(0,0);
pattern.addImage(image);
if (fill)
cb.setPatternFill(pattern);
else
cb.setPatternStroke(pattern);
}
catch (Exception ex)
{
if (fill)
{
cb.setColorFill(Color.gray);
}
else
{
cb.setColorStroke(Color.gray);
}
}
}
else
{
try
{
int type = BufferedImage.TYPE_4BYTE_ABGR;
if (paint.getTransparency() == Transparency.OPAQUE)
{
type = BufferedImage.TYPE_3BYTE_BGR;
}
final BufferedImage img = new BufferedImage((int) width, (int) height, type);
final Graphics2D g = (Graphics2D) img.getGraphics();
g.transform(transform);
final AffineTransform inv = transform.createInverse();
Shape fillRect = new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight());
fillRect = inv.createTransformedShape(fillRect);
g.setPaint(paint);
g.fill(fillRect);
if (invert)
{