
Chapter 13.9. Perspective Transformations

From the website:

  Killer Game Programming in Java
  http://fivedots.coe.psu.ac.th/~ad/jg

  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the website.

Thanks,
  Andrew

============================

This directory contains 4 Java files:
  JAILoader.java,
  Warper.java, QuadPanel.java, ImagePanel.java

Two batch files:
  compile.bat, run.bat

One image file:
  jai-logo.gif

The subdirectory images\ contains 6 images suitable for use in the 
Warper application:
  billboard1.jpg,
  blackboard1.jpg, blackboard2.jpg,
  slide1.jpg, slide2.jpg,
  street1.jpg


----------------------------
Downloading the JAI

The JAI libraries for different platforms are located at: 
  http://download.java.net/media/jai/builds/release/1_1_3/

I downloaded jai-1_1_3-lib-windows-i586-jdk.exe for Windows, which 
offer native acceleration for many operations (when a 32-bit Java
run-time is being used; see the next section).

The installer places the library in 
C:\Program Files\Sun Microsystems\Java Advanced Imaging 1.1.3\
or C:\Program Files (x86)\Sun Microsystems\Java Advanced Imaging 1.1.3\
which is used by my batch files, compile.bat and run.bat

----------------------------

JAI, Media Libraries and Java 64-bit

JAI utilizes a media DLL on Windows to speed up its graphic operations.
However, the DLL was compiled for 32-bit Windows which means that it
cannot be used by a 64-bit Java run-time.

This doesn't 'kill' JAI, but makes it fall back to a pure-Java implementation
of the graphic operations, which is typically 5-15% slower.

You're notified about this, by the printing of the message:
  
  Error: Could not load mediaLib accelerator wrapper classes. 
  Continuing in pure Java mode.

You can check if you're using a 64-bit Java run-time by typing:

  > java -version

The report will mention "64-Bit" somewhere.

For more details, see:
http://stackoverflow.com/questions/5207145/jai-and-imageio-for-64-bit-windows

----------------------------
Compilation:

  > compile *.java
       // JAI must be installed


----------------------------
Execution: 

Use JAILoader to test JAI's installation:

  > run JAILoader <image file>
e.g.
  > run JAILoader jai-logo.gif

-----

The Warper application looks for a file in the images/
subdirectory.

  > run Warper <image file>
e.g.
  > run Warper blackboard2.jpg
       // this looks for images/blackboard2.jpg


  Add quad points to the left-hand panel using the mouse:
    * Left mouse button click: add a quad point;
        -- add the points in clockwise-order starting from the top-left

    * Middle mouse button (wheel) click: remove all points;

    * Right mouse button drag: drags the nearest point.


  The destination quad image is automatically stored in warpOut.png.

---------
Last updated: 3rd June 2014
