How do I insert an image and rotate it 270 degrees?

Q: How do I insert an image and rotate it 270 degrees?
----
A: As a starting point you may want to take a look at AddImage (http://
www.pdftron.com/net/samplecode.html#AddImage) and ElementBuilder
sample projects. To rotate an image 270 degrees you could use the
following snippet:

static double deg2rad = 3.1415926535 / 180.0;
static Matrix2D ImageRotate270(double width, double height, double
offset_x, double offset_y)
{
  Matrix2D mtx = Matrix2D.RotationMatrix(270 * deg2rad);
  mtx.Translate(1, 0); // Translate the unit image in first quadrant.

  // Concatentate scaling and translation with the rotation matrix.
  mtx = new Matrix2D(height, 0, 0, width, offset_x, offset_y) * mtx;
  return mtx;
}

The following is a sample use case to add rotated image to a new or an
existing PDF page:

ElementBuilder eb = new ElementBuilder();
ElementWriter writer = new ElementWriter();
writer.Begin(page);
Image img = Image.Create(doc, "peppers.jpg");
Element element = eb.CreateImage(img, ImageRotate270(200, 300, 50,
400));
writer.WritePlacedElement(element);
writer.End();
writer.Dispose();
eb.Dispose();