Index: /trunk/src/org/expeditee/io/PDF2Writer.java
===================================================================
--- /trunk/src/org/expeditee/io/PDF2Writer.java	(revision 791)
+++ /trunk/src/org/expeditee/io/PDF2Writer.java	(revision 792)
@@ -100,10 +100,12 @@
 	@Override
 	protected void writePicture(Picture pic) throws IOException {
-		Image image = pic.getCroppedImage();
+		Image image = pic.getImageToDraw();
 		try {
 			PdfContentByte cb = _pdfWriter.getDirectContent();
 			com.lowagie.text.Image iTextImage = com.lowagie.text.Image.getInstance(image, null);
-			iTextImage.setAbsolutePosition(pic.getX(), _pdfWriter.getPageSize().getHeight() - pic.getY() - pic.getHeight());
-			iTextImage.setRotationDegrees((float) - pic.getRotate());
+			// System.out.println(pic.getScale());
+			// iTextImage.scalePercent(pic.getScale() * 100);
+			iTextImage.setAbsolutePosition(pic.getPolygon().getBounds().x, _pdfWriter.getPageSize().getHeight() - pic.getPolygon().getBounds().y - image.getHeight(null));
+			// iTextImage.setRotationDegrees((float) - pic.getRotate());
 			cb.addImage(iTextImage);
 		} catch (DocumentException e) {
@@ -113,5 +115,4 @@
 	
 	private List<Line> seenLines = new LinkedList<Line>();
-	private List<Item> seenArrowHeads = new LinkedList<Item>();
 	@Override
 	protected void writeLine(Line line) throws IOException {
Index: /trunk/src/org/expeditee/items/Picture.java
===================================================================
--- /trunk/src/org/expeditee/items/Picture.java	(revision 791)
+++ /trunk/src/org/expeditee/items/Picture.java	(revision 792)
@@ -9,4 +9,5 @@
 import java.awt.Polygon;
 import java.awt.Rectangle;
+import java.awt.RenderingHints;
 import java.awt.Shape;
 import java.awt.Stroke;
@@ -16,4 +17,5 @@
 import java.awt.image.BufferedImage;
 import java.awt.image.CropImageFilter;
+import java.awt.image.DataBufferInt;
 import java.awt.image.FilteredImageSource;
 import java.awt.image.ImageObserver;
@@ -21,4 +23,5 @@
 import java.io.IOException;
 import java.text.DecimalFormat;
+import java.util.Arrays;
 
 import javax.imageio.ImageIO;
@@ -55,4 +58,5 @@
 
 	protected Image _image = null;
+	protected Image _imageToDraw = null;
 
 	private int _scaleType = RATIO;
@@ -202,4 +206,6 @@
 			_scale = 1F;
 		}
+		
+		updateImageToDraw();
 	}
 
@@ -332,4 +338,5 @@
 	public void setWidth(Integer width) {
 		_scale = width * 1F / (_end.x - _start.x);
+		_imageToDraw = null;
 	}
 
@@ -368,5 +375,6 @@
 	}
 	
-	public void paintImageTiling(Graphics2D g) {
+	protected void updateImageToDraw() {
+		_imageToDraw = null;
 		if (_image == null) {
 			return;
@@ -437,9 +445,41 @@
 		}
 		
-		AffineTransform at = new AffineTransform();
-		at.translate(dX1, dY1);
-		at.rotate(Math.PI * _rotate / 180, tmp.getWidth() / 2, tmp.getHeight() / 2);
-		g.drawImage(tmp, at, _imageObserver);
-		// g.drawImage(tmp, dX1, dY1, dX2, dY2, 0, 0, tmp.getWidth(), tmp.getHeight(), _imageObserver);
+		double angle = Math.PI * _rotate / 180;
+		double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle));
+        int w = tmp.getWidth(), h = tmp.getHeight();
+        int neww = (int)Math.floor(w * cos + h * sin), newh = (int)Math.floor(h * cos + w * sin);
+		
+		BufferedImage rotated = new BufferedImage(neww, newh, BufferedImage.TYPE_INT_ARGB);
+		Arrays.fill(((DataBufferInt)rotated.getRaster().getDataBuffer()).getData(), 0);
+		
+		Graphics2D g = rotated.createGraphics();
+		g.translate((neww - w) / 2, (newh - h) / 2);
+		g.rotate(angle, tmp.getWidth() / 2, tmp.getHeight() / 2);
+		g.drawRenderedImage(tmp, null);
+		
+		_imageToDraw = rotated;//.getScaledInstance(rotated.getWidth(), rotated.getHeight(), Image.SCALE_REPLICATE);
+	}
+	
+	public Image getImageToDraw() {
+		return _imageToDraw;
+	}
+	
+	// TODO:
+	//  - Fix positioning (need to use something like polygon position)
+	//  - Use anti-aliasing for rotation
+	
+	public void paintImageTiling(Graphics2D g) {
+
+//		BufferedImage tmp = getImageToDraw();
+//		if(tmp == null) {
+//			return;
+//		}
+//		tmp.
+//		g.drawImage(tmp, at, _imageObserver);
+		if(_imageToDraw == null) {
+			updateImageToDraw();
+		}
+		Rectangle b = getPolygon().getBounds();
+		g.drawImage(_imageToDraw, b.x + 1, b.y + 1, _imageObserver);
 	}
 
@@ -519,4 +559,5 @@
 		Picture p = createPicture();
 		p._image = _image;
+		p._imageToDraw = null;
 		p._mode = _mode;
 		// Doing Duplicate item duplicates link mark which we dont want to do
@@ -575,4 +616,5 @@
 	public void setScale(float scale) {
 		_scale = scale;
+		_imageToDraw = null;
 	}
 	
@@ -629,4 +671,5 @@
 		updateSource();
 		updatePolygon();
+		updateImageToDraw();
 		// Make sure items that are resized display the border
 		invalidateAll();
@@ -791,4 +834,5 @@
 		updateSource();
 		super.translate(origin, ratio);
+		_imageToDraw = null;
 	}
 
@@ -817,12 +861,15 @@
 		setScale(getScale() * scale);
 		super.scale(scale, originX, originY);
+		_imageToDraw = null;
 	}
 	
 	public void setFlipX(boolean flip) {
 		_flipX = flip;
+		_imageToDraw = null;
 	}
 	
 	public void setFlipY(boolean flip) {
 		_flipY = flip;
+		_imageToDraw = null;
 	}
 	
@@ -839,4 +886,5 @@
 		updateSource();
 		updatePolygon();
+		_imageToDraw = null;
 	}
 	
