COMP: Do not use _stat64 with MinGW-32.

Unlike MinGW-w64, MinGW-32 aka MinGW, does not define as much of the API
including _stat64.  Do not use use _stat64 in TIFFImageIO when building with
MinGW-32.

Change-Id: I8f13a4500cdadf4f4adae7b5cf8893fe8b8cad55
ENH: Extract TiffReaderInternal to separate file

Refactored private class to be in separate private header.

Change-Id: Icb4008c1605a3a0b62c563350cf2e3bbe948ec6d
ENH: Refactor ReadTwoSamplePerPixelImage into template function

Reduce code duplication by using template method.

Change-Id: I45f417486e60a4d3e67ff31fa967dac069b3ce3e
ENH: Refactor GenericReadImage into template function

Reduce code duplication by using template method.

Change-Id: I79411ad6595258d54cbfa5a4152cc55994acd8e0
BUG: Remove Zeiss 2-channel support code in TIFFImageIO ( and LSMImageIO )

There are no tests for this branch of code. It only works in 3D under
certain cases. There are apparent bugs in the code such as not setting
all of the input image, and logically dead branches. Some downloaded
test images for similar described format do not load. This may effect
files with the extensions tif, tiff, or lsm.

Removal of this code will enable expansion of the current code to more
generically support multi-sample per pixel images.

For more robust reading of this type of image the SCIFIO remote
module should be used.

Change-Id: Idb98d69538db3bc8520881ea4a5e22476238c41e
ENH: Refactor method to convert RGBA image to output buffer

BUG: Address overflow issue when computing page offset with
TIFFReadRGBAImage method.

Extract repeated code to convert from ReadRGBAImage to output image
type.

Change-Id: Ia90b5e104f22c77493b8a4cd5bf640fd793b8b4b
ENH: Refactor duplicated code to read a page

Created a method to read a single page or sub-image in a tiff
file. Simular code was both in the ReadVolume method for 3-d and the
Read method for 2-d. The code block from ReadVolume was used because
it contained more typed cases. There for this patch does improve the
2d reading capabilities for tiffio, so that they are consistent with
the 3d.

Change-Id: I0fbfb19f04435a703bb3fa09ea4e79179592e443
BUG: Fix right oriented tiff images

The TIFFImageIO::ReadGenericImage method correctly handled top-left
oriented images, and bottom-right image, however images oriented with
right were non-correctly handled. These cases are now handled
correctly by the TIFFRGBAImage generic path.

New test images of the cthead1 image were added which have been
flipped the to the different orientation, and the matching orientation
tag specified so that they should all be read as equivalent
images. These have been added as a test case.

Change-Id: I058382d6d2e18341ab87edd165490be2187c1d15
BUG: Remove dead separated plannar code, add test

The PLANARCONFIG_SEPARATE block in TIFFImageIO::ReadGenericImage, was
preceded by a unreachable due to a conditional and exception
check. Support for this configuration remains in the TIFFReadRGBAImage
method. A test for the configuration has been added.

A new input image is added from the from the libTiff test images:

PlanarConfiguration = 2 (separated samples)
-------------------------------------------
oxford.tif      601x81 8-bit RGB (lzw) screendump off oxford

Change-Id: Ibb874f80809b70b1aee7a2c9ff1fc8544ed56c04
ENH: Include TIFF tags in the MetaDataDictionary

Add contribution from the Insight Journal:
http://hdl.handle.net/10380/3170

Change-Id: I20b02394d92c421bad75c5d0af496a6e80089ac0
STYLE: Fix minor kwstyle defects in test and test results

Change-Id: I4b2641d31acb5c764de4041bb7d21c08b3c99846
BUG: Use array delete operator for array new allocations

Change-Id: Ic9bc3c3792083a1a1b3fd842486a7436a4086150
ENH: add arbitrary TIFF TAGs to meta-data dictionary

A more general approach to adding custom tiff tags to the meta-data
dictionary has been used based on the implementation of libtiff's
PrintDirectory method and the libtiff "Defining New TIFF Tags"
documentation.

Additionally a new test image was added generated in Photoshop, which
has a novel pixel layout, and also contains additional tag types such
as byte, and size specified ascii.

Change-Id: Idb2e669e540cfbe27a932444011f4b9896ca403d
ENH: Reduce code duplicate in TIFFImageIO::ReadCurrentPage

Refactoring of the pixelOffset to include the number of components
remove the need for a separate block for RGB multi-component files.
BUG: Address Coverity warning about null pointer dereferences

The patch addressed the following Coverity warnings:

** CID 1243373:  Explicit null dereferenced  (FORWARD_NULL)
itkTIFFImageIO.cxx:
1192 in itk::TIFFImageIO::ReadTIFFTags()()

** CID 1243372:  Dereference null return value  (NULL_RETURNS)
itkTIFFImageIO.cxx:
1096 in itk::TIFFImageIO::ReadTIFFTags()()

** CID 1243371:  Dereference before null check  (REVERSE_INULL)
itkTIFFImageIO.cxx:
1100 in itk::TIFFImageIO::ReadTIFFTags()()
Last login: Fri Oct  3 19:47:29 on ttys004

Change-Id: I02c8435628c860ff03889b9b57e9dd1543bf82da
ENH: Remove support for TIFF tile as 3D and dead code

This TIFF file format is a file which contains a list of directories,
if there are no directories in the file it's not a valid tiff. Code
which supported 3D tiles was conditioned on a file with no directories
and no data. Additional code was removed related to a private SGI tag
TIFFTAG_TILEDEPTH, ImageJ specific tag also pre-conditioned on this
invalid case.

Change-Id: Id4ef171c5dbe0c797be206e0059c7488719ef6e6
ENH: RGBA read images should stay unchanged.

The image that are read with the TIFFReadRGBAImage should not have
their pixel types converted. This libtiff method always read images
into an ABGR uint8 format. When the tiff file is read by this method
it should report that uint8 and RGBA is the component an pixel type
for the image. This allows the standard ITK buffer conversion to be
performed.

This change remove extra cases and template instantiations.

Additionally the RGBAImageToBuffer method was flipping the image along
the y-axis, this has been more explicitly done with the call to
TIFFReadRGBAImageOriented.

Change-Id: I022b12921d406edb09730f905213b0db811f1bd4
ENH: Refactor per pixel conversion function to per scan-line method

This patch changes the implementation of conversion from the TIFF
scanline buffer from a function call on each pixel to a function call
per scanline. The enable efficient copying of similar scanline and
better reuse of variables for palette look ups.

This can increase the performance of reading grayscale images by up to
3X for cached files.

Change-Id: I24bb744fda35629f1c1ed7154e26e5708e912059
PERF: Refactor color table lookup

Change to use a index lookup for the color and gray scale
palettes. The remove excessive exception checking done on a per pixel
basis with the GetColor method. Additionally the InitializeColor
method was change do initialize the color palette variables.

An exception no longer occurs when an index exceeds the number of
entries in a palette. Instead a module operator is used to prevent
out of bounds memory access.

Change-Id: Ia62c65cd8b1be0d66c488540709a8fb961190cc9
BUG: Adding missing parentheses around boolean expression

Change-Id: I669d160ff3ba830f3c33ac87de434db41472eb79