/*******************************************************************************
 * DISCLAIMER: The sample code or utility or tool described herein
 *    is provided on an "as is" basis, without warranty of any kind.
 *    UIDAI does not warrant or guarantee the individual success
 *    developers may have in implementing the sample code on their
 *    environment. 
 *    
 *    UIDAI does not warrant, guarantee or make any representations
 *    of any kind with respect to the sample code and does not make
 *    any representations or warranties regarding the use, results
 *    of use, accuracy, timeliness or completeness of any data or
 *    information relating to the sample code. UIDAI disclaims all
 *    warranties, express or implied, and in particular, disclaims
 *    all warranties of merchantability, fitness for a particular
 *    purpose, and warranties related to the code, or any service
 *    or software related thereto. 
 *    
 *    UIDAI is not responsible for and shall not be liable directly
 *    or indirectly for any direct, indirect damages or costs of any
 *    type arising out of use or any action taken by you or others
 *    related to the sample code.
 *    
 *    THIS IS NOT A SUPPORTED SOFTWARE.
 ******************************************************************************/

package in.gov.uidai.tools;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.ComponentColorModel;
import java.awt.image.ComponentSampleModel;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.image.Raster;
import java.awt.image.SampleModel;
import java.awt.image.WritableRaster;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.CharacterCodingException;
import java.text.DecimalFormat;

import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageInputStream;
import javax.imageio.stream.ImageOutputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.JLabel;
import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import javax.swing.text.Element;

import com.sun.media.imageio.plugins.jpeg2000.J2KImageWriteParam;
import com.sun.media.imageio.stream.RawImageInputStream;

/**
 * 
 * @author Anujit
 * 
 */
public class AppUtil {

	static Clip clip = null;

	/**
	 * @param strPosition
	 * @return the position of the Finger for the value from the FMR header
	 */
	public static String getFingerPosition(String strPosition) {
		String str = "";
		if (strPosition.trim().equalsIgnoreCase("00"))
			str = "Unknown";
		if (strPosition.trim().equalsIgnoreCase("01"))
			str = "Right thumb";
		if (strPosition.trim().equalsIgnoreCase("02"))
			str = "Right index finger";
		if (strPosition.trim().equalsIgnoreCase("03"))
			str = "Right middle finger";
		if (strPosition.trim().equalsIgnoreCase("04"))
			str = "Right ring finger";
		if (strPosition.trim().equalsIgnoreCase("05"))
			str = "Right little finger";
		if (strPosition.trim().equalsIgnoreCase("06"))
			str = "Left thumb";
		if (strPosition.trim().equalsIgnoreCase("07"))
			str = "Left index finger";
		if (strPosition.trim().equalsIgnoreCase("08"))
			str = "Left middle finger";
		if (strPosition.trim().equalsIgnoreCase("09"))
			str = "Left ring finger";
		if (strPosition.trim().equalsIgnoreCase("10"))
			str = "Left little finge";
		if (strPosition.trim().equalsIgnoreCase("13"))
			str = "Plain right four fingers";
		if (strPosition.trim().equalsIgnoreCase("14"))
			str = "Plain left four fingers";
		if (strPosition.trim().equalsIgnoreCase("15"))
			str = "Plain thumbs";
		return str;
	}

	public static int CheckValidUID(String strUID) {
		int dMultTable[][] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, { 1, 2, 3, 4, 0, 6, 7, 8, 9, 5 }, { 2, 3, 4, 0, 1, 7, 8, 9, 5, 6 }, { 3, 4, 0, 1, 2, 8, 9, 5, 6, 7 },
				{ 4, 0, 1, 2, 3, 9, 5, 6, 7, 8 }, { 5, 9, 8, 7, 6, 0, 4, 3, 2, 1 }, { 6, 5, 9, 8, 7, 1, 0, 4, 3, 2 }, { 7, 6, 5, 9, 8, 2, 1, 0, 4, 3 }, { 8, 7, 6, 5, 9, 3, 2, 1, 0, 4 },
				{ 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 } };
		int permTable[][] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, { 1, 5, 7, 6, 2, 8, 3, 0, 9, 4 }, { 5, 8, 0, 3, 7, 9, 6, 1, 4, 2 }, { 8, 9, 1, 6, 0, 4, 3, 5, 2, 7 }, { 9, 4, 5, 3, 1, 2, 6, 8, 7, 0 },
				{ 4, 2, 8, 6, 5, 7, 3, 9, 0, 1 }, { 2, 7, 9, 3, 8, 0, 6, 4, 1, 5 }, { 7, 0, 4, 6, 9, 1, 3, 2, 5, 8 } };
		int i = 0, c = 0;

		for (i = 0; i < 12; i++) {
			int ni = 0, newC = 0;

			if (Character.isDigit(strUID.charAt(11 - i)))
				ni = strUID.charAt(11 - i) - '0';
			else {
				return (-1);
			}
			newC = dMultTable[c][permTable[i % 8][ni]];
			c = newC;
		}
		if (c == 0)
			return (0);
		return (-1);
	}

	/**
	 * Creates iso file and writes byte array to the file.
	 * 
	 * @param filename
	 * @param dataLine
	 */
	public static void createFile(String filename, byte[] dataLine) {
		FileChannel wChannel;
		try {
			ByteBuffer bbuf = ByteBuffer.wrap(dataLine);
			File outFile = new File(filename);
			wChannel = new FileOutputStream(outFile).getChannel();
			wChannel.write(bbuf);
			wChannel.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (CharacterCodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static String getCompressionAlgorithm(String strCode) {
		String rtnString = "";
		if (strCode.contains("00"))
			rtnString = "Uncompressed - no bit packing";
		if (strCode.contains("01"))
			rtnString = "Uncompressed - bit packed";
		if (strCode.contains("02"))
			rtnString = "Compressed - WSQ";
		if (strCode.contains("03"))
			rtnString = "Compressed - JPEG";
		if (strCode.contains("04"))
			rtnString = "Compressed - JPEG2000";
		if (strCode.contains("05"))
			rtnString = "PNG";

		return rtnString;

	}

	public static void getIsoFirChecked(JTextPane textPane, File file, String fileName, JLabel lblImage) throws FileNotFoundException, IOException {
		String color = "black";
		FileInputStream fis = new FileInputStream(file);
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		byte[] buf = new byte[1024];
		try {
			for (int readNum; (readNum = fis.read(buf)) != -1;) {
				bos.write(buf, 0, readNum);
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		byte[] bytes = bos.toByteArray();

		StringBuffer stb = new StringBuffer();
		stb.append("File: " + fileName + "\n");
		printMessage(textPane, color, 18, stb.toString(), true);
		stb = null;

		stb = new StringBuffer();
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		stb = new StringBuffer();
		stb.append("\n");
		stb.append("Field                                               ");
		stb.append("Byte                                ");
		stb.append("Value (Hexa Decimal)              ");
		stb.append("Remarks");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), true);
		stb = null;

		stb = new StringBuffer();
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		stb = new StringBuffer();
		stb.append("Format identifier                              ");
		stb.append(" 1 - 4                                  ");

		StringBuffer str = new StringBuffer();
		str.append(bytesToHex(new byte[] { bytes[0] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[1] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[2] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[3] }));

		stb.append(str.toString());
		String fiRemarks = "FIR (Finger Image Record)";
		if (!str.toString().trim().equalsIgnoreCase("46 49 52 00")) {
			color = "red";
			fiRemarks = "Not FIR (Finger Image Record)";
		}
		stb.append("                           ");
		stb.append(fiRemarks);
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;
		str = null;
		color = "black";

		stb = new StringBuffer();
		stb.append("Version number                               ");
		stb.append(" 5 - 8                                  ");

		str = new StringBuffer();
		str.append(bytesToHex(new byte[] { bytes[4] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[5] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[6] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[7] }));

		stb.append(str.toString());
		String vnRemarks = "010";
		if (!str.toString().trim().equalsIgnoreCase("30 31 30 00")) {
			color = "red";
			vnRemarks = "Not 010";
		}
		stb.append("                           ");
		stb.append(vnRemarks);
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;
		str = null;
		color = "black";

		stb = new StringBuffer();
		stb.append("Record length                                 ");
		stb.append(" 9 - 14                                 ");
		stb.append(bytesToHex(new byte[] { bytes[8] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[9] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[10] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[11] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[12] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[13] }));
		stb.append("                  ");
		int recLen = Integer.parseInt((String.valueOf(bytesToHex(new byte[] { bytes[8] })) + String.valueOf(bytesToHex(new byte[] { bytes[9] })) + String.valueOf(bytesToHex(new byte[] { bytes[10] }))
				+ String.valueOf(bytesToHex(new byte[] { bytes[11] })) + String.valueOf(bytesToHex(new byte[] { bytes[12] })) + String.valueOf(bytesToHex(new byte[] { bytes[13] }))), 16);
		stb.append(recLen);
		stb.append("\n");

		stb.append("Device ID                                       ");
		stb.append("15 - 16                                ");
		stb.append(bytesToHex(new byte[] { bytes[14] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[15] }));
		stb.append("                                   ");
		stb.append("Vendor supplied");
		stb.append("\n");

		stb.append("Image Acquisition Level                    ");
		stb.append("17 - 18                                ");
		stb.append(bytesToHex(new byte[] { bytes[16] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[17] }));
		stb.append("                                    ");
		stb.append("Level " + Integer.parseInt(bytesToHex(new byte[] { bytes[17] }), 16));
		stb.append("\n");

		stb.append("Number of fingers                            ");
		stb.append("19                                       ");
		stb.append(bytesToHex(new byte[] { bytes[18] }));
		stb.append("                                        ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[18] }), 16));
		stb.append("\n");

		stb.append("Scale units                                      ");
		stb.append("20                                       ");
		stb.append(bytesToHex(new byte[] { bytes[19] }));
		stb.append("                                        ");
		if (bytesToHex(new byte[] { bytes[19] }).equalsIgnoreCase("01"))
			stb.append("Pixels per inch");
		if (bytesToHex(new byte[] { bytes[19] }).equalsIgnoreCase("02"))
			stb.append("Pixels per cm");
		stb.append("\n");

		stb.append("Scale resolution (horizontal)               ");
		stb.append("21 - 22                                ");
		stb.append(bytesToHex(new byte[] { bytes[20] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[21] }));
		stb.append("                                    ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[20] })) + String.valueOf(bytesToHex(new byte[] { bytes[21] })), 16) + " pixels.");
		stb.append("\n");

		stb.append("Scale resolution (vertical)                  ");
		stb.append("23 - 24                                ");
		stb.append(bytesToHex(new byte[] { bytes[22] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[23] }));
		stb.append("                                    ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[22] })) + String.valueOf(bytesToHex(new byte[] { bytes[23] })), 16) + " pixels.");
		stb.append("\n");

		stb.append("Image resolution (horizontal)             ");
		stb.append("25 - 26                                ");
		stb.append(bytesToHex(new byte[] { bytes[24] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[25] }));
		stb.append("                                    ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[24] })) + String.valueOf(bytesToHex(new byte[] { bytes[25] })), 16) + " pixels.");
		stb.append("\n");

		stb.append("Image resolution (vertical)                 ");
		stb.append("27 - 28                                ");
		stb.append(bytesToHex(new byte[] { bytes[26] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[27] }));
		stb.append("                                    ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[26] })) + String.valueOf(bytesToHex(new byte[] { bytes[27] })), 16) + " pixels.");
		stb.append("\n");

		stb.append("Pixel depth                                     ");
		stb.append("29                                       ");
		stb.append(bytesToHex(new byte[] { bytes[28] }));
		stb.append("                                        ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[28] }), 16) + " Gray levels");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		stb = new StringBuffer();
		stb.append("Image compression Algorithm            ");
		stb.append("30                                       ");
		stb.append(bytesToHex(new byte[] { bytes[29] }));
		stb.append("                                        ");

		String icaRemarks = AppUtil.getCompressionAlgorithm(bytesToHex(new byte[] { bytes[29] }));
		/*
		 * if (!bytesToHex(new byte[] { bytes[29]
		 * }).toString().trim().equalsIgnoreCase("00")) { color = "red";
		 * icaRemarks = "Image Compressed"; }
		 */
		stb.append(icaRemarks);
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;
		color = "black";

		stb = new StringBuffer();
		stb.append("Reserved                                        ");
		stb.append("31 - 32                                 ");
		stb.append(bytesToHex(new byte[] { bytes[30] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[31] }));
		stb.append("                                   ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[30] }), 16) + Integer.parseInt(bytesToHex(new byte[] { bytes[31] }), 16));
		stb.append("\n");

		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");

		stb.append("Length of finger data block               ");
		stb.append("33 - 36                                ");
		stb.append(bytesToHex(new byte[] { bytes[32] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[33] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[34] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[35] }));
		stb.append("                           ");
		int len = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[32] })) + String.valueOf(bytesToHex(new byte[] { bytes[33] })) + String.valueOf(bytesToHex(new byte[] { bytes[34] }))
				+ String.valueOf(bytesToHex(new byte[] { bytes[35] })), 16);
		stb.append(len);
		if (recLen - len != 32) {
			stb.append(" (Invalid data length)");
			stb.append("\n");
			printMessage(textPane, "red", 12, stb.toString(), false);
		} else {
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
		}
		stb = null;

		stb = new StringBuffer();
		stb.append("Finger position                                 ");
		stb.append("37                                       ");
		stb.append(bytesToHex(new byte[] { bytes[36] }));
		stb.append("                                        ");
		String fpRemarks = AppUtil.getFingerPosition(bytesToHex(new byte[] { bytes[36] }));
		if (Integer.parseInt(bytesToHex(new byte[] { bytes[36] }), 16) > 15) {
			color = "red";
			fpRemarks = "Invalid Range";
		}
		stb.append(fpRemarks);
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;
		color = "black";

		stb = new StringBuffer();
		stb.append("Count of views                                ");
		stb.append("38                                       ");
		stb.append(bytesToHex(new byte[] { bytes[37] }));
		stb.append("                                         ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[37] }), 16));
		stb.append("\n");

		stb.append("View number                                  ");
		stb.append("39                                       ");
		stb.append(bytesToHex(new byte[] { bytes[38] }));
		stb.append("                                         ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[38] }), 16));
		stb.append("\n");

		stb.append("Finger image quality                         ");
		stb.append("40                                       ");
		stb.append(bytesToHex(new byte[] { bytes[39] }));
		stb.append("                                         ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[39] }), 16));
		stb.append("\n");

		stb.append("Impression type                              ");
		stb.append("41                                       ");
		stb.append(bytesToHex(new byte[] { bytes[40] }));
		stb.append("                                         ");
		stb.append("Live-scan plain " + Integer.parseInt(bytesToHex(new byte[] { bytes[40] }), 16));
		stb.append("\n");

		stb.append("Horizontal line length                        ");
		stb.append("42 - 43                                ");
		stb.append(bytesToHex(new byte[] { bytes[41] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[42] }));
		stb.append("                                    ");
		stb.append("Width " + Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[41] })) + String.valueOf(bytesToHex(new byte[] { bytes[42] })), 16));
		stb.append("\n");

		stb.append("Vertical line length                           ");
		stb.append("44 - 45                                 ");
		stb.append(bytesToHex(new byte[] { bytes[43] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[44] }));
		stb.append("                                    ");
		stb.append("Height " + Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[43] })) + String.valueOf(bytesToHex(new byte[] { bytes[44] })), 16));
		stb.append("\n");

		stb.append("Reserved                                        ");
		stb.append("46                                       ");
		stb.append(bytesToHex(new byte[] { bytes[45] }));
		stb.append("                                         ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[45] }), 16));
		stb.append("\n");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		textPane.setCaretPosition(0);
		new ISORawToBMPImageConverter().showImage(bytes, lblImage);
	}

	public static void getIsoFmrChecked(JTextPane textPane, File file, String fileName) throws FileNotFoundException, IOException {
		String color = "black";
		FileInputStream fis = new FileInputStream(file);
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		byte[] buf = new byte[1024];
		try {
			for (int readNum; (readNum = fis.read(buf)) != -1;) {
				bos.write(buf, 0, readNum);
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		byte[] bytes = bos.toByteArray();

		StringBuffer stb = new StringBuffer();
		stb.append("File: " + fileName + "\n");
		printMessage(textPane, color, 18, stb.toString(), true);
		stb = null;

		stb = new StringBuffer();
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		stb = new StringBuffer();
		stb.append("\n");
		stb.append("Field                                               ");
		stb.append("Byte                                ");
		stb.append("Value (Hexa Decimal)              ");
		stb.append("Remarks");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), true);
		stb = null;

		stb = new StringBuffer();
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		stb = new StringBuffer();
		stb.append("Format identifier                              ");
		stb.append(" 1 - 4                                  ");

		StringBuffer str = new StringBuffer();
		str.append(bytesToHex(new byte[] { bytes[0] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[1] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[2] }));
		str.append(" ");
		str.append(bytesToHex(new byte[] { bytes[3] }));

		stb.append(str.toString());
		String fiRemarks = "FMR (Finger Minutiae Record)";
		if (!str.toString().trim().equalsIgnoreCase("46 4D 52 00")) {
			color = "red";
			fiRemarks = "Not FMR (Finger Minutiae Record)";
		}
		stb.append("                           ");
		stb.append(fiRemarks);
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;
		str = null;
		color = "black";

		stb = new StringBuffer();
		stb.append("Version number                               ");
		stb.append(" 5 - 8                                  ");
		StringBuffer strV = new StringBuffer();
		strV.append(bytesToHex(new byte[] { bytes[4] }));
		strV.append(" ");
		strV.append(bytesToHex(new byte[] { bytes[5] }));
		strV.append(" ");
		strV.append(bytesToHex(new byte[] { bytes[6] }));
		strV.append(" ");
		strV.append(bytesToHex(new byte[] { bytes[7] }));
		stb.append(strV.toString());
		String vRemarks = " 20";
		if (!strV.toString().trim().equalsIgnoreCase("20 32 30 00")) {
			color = "red";
			vRemarks = "Invalid version";
		}
		stb.append("                             ");
		stb.append(vRemarks);
		stb.append("\n");
		color = "black";
		stb.append("Record length                                 ");
		stb.append(" 9 - 12                                 ");
		stb.append(bytesToHex(new byte[] { bytes[8] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[9] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[10] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[11] }));
		stb.append("                           ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[8] })) + String.valueOf(bytesToHex(new byte[] { bytes[9] })) + String.valueOf(bytesToHex(new byte[] { bytes[10] }))
				+ String.valueOf(bytesToHex(new byte[] { bytes[11] })), 16)
				+ " bytes");
		stb.append("\n");

		stb.append("Device ID                                       ");
		stb.append("13 - 14                                ");
		stb.append(bytesToHex(new byte[] { bytes[12] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[13] }));
		stb.append("                                    ");
		stb.append("Vendor specified");
		stb.append("\n");

		stb.append("Image size (horizontal)                     ");
		stb.append("15 - 16                                ");
		stb.append(bytesToHex(new byte[] { bytes[14] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[15] }));
		stb.append("                                     ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[14] })) + String.valueOf(bytesToHex(new byte[] { bytes[15] })), 16) + " pixels");
		stb.append("\n");

		stb.append("Image size (vertical)                         ");
		stb.append("17 - 18                                ");
		stb.append(bytesToHex(new byte[] { bytes[16] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[17] }));
		stb.append("                                    ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[16] })) + String.valueOf(bytesToHex(new byte[] { bytes[17] })), 16) + " pixels");
		stb.append("\n");

		stb.append("Horizontal resolution                         ");
		stb.append("19 - 20                                ");
		stb.append(bytesToHex(new byte[] { bytes[18] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[19] }));
		stb.append("                                    ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[18] })) + String.valueOf(bytesToHex(new byte[] { bytes[19] })), 16) + " pixels per cm");
		stb.append("\n");

		stb.append("Vertical resolution                             ");
		stb.append("21 - 22                               ");
		stb.append(bytesToHex(new byte[] { bytes[20] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[21] }));
		stb.append("                                    ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[20] })) + String.valueOf(bytesToHex(new byte[] { bytes[21] })), 16) + " pixels per cm");
		stb.append("\n");

		stb.append("Number of finger views                     ");
		stb.append("23                                      ");
		stb.append(bytesToHex(new byte[] { bytes[22] }));
		stb.append("                                        ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[22] }), 16));
		stb.append("\n");

		stb.append("Reserved                                        ");
		stb.append("24                                       ");
		stb.append(bytesToHex(new byte[] { bytes[23] }));
		stb.append("                                        ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[23] }), 16));
		stb.append("\n");

		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		stb = new StringBuffer();
		stb.append("Finger position                                 ");
		stb.append("25                                       ");
		stb.append(bytesToHex(new byte[] { bytes[24] }));
		stb.append("                                        ");
		String fpRemarks = "Unknown";
		if (!bytesToHex(new byte[] { bytes[24] }).toString().trim().equalsIgnoreCase("00")) {
			color = "red";
			fpRemarks = AppUtil.getFingerPosition(bytesToHex(new byte[] { bytes[24] }));
		}
		stb.append(fpRemarks);
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;
		color = "black";

		stb = new StringBuffer();
		stb.append("View number and Impression type      ");
		stb.append("26                                       ");
		stb.append(bytesToHex(new byte[] { bytes[25] }));
		stb.append("                                        ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[25] }), 16));
		stb.append("\n");

		stb.append("Finger quality                                   ");
		stb.append("27                                       ");
		stb.append(bytesToHex(new byte[] { bytes[26] }));
		stb.append("                                         ");
		stb.append(Integer.parseInt(bytesToHex(new byte[] { bytes[26] }), 16));
		stb.append("\n");

		stb.append("Number of minutiae                          ");
		stb.append("28                                       ");
		stb.append(bytesToHex(new byte[] { bytes[27] }));
		stb.append("                                         ");
		int i = Integer.parseInt(bytesToHex(new byte[] { bytes[27] }), 16);
		stb.append(i);
		stb.append("\n");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;
		int byteIdx = 28;
		int idx = 28;
		// Loop thru the number of Minutiae points
		stb = new StringBuffer();
		stb.append("Copy and paste the below data in Notepad and save as .csv file to open in Excel for plotting the minutiae points in graph.");
		stb.append("\n");
		stb.append("Minutia,   X Bytes,    X(Hex), X(Dec), Y Bytes,    Y(Hex),  Y(Dec), Th(Byte), Th(Hex), Th(Dec), Qlty(Byte), Qlty(Hex), Qlty(Dec)");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), true);
		stb = null;
		stb = new StringBuffer();
		for (int j = 1; j <= i; j++) {
			if (j < 10)
				stb.append("0" + j + ",        ");
			else
				stb.append(j + ",        ");
			// X byte
			if (idx < 99)
				stb.append("0" + (++idx) + " - " + "0" + (++idx) + ",      ");
			else
				stb.append((++idx) + " - " + (++idx) + ",      ");
			String temp1 = bytesToHex(new byte[] { bytes[byteIdx] });
			byte a = (byte) ((byte) bytes[byteIdx] << 2);
			byte b = (byte) ((byte) a >> 2);
			String temp2 = bytesToHex(new byte[] { bytes[++byteIdx] });

			stb.append(temp1);
			stb.append(" ");
			stb.append(temp2);
			stb.append(",    ");
			int xDec = Integer.parseInt((String.valueOf(b) + String.valueOf(temp2)), 16);
			if (xDec < 100)
				stb.append("0" + xDec);
			else
				stb.append(xDec);
			stb.append(",    ");

			// Y byte
			if (idx < 99)
				stb.append("0" + (++idx) + " - " + "0" + (++idx) + ",    ");
			else
				stb.append((++idx) + " - " + (++idx) + ",    ");
			String temp3 = bytesToHex(new byte[] { bytes[++byteIdx] });
			String temp4 = bytesToHex(new byte[] { bytes[++byteIdx] });
			stb.append(temp3);
			stb.append(" ");
			stb.append(temp4);
			stb.append(",      ");
			int yDec = Integer.parseInt((String.valueOf(temp3) + String.valueOf(temp4)), 16);
			if (yDec < 100)
				stb.append("0" + yDec);
			else
				stb.append(yDec);
			stb.append(",      ");
			// Theta Byte value
			if (idx < 99)
				stb.append("0" + (++idx) + ",      ");
			else
				stb.append((++idx) + ",      ");

			stb.append(bytesToHex(new byte[] { bytes[++byteIdx] }));
			stb.append(",         ");
			int thDec = Integer.parseInt(bytesToHex(new byte[] { bytes[byteIdx] }), 16);
			if (thDec < 100)
				stb.append("0" + thDec);
			else
				stb.append(thDec);
			stb.append(",           ");
			// Quality byte value
			if (idx < 99)
				stb.append("0" + (++idx) + ",         ");
			else
				stb.append((++idx) + ",         ");
			stb.append(bytesToHex(new byte[] { bytes[++byteIdx] }));
			stb.append(",            ");
			int qDec = Integer.parseInt(bytesToHex(new byte[] { bytes[byteIdx] }), 16);
			if (qDec < 100)
				stb.append("0" + qDec);
			else
				stb.append(qDec);
			byteIdx++;
			stb.append("\n");
		}

		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");
		stb.append("Extended Data Block Length              ");
		stb.append((++idx) + " - " + (++idx) + "                           ");
		stb.append(bytesToHex(new byte[] { bytes[byteIdx] }));
		stb.append(" ");
		stb.append(bytesToHex(new byte[] { bytes[byteIdx + 1] }));
		stb.append("                                       ");
		stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[byteIdx] })) + String.valueOf(bytesToHex(new byte[] { bytes[byteIdx + 1] })), 16));
		stb.append("\n");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("------------------------------------------------------------------------------------------------------");
		stb.append("\n");
		printMessage(textPane, color, 12, stb.toString(), false);
		stb = null;

		textPane.setCaretPosition(0);
	}

	public static void getIsoIIRChecked(JTextPane textPane, File file, String fileName) throws FileNotFoundException, IOException {
		String color = "black";
		FileInputStream fis = new FileInputStream(file);
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		byte[] buf = new byte[1024];
		try {
			for (int readNum; (readNum = fis.read(buf)) != -1;) {
				bos.write(buf, 0, readNum);
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		byte[] bytes = bos.toByteArray();

		if (bytes.length > 59) {

			StringBuffer stb = new StringBuffer();
			stb.append("File: " + fileName + "\n");
			printMessage(textPane, color, 18, stb.toString(), true);
			stb = null;

			stb = new StringBuffer();
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;

			stb = new StringBuffer();
			stb.append("\n");
			stb.append("Field                                               ");
			stb.append("Byte                                ");
			stb.append("Value (Hexa Decimal)              ");
			stb.append("Remarks");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), true);
			stb = null;

			stb = new StringBuffer();
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;

			stb = new StringBuffer();
			stb.append("Format identifier                              ");
			stb.append(" 1 - 4                                  ");

			StringBuffer str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[0] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[1] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[2] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[3] }));

			stb.append(str.toString());
			String fiRemarks = "IIR (Iris Image Record)";
			if (!str.toString().trim().equalsIgnoreCase("49 49 52 00")) {
				color = "red";
				fiRemarks = "Not IIR (Iris Image Record)";
			}
			stb.append("                           ");
			stb.append(fiRemarks);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			stb = new StringBuffer();
			stb.append("Version number                               ");
			stb.append(" 5 - 8                                  ");
			StringBuffer strV = new StringBuffer();
			strV.append(bytesToHex(new byte[] { bytes[4] }));
			strV.append(" ");
			strV.append(bytesToHex(new byte[] { bytes[5] }));
			strV.append(" ");
			strV.append(bytesToHex(new byte[] { bytes[6] }));
			strV.append(" ");
			strV.append(bytesToHex(new byte[] { bytes[7] }));
			stb.append(strV.toString());
			String vRemarks = "";
			// int vRemarks = Integer.parseInt(String.valueOf(bytesToHex(new
			// byte[] { bytes[4] }))
			// + String.valueOf(bytesToHex(new byte[] { bytes[5] }))
			// + String.valueOf(bytesToHex(new byte[] { bytes[6] }))
			// + String.valueOf(bytesToHex(new byte[] { bytes[7] })), 16);
			stb.append("                          ");
			stb.append(vRemarks);
			stb.append("\n");
			color = "black";

			stb.append("Record length                                 ");
			stb.append(" 9 - 12                                 ");
			stb.append(bytesToHex(new byte[] { bytes[8] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[9] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[10] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[11] }));
			stb.append("                           ");
			stb.append(Integer.parseInt(
					String.valueOf(bytesToHex(new byte[] { bytes[8] })) + String.valueOf(bytesToHex(new byte[] { bytes[9] })) + String.valueOf(bytesToHex(new byte[] { bytes[10] }))
							+ String.valueOf(bytesToHex(new byte[] { bytes[11] })), 16)
					+ " bytes");
			stb.append("\n");

			stb.append("Device ID                                       ");
			stb.append("13 - 14                                ");
			stb.append(bytesToHex(new byte[] { bytes[12] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[13] }));
			stb.append("                                    ");
			int devId = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[12] })) + String.valueOf(bytesToHex(new byte[] { bytes[13] })), 16);
			String deviceId = String.valueOf(devId);
			if (devId == 0) {
				deviceId = devId + " : " + "CAPTURE_DEVICE_UNDEF";
			}
			stb.append(deviceId);
			stb.append("\n");

			stb.append("No. of iris biometric subtypes             ");
			stb.append("15                                       ");
			stb.append(bytesToHex(new byte[] { bytes[14] }));
			stb.append("                                        ");
			stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[14] })), 16));
			stb.append("\n");

			stb.append("Record header length                       ");
			stb.append("16 - 17                                ");
			stb.append(bytesToHex(new byte[] { bytes[15] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[16] }));
			stb.append("                                   ");
			stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[15] })) + String.valueOf(bytesToHex(new byte[] { bytes[16] })), 16));
			stb.append("\n");

			stb.append("Iris image properties bitfield               ");
			stb.append("18 - 19                                ");
			stb.append(bytesToHex(new byte[] { bytes[17] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[18] }));
			stb.append("                                    ");
			int propBit = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[17] })) + String.valueOf(bytesToHex(new byte[] { bytes[18] })), 16);
			String binary = Integer.toBinaryString(propBit);
			int len = binary.length();
			if (len < 16) {
				for (int i = 0; i < 16 - len; i++) {
					binary = 0 + binary;
				}
			}
			stb.append(propBit + " : " + binary);
			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(14, 16))) {
				stb.append("                                                                                                                                           ");
				stb.append("Horizontal orientation : ORIENTATION_UNDEF");
			} else if ("01".equalsIgnoreCase(binary.substring(14, 16))) {
				stb.append("                                                                                                                                           ");
				stb.append("Horizontal orientation : ORIENTATION_BASE");
			} else if ("10".equalsIgnoreCase(binary.substring(14, 16))) {
				stb.append("                                                                                                                                           ");
				stb.append("Horizontal orientation : ORIENTATION_FLIPPED");
			}
			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(12, 14))) {
				stb.append("                                                                                                                                           ");
				stb.append("Vertical orientation : ORIENTATION_UNDEF");
			} else if ("01".equalsIgnoreCase(binary.substring(12, 14))) {
				stb.append("                                                                                                                                           ");
				stb.append("Vertical orientation : ORIENTATION_BASE");
			} else if ("10".equalsIgnoreCase(binary.substring(12, 14))) {
				stb.append("                                                                                                                                           ");
				stb.append("Vertical orientation : ORIENTATION_FLIPPED");
			}
			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(10, 12))) {
				stb.append("                                                                                                                                           ");
				stb.append("Scan type (rectilinear only) : SCAN_TYPE_CORRECTED");
			} else if ("01".equalsIgnoreCase(binary.substring(10, 12))) {
				stb.append("                                                                                                                                           ");
				stb.append("Scan type (rectilinear only) : SCAN_TYPE_PROGRESSIVE");
			} else if ("10".equalsIgnoreCase(binary.substring(10, 12))) {
				stb.append("                                                                                                                                           ");
				stb.append("Scan type (rectilinear only) : SCAN_TYPE_INTERLACE_FRAME");
			} else if ("11".equalsIgnoreCase(binary.substring(10, 12))) {
				stb.append("                                                                                                                                           ");
				stb.append("Scan type (rectilinear only) : SCAN_TYPE_INTERLACE_FIELD");
			}
			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(8, 10))) {
				stb.append("                                                                                                                                           ");
				stb.append("Iris occlusions (polar only) : IROCC_UNDEF");
			} else if ("01".equalsIgnoreCase(binary.substring(8, 10))) {
				stb.append("                                                                                                                                           ");
				stb.append("Iris occlusions (polar only) : ROCC_PROCESSED");
			}
			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(6, 8))) {
				stb.append("                                                                                                                                           ");
				stb.append("Occlusion filling (polar only) : IROCC_ZEROFILL");
			} else if ("01".equalsIgnoreCase(binary.substring(6, 8))) {
				stb.append("                                                                                                                                           ");
				stb.append("Occlusion filling (polar only) : IROC_UNITFILL");
			}
			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(4, 6))) {
				stb.append("                                                                                                                                           ");
				stb.append("Boundary extraction (polar only) : IRBNDY_UNDEF");
			} else if ("01".equalsIgnoreCase(binary.substring(4, 6))) {
				stb.append("                                                                                                                                           ");
				stb.append("Boundary extraction (polar only) : IRBNDY_PROCESSED");
			}
			stb.append("\n");

			stb.append("Iris diameter                                    ");
			stb.append("20 - 21                                ");
			stb.append(bytesToHex(new byte[] { bytes[19] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[20] }));
			stb.append("                                    ");
			stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[19] })) + String.valueOf(bytesToHex(new byte[] { bytes[20] })), 16) + " pixels");
			stb.append("\n");

			stb.append("Image format                                  ");
			stb.append("22 - 23                                ");
			stb.append(bytesToHex(new byte[] { bytes[21] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[22] }));
			stb.append("                                    ");
			int format = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[21] })) + String.valueOf(bytesToHex(new byte[] { bytes[22] })), 16);
			String iformat = String.valueOf(format);
			if (format == 2) {
				iformat = format + " : " + "IMAGEFORMAT_MONO_RAW";
			} else if (format == 4) {
				iformat = format + " : " + "IMAGEFORMAT_RGB_RAW";
			} else if (format == 6) {
				iformat = format + " : " + "IMAGEFORMAT_MONO_JPEG";
			} else if (format == 8) {
				iformat = format + " : " + "IMAGEFORMAT_RGB_JPEG";
			} else if (format == 10) {
				iformat = format + " : " + "IMAGEFORMAT_MONO_JPEG_LS";
			} else if (format == 12) {
				iformat = format + " : " + "IMAGEFORMAT_RGB_JPEG_LS";
			} else if (format == 14) {
				iformat = format + " : " + "IMAGEFORMAT_MONO_JPEG2000";
			}
			stb.append(iformat);
			stb.append("\n");

			stb.append("Raw image width                             ");
			stb.append("24 - 25                                ");
			stb.append(bytesToHex(new byte[] { bytes[23] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[24] }));
			stb.append("                                    ");
			int width = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[23] })) + String.valueOf(bytesToHex(new byte[] { bytes[24] })), 16);
			String iWidth = String.valueOf(width);
			if (width == 0) {
				iWidth = width + " : " + "WIDTH_UNDEF";
			}
			stb.append(iWidth);
			stb.append("\n");

			stb.append("Raw image height                            ");
			stb.append("26 - 27                                ");
			stb.append(bytesToHex(new byte[] { bytes[25] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[26] }));
			stb.append("                                    ");
			int height = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[25] })) + String.valueOf(bytesToHex(new byte[] { bytes[26] })), 16);
			String iHeight = String.valueOf(height);
			if (height == 0) {
				iHeight = height + " : " + "HEIGHT_UNDEF";
			}
			stb.append(iHeight);
			stb.append("\n");

			stb.append("Intensity depth                               ");
			stb.append("28                                       ");
			stb.append(bytesToHex(new byte[] { bytes[27] }));
			stb.append("                                        ");
			int dpt = Integer.parseInt(bytesToHex(new byte[] { bytes[27] }), 16);
			String iDepth = String.valueOf(dpt);
			if (dpt == 0) {
				iDepth = dpt + " : " + "INTENSITY_DEPTH_UNDEF";
			}
			stb.append(iDepth);
			stb.append("\n");

			stb.append("Image transformation                       ");
			stb.append("29                                       ");
			stb.append(bytesToHex(new byte[] { bytes[28] }));
			stb.append("                                        ");
			int trnsf = Integer.parseInt(bytesToHex(new byte[] { bytes[28] }), 16);
			String itrnsf = String.valueOf(trnsf);
			if (trnsf == 0) {
				itrnsf = trnsf + " : " + "TRANS_UNDEF";
			} else if (trnsf == 1) {
				itrnsf = trnsf + " : " + "TRANS_STD";
			}
			stb.append(itrnsf);
			stb.append("\n");

			stb.append("Device unique identifier                    ");
			stb.append("30 - 45   ");
			stb.append(bytesToHex(new byte[] { bytes[29] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[30] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[31] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[32] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[33] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[34] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[35] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[36] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[37] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[38] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[39] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[40] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[41] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[42] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[43] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[44] }));
			stb.append("  ");
			stb.append("Device Serial number, identified by the first character 'D'");
			stb.append("\n");
			stb.append("                                                                                                                                           ");
			stb.append("Host PC Mac address, identified by the first character 'M'");
			stb.append("\n");
			stb.append("                                                                                                                                           ");
			stb.append("Host PC processor ID, identified by the first character 'P'");
			stb.append("\n");
			stb.append("                                                                                                                                           ");
			stb.append("No serial number, identified by all zero�s");
			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");

			stb.append("Biometric subtype identifier              ");
			stb.append("46                                       ");
			stb.append(bytesToHex(new byte[] { bytes[45] }));
			stb.append("                                        ");
			int stype = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[45] })), 16);
			String bstype = String.valueOf(stype);
			if (stype == 0) {
				bstype = stype + " : " + "EYE_UNDEF";
			} else if (stype == 1) {
				bstype = stype + " : " + "EYE_RIGHT";
			} else if (stype == 2) {
				bstype = stype + " : " + "EYE_LEFT";
			}
			stb.append(bstype);
			stb.append("\n");

			stb.append("Number of iris images                      ");
			stb.append("47 - 48                                ");
			stb.append(bytesToHex(new byte[] { bytes[46] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[47] }));
			stb.append("                                    ");
			stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[46] })) + String.valueOf(bytesToHex(new byte[] { bytes[47] })), 16));
			stb.append("\n");

			stb.append("Image sequence number                 ");
			stb.append("49 - 50                                ");
			stb.append(bytesToHex(new byte[] { bytes[48] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[49] }));
			stb.append("                                    ");
			stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[48] })) + String.valueOf(bytesToHex(new byte[] { bytes[49] })), 16));
			stb.append("\n");

			stb.append("Image quality medium                     ");
			stb.append("51                                       ");
			stb.append(bytesToHex(new byte[] { bytes[50] }));
			stb.append("                                        ");
			stb.append(Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[50] })), 16));
			stb.append("\n");

			stb.append("Rotation angle                               ");
			stb.append("52 - 53                                ");
			stb.append(bytesToHex(new byte[] { bytes[51] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[52] }));
			stb.append("                                     ");
			int rAngle = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[51] })) + String.valueOf(bytesToHex(new byte[] { bytes[52] })), 16);
			String irAngle = String.valueOf(rAngle);
			if (rAngle == 65535) {
				irAngle = rAngle + " : " + "ROT_ANGLE_UNDEF";
			}
			stb.append(irAngle);
			stb.append("\n");

			stb.append("Rotation uncertainty                       ");
			stb.append("54 - 55                                ");
			stb.append(bytesToHex(new byte[] { bytes[53] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[54] }));
			stb.append("                                     ");
			int rotUn = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[53] })) + String.valueOf(bytesToHex(new byte[] { bytes[54] })), 16);
			String irotUn = String.valueOf(rotUn);
			if (rotUn == 65535) {
				irotUn = rotUn + " : " + "ROT_UNCERTAIN_UNDEF";
			}
			stb.append(irotUn);
			stb.append("\n");

			stb.append("Size of image data                         ");
			stb.append("56 - 59                                 ");
			stb.append(bytesToHex(new byte[] { bytes[55] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[56] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[57] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[58] }));
			stb.append("                           ");
			stb.append(Integer.parseInt(
					String.valueOf(bytesToHex(new byte[] { bytes[55] })) + String.valueOf(bytesToHex(new byte[] { bytes[56] })) + String.valueOf(bytesToHex(new byte[] { bytes[57] }))
							+ String.valueOf(bytesToHex(new byte[] { bytes[58] })), 16)
					+ " bytes");
			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;

		} else {
			printMessage(textPane, "red", 12, "Image is less than 45 bytes", false);
		}

		textPane.setCaretPosition(0);
	}

	public static void getIsoChecked1(JTextPane textPane, byte[] bytes, StringBuffer consoleLogBuffer, boolean deviceCheck) {

		printMessage(textPane, "gray", 12, "Check ISO 19794-4 Finger Image Record Details below in Decimal values.", consoleLogBuffer, deviceCheck);
		printMessage(textPane, "gray", 12, "General Record Header (32 Bytes).", consoleLogBuffer, deviceCheck);

		StringBuffer stb1 = new StringBuffer();
		stb1.append("Format Identifier (4 bytes): ");
		stb1.append((int) byte2uint(bytes[0]) + " ");
		stb1.append((int) byte2uint(bytes[1]) + " ");
		stb1.append((int) byte2uint(bytes[2]) + " ");
		stb1.append((int) byte2uint(bytes[3]) + "\n");

		stb1.append("Version Number (4 bytes): ");
		stb1.append((int) byte2uint(bytes[4]) + " ");
		stb1.append((int) byte2uint(bytes[5]) + " ");
		stb1.append((int) byte2uint(bytes[6]) + " ");
		stb1.append((int) byte2uint(bytes[7]) + "\n");

		stb1.append("Record Length (6 bytes): ");
		stb1.append((int) byte2uint(bytes[8]) + " ");
		stb1.append((int) byte2uint(bytes[9]) + " ");
		stb1.append((int) byte2uint(bytes[10]) + " ");
		stb1.append((int) byte2uint(bytes[11]) + " ");
		stb1.append((int) byte2uint(bytes[12]) + " ");
		stb1.append((int) byte2uint(bytes[13]) + "\n");

		stb1.append("Device ID (2 bytes): ");
		stb1.append((int) byte2uint(bytes[14]) + " ");
		stb1.append((int) byte2uint(bytes[15]) + "\n");

		stb1.append("Image Acquisition Level (2 bytes): ");
		stb1.append((int) byte2uint(bytes[16]) + " ");
		stb1.append((int) byte2uint(bytes[17]) + "\n");

		stb1.append("Number of Fingers (1 byte): ");
		stb1.append((int) byte2uint(bytes[18]) + "\n");

		stb1.append("Scale Units (1 byte): ");
		stb1.append((int) byte2uint(bytes[19]) + "\n");

		stb1.append("Scan Resolution (Horiz & Vert) (4 bytes): ");
		stb1.append((int) byte2uint(bytes[20]) + " ");
		stb1.append((int) byte2uint(bytes[21]) + " ");
		stb1.append((int) byte2uint(bytes[22]) + " ");
		stb1.append((int) byte2uint(bytes[23]) + "\n");

		stb1.append("Image Resolution (Horiz & Vert) (4 bytes): ");
		stb1.append((int) byte2uint(bytes[24]) + " ");
		stb1.append((int) byte2uint(bytes[25]) + " ");
		stb1.append((int) byte2uint(bytes[26]) + " ");
		stb1.append((int) byte2uint(bytes[27]) + "\n");

		stb1.append("Pixel Depth (1 byte): ");
		stb1.append((int) byte2uint(bytes[28]) + "\n");

		stb1.append("Image Compression Algorithm (1 byte): ");
		stb1.append((int) byte2uint(bytes[29]) + "\n");

		stb1.append("Reserved (2 bytes): ");
		stb1.append((int) byte2uint(bytes[30]) + " ");
		stb1.append((int) byte2uint(bytes[31]));

		printMessage(textPane, "green", 10, stb1.toString(), consoleLogBuffer, deviceCheck);
		stb1 = null;

		StringBuffer stb2 = new StringBuffer();
		printMessage(textPane, "gray", 12, "Finger Image Record Header (14 Bytes).", consoleLogBuffer, deviceCheck);

		stb2.append("Length of Finger Data Block (4 bytes): ");
		stb2.append((int) byte2uint(bytes[32]) + " ");
		stb2.append((int) byte2uint(bytes[33]) + " ");
		stb2.append((int) byte2uint(bytes[34]) + " ");
		stb2.append((int) byte2uint(bytes[35]) + "\n");

		stb2.append("Finger Position (1 byte): ");
		stb2.append((int) byte2uint(bytes[36]) + "\n");

		stb2.append("Count of Views (1 byte): ");
		stb2.append((int) byte2uint(bytes[37]) + "\n");

		stb2.append("View Number (1 byte): ");
		stb2.append((int) byte2uint(bytes[38]) + "\n");

		stb2.append("Finger Image Quality (1 byte): ");
		stb2.append((int) byte2uint(bytes[39]) + "\n");

		stb2.append("Impression Type (1 byte): ");
		stb2.append((int) byte2uint(bytes[40]) + "\n");

		stb2.append("Horizontal Line Length (2 bytes): ");
		stb2.append((int) byte2uint(bytes[41]) + " ");
		stb2.append((int) byte2uint(bytes[42]) + "\n");

		stb2.append("Vertical Line Length (2 bytes): ");
		stb2.append((int) byte2uint(bytes[43]) + " ");
		stb2.append((int) byte2uint(bytes[44]) + "\n");

		stb2.append("Reserved (1 byte): ");
		stb2.append((int) byte2uint(bytes[45]));

		printMessage(textPane, "green", 10, stb2.toString(), consoleLogBuffer, deviceCheck);
		stb2 = null;
	}

	public static void printMessage(JTextPane pane, String colorName, int fontSize, String text, StringBuffer consoleLogBuffer, boolean deviceCheck) {

		try {

			if (pane == null) {
				if (consoleLogBuffer != null) {
					// consoleLogBuffer.append(DeviceLogger.NEW_LINE).append(DeviceLogger.getTimeStamp());
					// consoleLogBuffer.append(DeviceLogger.SPACE).append(text);
				}
			} else {
				if (consoleLogBuffer != null) {
					// consoleLogBuffer.append(DeviceLogger.NEW_LINE).append(DeviceLogger.getTimeStamp());
					// consoleLogBuffer.append(DeviceLogger.SPACE).append(text);
				}

				if (!deviceCheck) {
					Element root = pane.getDocument().getDefaultRootElement();
					while (root.getElementCount() > 101) {
						Element firstLine = root.getElement(0);
						try {
							pane.getDocument().remove(0, firstLine.getEndOffset());
						} catch (BadLocationException ble) {
							System.out.println(ble);
						}
					}
				}

				StyledDocument doc = (StyledDocument) pane.getDocument();
				Style style = doc.addStyle("StyleName", null);
				StyleConstants.setFontSize(style, fontSize);
				// StyleConstants.setBold(style, true);
				if (colorName.equalsIgnoreCase("GREEN")) {
					StyleConstants.setForeground(style, new java.awt.Color(0, 100, 0));
				} else if (colorName.equalsIgnoreCase("red")) {
					StyleConstants.setForeground(style, Color.RED);
				} else if (colorName.equalsIgnoreCase("gray")) {
					StyleConstants.setForeground(style, Color.DARK_GRAY);
				} else {
					StyleConstants.setForeground(style, Color.BLACK);
				}
				doc.insertString(doc.getLength(), "\n" + text, style);
				pane.setCaretPosition(pane.getDocument().getLength());
			}
		} catch (Exception x) {
		}
	}

	public static void printMessageGeneral(JTextPane pane, String text, StringBuffer consoleLogBuffer, boolean deviceCheck) {
		printMessage(pane, "black", 12, text, consoleLogBuffer, deviceCheck);
	}

	public static void printMessageSuccess(JTextPane pane, String text, StringBuffer consoleLogBuffer, boolean deviceCheck) {
		printMessage(pane, "green", 12, text, consoleLogBuffer, deviceCheck);
	}

	public static void printMessageErrorFatal(JTextPane pane, String text, StringBuffer consoleLogBuffer, boolean deviceCheck) {
		printMessage(pane, "red", 18, "FATAL: " + text, consoleLogBuffer, deviceCheck);
	}

	public static void printMessageError(JTextPane pane, String text, StringBuffer consoleLogBuffer, boolean deviceCheck) {
		printMessage(pane, "red", 12, text, consoleLogBuffer, deviceCheck);
	}

	/**
	 * Equivalent to calling <code>bytesToHex(b, 0, b.length)</code>.
	 */
	private static String bytesToHex(byte[] b) {
		return bytesToHex(b, 0, b.length);
	}

	/**
	 * Converts a single byte to a hex string representation, can be decoded
	 * with Byte.parseByte().
	 * 
	 * @param b
	 *            the byte to encode
	 * @return a
	 */
	private static String bytesToHex(byte[] b, int index, int length) {
		StringBuffer buf = new StringBuffer();
		byte leading, trailing;
		for (int pos = index; pos >= 0 && pos < index + length && pos < b.length; ++pos) {
			leading = (byte) ((b[pos] >>> 4) & 0x0f);
			trailing = (byte) (b[pos] & 0x0f);
			buf.append((0 <= leading) && (leading <= 9) ? (char) ('0' + leading) : (char) ('A' + (leading - 10)));
			buf.append((0 <= trailing) && (trailing <= 9) ? (char) ('0' + trailing) : (char) ('A' + (trailing - 10)));
		}
		return buf.toString();
	}

	private static int byte2uint(byte b) {
		return (int) (b & 0xFF);
	}

	private static void printMessage(JTextPane pane, String colorName, int fontSize, String text, boolean bold) {
		try {
			StyledDocument doc = (StyledDocument) pane.getDocument();
			Style style = doc.addStyle("StyleName", null);
			StyleConstants.setFontSize(style, fontSize);
			StyleConstants.setBold(style, bold);
			if (colorName.equalsIgnoreCase("GREEN")) {
				StyleConstants.setForeground(style, new java.awt.Color(0, 100, 0));
			} else if (colorName.equalsIgnoreCase("red")) {
				StyleConstants.setForeground(style, Color.RED);
			} else if (colorName.equalsIgnoreCase("gray")) {
				StyleConstants.setForeground(style, Color.DARK_GRAY);
			} else {
				StyleConstants.setForeground(style, Color.BLACK);
			}
			doc.insertString(doc.getLength(), text, style);
			pane.setCaretPosition(pane.getDocument().getLength());
		} catch (Exception x) {
		}
	}

	public static void playBeep3() {
		clip = null;
		try {
			String fileName = "resources/camera1.wav";
			AudioInputStream soundStream = null;
			File audioFile = new File(fileName);
			soundStream = AudioSystem.getAudioInputStream(audioFile);
			AudioFormat streamFormat = soundStream.getFormat();
			DataLine.Info clipInfo = new DataLine.Info(Clip.class, streamFormat);
			clip = (Clip) AudioSystem.getLine(clipInfo);
			clip.open(soundStream);
			clip.setLoopPoints(0, -1);
			clip.start();
		} catch (UnsupportedAudioFileException e) {
			System.out.println(e.getMessage());
		} catch (IOException e) {
			System.out.println(e.getMessage());
		} catch (LineUnavailableException e) {
			System.out.println(e.getMessage());
		}
	}

	public static void closeClip() {
		if (clip.isOpen()) {
			clip.stop();
			clip.flush();
			clip.close();
		}
	}

	public static void playBeep(String fileName) {
		try {
			AudioInputStream soundStream = null;
			File audioFile = new File(fileName);
			soundStream = AudioSystem.getAudioInputStream(audioFile);
			AudioFormat streamFormat = soundStream.getFormat();
			DataLine.Info clipInfo = new DataLine.Info(Clip.class, streamFormat);
			Clip clip = (Clip) AudioSystem.getLine(clipInfo);
			clip.open(soundStream);
			clip.setLoopPoints(0, -1);
			clip.start();
		} catch (UnsupportedAudioFileException e) {
			System.out.println(e.getMessage());
		} catch (IOException e) {
			System.out.println(e.getMessage());
		} catch (LineUnavailableException e) {
			System.out.println(e.getMessage());
		}
	}

	public static int getMinutiaeCount(byte[] image) {
		int minutiaeCount = 0;
		if (image.length > 34) {
			minutiaeCount = Integer.parseInt(bytesToHex(new byte[] { image[27] }), 16);
		}
		return minutiaeCount;
	}

	public static BufferedImage displayIrisImage(byte[] rawImage, int width, int height) {
		BufferedImage image = null;
		try {
			ByteArrayInputStream bin = new ByteArrayInputStream(rawImage);
			ImageInputStream imIs = ImageIO.createImageInputStream(bin);
			int[] bandOffets = { 0 };
			ComponentSampleModel imgSampleModel = new ComponentSampleModel(DataBuffer.TYPE_BYTE, width, height, 1, width, bandOffets);
			Dimension[] imageDimensions = { new Dimension(width, height) };
			long[] ofs = { 0L };
			RawImageInputStream ris = new RawImageInputStream(imIs, imgSampleModel, ofs, imageDimensions);
			image = ImageIO.read(ris);

			// ImageIO.write(image, "JPG", new File("C:/final_iris" + "." +
			// "JPG"));
		} catch (IOException e) {
			System.out.println("Error: " + e.getMessage());
		}

		return image;
	}

	public static void writeImage(byte[] fileData, String fileName, String type) {
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(new File(fileName + type));
		} catch (FileNotFoundException e) {
			System.out.println("ERROR : in.gov.uidai.auth.util.AppUtil.writeImage() : " + e.getMessage());
		}
		if (fileData != null) {
			try {
				fos.write(fileData);
				fos.close();
			} catch (IOException e) {
				System.out.println("ERROR : in.gov.uidai.auth.util.AppUtil.writeImage() : " + e.getMessage());
			}
		}
	}

	public static String formatDecimal(double value, String format) {
		DecimalFormat formatter = new DecimalFormat(format);
		return formatter.format(value);
	}

	public static byte[] toCompressedJPEG2000(ImageWriter writer, int height, int width, byte[] pixels, int compressionRatio, boolean lossless) {
		BufferedImage image = toImage(height, width, pixels);

		// http://www.java.net/node/702095
		J2KImageWriteParam jwp = (J2KImageWriteParam) writer.getDefaultWriteParam();
		jwp.setLossless(lossless);
		// jwp.setFilter(J2KImageWriteParam.FILTER_97);
		if (!lossless) {
			jwp.setEncodingRate(8.0 / compressionRatio);
		}

		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		try {
			ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
			writer.setOutput(ios);
			writer.write(null, new IIOImage(image, null, null), jwp);
			ios.flush();
			ios.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

		byte[] jp2 = baos.toByteArray();
		// System.out.println(jp2.length);
		return jp2;
	}

	public static byte[] toIIR_2005(byte biometricSubtype, int height, int width, short imageFormat, byte[] data) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream wr = new DataOutputStream(baos);

		int ImageLength = data.length;
		int RecordLength = ImageLength + 45 + 3 + 11;

		try {
			// IirRecordHeader
			wr.writeBytes("IIR\0");
			wr.writeBytes("111\0");
			wr.writeInt(RecordLength);
			wr.writeShort(0);// CaptureDeviceId
			wr.writeByte(1);// NumEyes
			wr.writeShort(45);// RecordHeaderLength
			wr.writeShort(0);// IrisProperties
			wr.writeShort(0);// IrisDiameter
			wr.writeShort(imageFormat);// ImageFormat
			wr.writeShort(width);
			wr.writeShort(height);
			wr.writeByte(8);// IntensityDepth
			wr.writeByte(0);// ImageTranform
			wr.write(new byte[16]);// UniqueDeviceID// should be 16
			// IirSubtypeHeader
			wr.writeByte(biometricSubtype);// Subtype//EYE_UNDEF
			wr.writeShort(1);// NumberOfImages
			// IirImageHeader
			wr.writeShort(1);// ImageNumber
			wr.writeByte(0);// Quality
			wr.writeShort(-1);// Rotation
			wr.writeShort(-1);// RotationUncertainty
			wr.writeInt(ImageLength);
			// Image Data

			wr.write(data);
			wr.flush();
			wr.close();
		} catch (IOException e) {
			e.printStackTrace();
		}

		byte[] iir = baos.toByteArray();
		// System.out.println(Thread.currentThread().getName() + " " +
		// DatatypeConverter.printHexBinary(iir));
		return iir;
	}

	public static byte[] toUncompressedIIR_2005(byte biometricSubtype, int height, int width, byte[] pixels) {
		short IMAGEFORMAT_MONO_RAW = 2;
		return toIIR_2005(biometricSubtype, height, width, IMAGEFORMAT_MONO_RAW, pixels);
	}

	public static byte[] toCompressedIIR_2005(byte biometricSubtype, int height, int width, byte[] jp2Image) {
		short IMAGEFORMAT_MONO_JPEG2000 = 14;
		return toIIR_2005(biometricSubtype, height, width, IMAGEFORMAT_MONO_JPEG2000, jp2Image);
	}

	public static BufferedImage toImage(int height, int width, byte[] pixels) {
		final ColorModel grayColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
		DataBuffer dataBuffer = new DataBufferByte(pixels, pixels.length);
		SampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_BYTE, width, height, 1, width, new int[] { 0 });
		// Create a raster using the sample model and data buffer
		WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer, null);
		// Combine the color model and raster into a buffered image
		return new BufferedImage(grayColorModel, raster, false, null);
	}

	public static void getIsoIIR2011Checked(JTextPane textPane, File file, String fileName) throws FileNotFoundException, IOException {
		String color = "black";
		FileInputStream fis = new FileInputStream(file);
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		byte[] buf = new byte[1024];
		try {
			for (int readNum; (readNum = fis.read(buf)) != -1;) {
				bos.write(buf, 0, readNum);
			}
		} catch (IOException ex) {
			ex.printStackTrace();
		}
		byte[] bytes = bos.toByteArray();

		if (bytes.length > 59) {

			StringBuffer stb = new StringBuffer();
			stb.append("File: " + fileName + "\n");
			printMessage(textPane, color, 18, stb.toString(), true);
			stb = null;

			stb = new StringBuffer();
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;

			stb = new StringBuffer();
			stb.append("\n");
			stb.append("Field                                               ");
			stb.append("Byte                                ");
			stb.append("Value (Hexa Decimal)              ");
			stb.append("Remarks");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), true);
			stb = null;

			stb = new StringBuffer();
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;

			stb = new StringBuffer();
			stb.append("Format identifier                              ");
			stb.append(" 1 - 4                                  ");

			StringBuffer str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[0] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[1] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[2] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[3] }));

			stb.append(str.toString());
			String fiRemarks = "IIR (Iris Image Record)";
			if (!str.toString().trim().equalsIgnoreCase("49 49 52 00")) {
				color = "red";
				fiRemarks = "Not IIR (Iris Image Record)";
			}
			stb.append("                           ");
			stb.append(fiRemarks);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			stb = new StringBuffer();
			stb.append("Version number                               ");
			stb.append(" 5 - 8                                  ");
			StringBuffer strV = new StringBuffer();
			strV.append(bytesToHex(new byte[] { bytes[4] }));
			strV.append(" ");
			strV.append(bytesToHex(new byte[] { bytes[5] }));
			strV.append(" ");
			strV.append(bytesToHex(new byte[] { bytes[6] }));
			strV.append(" ");
			strV.append(bytesToHex(new byte[] { bytes[7] }));
			stb.append(strV.toString());
			String vRemarks = "";
			String lastByte = bytesToHex(new byte[] { bytes[7] });
			if (!lastByte.trim().equalsIgnoreCase("00")) {
				vRemarks = "Should be three numerals followed by o byte";
				color = "red";
			}
			stb.append("                          ");
			stb.append(vRemarks);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			stb = new StringBuffer();
			stb.append("Record length                                 ");
			stb.append(" 9 - 12                                 ");
			stb.append(bytesToHex(new byte[] { bytes[8] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[9] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[10] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[11] }));
			stb.append("                           ");
			stb.append(Integer.parseInt(
					String.valueOf(bytesToHex(new byte[] { bytes[8] })) + String.valueOf(bytesToHex(new byte[] { bytes[9] })) + String.valueOf(bytesToHex(new byte[] { bytes[10] }))
							+ String.valueOf(bytesToHex(new byte[] { bytes[11] })), 16)
					+ " bytes");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			stb = new StringBuffer();
			stb.append("No. of Iris                                      ");
			stb.append(" 13 - 14                                  ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[12] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[13] }));
			str.append(" ");

			stb.append(str.toString());
			int iris = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[12] })) + String.valueOf(bytesToHex(new byte[] { bytes[13] })), 16);
			String noIrisRemarks = iris + ":IIR Captured";
			if (str.toString().trim().equalsIgnoreCase("00 00")) {
				color = "red";
				noIrisRemarks = "No IIRs Captured";
			}
			stb.append("                           ");
			stb.append(noIrisRemarks);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			stb = new StringBuffer();
			stb.append("Certification Flag                              ");
			stb.append("    15                                    ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[14] }));
			str.append(" ");

			stb.append(str.toString());
			String cerRemarks = "No certification schemes are available for this part of ISO/IEC 19794";
			stb.append("                           ");
			stb.append(cerRemarks);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			stb = new StringBuffer();
			stb.append("No. of Eyes Represented                     ");
			stb.append(" 16                                   ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[15] }));
			str.append(" ");
			stb.append(str.toString());
			String noEyesRemarks = "Wrong implementation";
			int noOfEyes = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[15] })), 16);
			switch (noOfEyes) {
			case 0:
				noEyesRemarks = "The laterality of the eye image(s) is unknown";
				break;
			case 1:
				noEyesRemarks = "Left or right eye is known to be present";
				break;
			case 2:
				noEyesRemarks = "Left and right eyes are known to be present";
				break;

			}
			stb.append("                           ");
			if (noEyesRemarks.equalsIgnoreCase("Wrong implementation")) {
				color = "red";
			}
			stb.append(noEyesRemarks);
			stb.append("\n");
			color = "black";

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			// general header completes here
			// Representation Length 4 bytes
			stb = new StringBuffer();
			stb.append("Representation Length                    ");
			stb.append("17 - 20                                 ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[16] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[17] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[18] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[19] }));

			stb.append(str.toString());

			double end = (Math.pow(2, 32) - 1) - 16;
			int RL = Integer.parseInt(
					String.valueOf(bytesToHex(new byte[] { bytes[16] })) + String.valueOf(bytesToHex(new byte[] { bytes[17] })) + String.valueOf(bytesToHex(new byte[] { bytes[18] }))
							+ String.valueOf(bytesToHex(new byte[] { bytes[19] })), 16);
			String rlRemarks = "";
			if (RL >= 53 && RL <= end) {
				rlRemarks = "Length In correct range";
			} else {
				color = "red";
				rlRemarks = "Length not in correct range";
			}

			stb.append("                       ");
			stb.append(rlRemarks);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			// capture date and time 9 bytes
			stb = new StringBuffer();
			stb.append("Capture Date                                 ");
			stb.append(" 21 - 29                                ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[20] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[21] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[22] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[23] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[24] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[25] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[26] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[27] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[28] }));
			str.append(" ");
			stb.append(str.toString());
			String dd = "";
			/*
			 * DateFormat formatter = new
			 * SimpleDateFormat("yyyy.MM.dd.HH.mm.ss"); dd=formatter.format(new
			 * Date(Integer.parseInt( String.valueOf(bytesToHex(new byte[] {
			 * bytes[20] }))+ String.valueOf(bytesToHex(new byte[] { bytes[21]
			 * }))+ String.valueOf(bytesToHex(new byte[] { bytes[22] }))+
			 * String.valueOf(bytesToHex(new byte[] { bytes[23] }))+
			 * String.valueOf(bytesToHex(new byte[] { bytes[24] }))+
			 * String.valueOf(bytesToHex(new byte[] { bytes[25] }))+
			 * String.valueOf(bytesToHex(new byte[] { bytes[26] }))+
			 * String.valueOf(bytesToHex(new byte[] { bytes[27] }))+
			 * String.valueOf(bytesToHex(new byte[] { bytes[28] })),16)));
			 */
			stb.append("                     ");
			stb.append(dd);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			// Device technology Identity
			stb = new StringBuffer();
			stb.append("Device Tech ID                                ");
			stb.append("    30                                  ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[29] }));
			str.append(" ");

			stb.append(str.toString());

			String dtID = "";
			if (str.toString().trim().equalsIgnoreCase("00")) {
				color = "red";
				dtID = "Unknown or Unspecified ";
			} else if (str.toString().trim().equalsIgnoreCase("01"))
				dtID = "CMOS/CCD ";
			stb.append("                               ");
			stb.append(dtID);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			// device vendor ID 2 bytes
			stb = new StringBuffer();
			stb.append("Device Vendor ID                          ");
			stb.append(" 31 - 32                                 ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[30] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[31] }));
			str.append(" ");

			stb.append(str.toString());
			String vendor = "";
			if (str.toString().trim().equalsIgnoreCase("00 00")) {
				color = "red";
				vendor = "Unsupport";
			} else {
				vendor = "Registered Value (IBIA or otherwise)";
			}
			stb.append("                           ");
			stb.append(vendor);
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			stb = new StringBuffer();
			stb.append("Device Type ID                             ");
			stb.append(" 33 - 34                                 ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[32] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[33] }));
			str.append(" ");

			stb.append(str.toString());
			String type = "";
			if (str.toString().trim().equalsIgnoreCase("00 00")) {
				color = "red";
				type = "Unsupport";
			} else {
				type = "Registered Value (IBIA or otherwise)";
			}
			stb.append("                           ");
			stb.append(type);
			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";
			// Quality block 1 to n bytes first bytes gives the number of
			// qualityblock
			// quality block=quality score(1 byte)+algoritham(2
			// byte)+algoritham(2 byte).

			int noQuality = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[34] })), 16) * 5;
			int next = 36 + noQuality;
			stb = new StringBuffer();
			stb.append("No of  Quality Block                     ");
			stb.append("   35 -" + (noQuality + 35) + "                         ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[34] }));
			str.append(" ");

			stb.append(str.toString());
			stb.append("                           ");
			stb.append("\n");

			stb.append("Sequence Number                         ");
			stb.append(next + " - " + (next + 1) + "                       ");
			stb.append(bytesToHex(new byte[] { bytes[next] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[next + 1] }));
			stb.append("                                ");
			stb.append("Representation Sequence Number");
			stb.append("\n");

			// Eye label 1 byte

			stb.append("Eye Label                                      ");
			stb.append(next + 2 + "                                  ");
			stb.append(bytesToHex(new byte[] { bytes[next + 2] }));
			stb.append(" ");
			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 2] }));
			stb.append("                                      ");
			if (str.toString().trim().equalsIgnoreCase("00"))
				stb.append("Label Undefined ");
			else if (str.toString().trim().equalsIgnoreCase("01"))
				stb.append("Label is RIGHT");
			else if (str.toString().trim().equalsIgnoreCase("02"))
				stb.append("Label is LEFT");

			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			// Image type one byte
			stb = new StringBuffer();
			stb.append("Image Type                                  ");
			stb.append(next + 3 + "                                 ");
			stb.append(bytesToHex(new byte[] { bytes[next + 3] }));
			stb.append(" ");
			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 3] }));
			stb.append("                                   ");
			if (str.toString().trim().equalsIgnoreCase("01"))
				stb.append("IMAGE_TYPE_UNCROPPED ");
			else if (str.toString().trim().equalsIgnoreCase("02"))
				stb.append("IMAGE_TYPE_VGA - (640x480) format");
			else if (str.toString().trim().equalsIgnoreCase("03"))
				stb.append("IMAGE_TYPE_CROPPED ,Kind3 Image ");
			else if (str.toString().trim().equalsIgnoreCase("07"))
				stb.append("IMAGE_TYPE_CROPPED_AND_MASKED ,Kind7 image");
			else {
				stb.append("Type Unknown");
				color = "red";
			}
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			// Image format one byte
			stb = new StringBuffer();
			stb.append("Image Format                                ");
			stb.append(next + 4 + "                                ");
			stb.append(bytesToHex(new byte[] { bytes[next + 4] }));
			stb.append(" ");
			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 4] }));
			if (str.toString().trim().equalsIgnoreCase("02"))
				stb.append("IMAGEFORMAT_MONO_RAW ");
			else if (str.toString().trim().equalsIgnoreCase("0A"))
				stb.append("IMAGEFORMAT_MONO_JPEG2000 ");
			else if (str.toString().trim().equalsIgnoreCase("0E"))
				stb.append("IMAGEFORMAT_MONO_PNG ");
			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");
			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;
			str = null;
			color = "black";

			// iris image properties 1 byte
			stb = new StringBuffer();
			stb.append("Iris image properties bitfield            ");
			stb.append(next + 5 + "                         ");
			stb.append(bytesToHex(new byte[] { bytes[next + 5] }));
			stb.append(" ");
			int propBit = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 5] })), 16);
			String binary = Integer.toBinaryString(propBit);
			int len = binary.length();
			if (len < 8) {
				for (int i = 0; i < 8 - len; i++) {
					binary = 0 + binary;
				}
			}
			stb.append(propBit + " : " + binary);
			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(6, 8))) {
				stb.append("                                                                                                                                           ");
				stb.append("Horizontal orientation : ORIENTATION_UNDEF");
			} else if ("01".equalsIgnoreCase(binary.substring(6, 8))) {
				stb.append("                                                                                                                                           ");
				stb.append("Horizontal orientation : ORIENTATION_BASE");
			} else if ("10".equalsIgnoreCase(binary.substring(6, 8))) {
				stb.append("                                                                                                                                           ");
				stb.append("Horizontal orientation : ORIENTATION_FLIPPED");
			}

			stb.append("\n");
			if ("00".equalsIgnoreCase(binary.substring(4, 6))) {
				stb.append("                                                                                                                                           ");
				stb.append("Vertical orientation : ORIENTATION_UNDEF");
			} else if ("01".equalsIgnoreCase(binary.substring(12, 14))) {
				stb.append("                                                                                                                                           ");
				stb.append("Vertical orientation : ORIENTATION_BASE");
			} else if ("10".equalsIgnoreCase(binary.substring(12, 14))) {
				stb.append("                                                                                                                                           ");
				stb.append("Vertical orientation : ORIENTATION_FLIPPED");
			}
			stb.append("\n");

			if ("00".equalsIgnoreCase(binary.substring(0, 2))) {
				stb.append("                                                                                                                                           ");
				stb.append("Previous Compression : PREVIOUS_COMPRESSION_UNDEF");
			} else if ("01".equalsIgnoreCase(binary.substring(8, 10))) {
				stb.append("                                                                                                                                           ");
				stb.append("Previous Compression : PREVIOUS_COMPRESSION_LOSSLESS_OR_NONE ");
			} else if ("10".equalsIgnoreCase("binary.substring(8, 10)"))
				stb.append("Previous Compression :PREVIOUS_COMPRESSION_LOSSY  ");

			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");

			// width 2 bytes
			stb.append("Image Width                              ");
			stb.append((next + 6) + "-" + (next + 7) + "                           ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 6] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 7] }));
			str.append(" ");

			stb.append(str.toString());
			int width = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 6] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 7] })), 16);
			stb.append("                           ");
			stb.append(width);
			stb.append("\n");

			// width 2 bytes
			stb.append("Image Height                            ");
			stb.append((next + 8) + "-" + (next + 9) + "                           ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 8] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 9] }));
			str.append(" ");

			stb.append(str.toString());
			int height = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 8] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 9] })), 16);
			stb.append("                           ");
			stb.append(height);
			stb.append("\n");

			stb.append("Image Depth                              ");
			stb.append("   " + (next + 10) + "                                  ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 10] }));
			str.append(" ");

			stb.append(str.toString());
			int depth = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 10] })));
			String depthS = new Integer(depth).toString();
			if (depth < 8)
				depthS = depth + "  Depth should be greater than or equal to 8";
			stb.append("                           ");
			stb.append(depthS);
			stb.append("\n");

			stb.append("Range                                  ");
			stb.append("  " + (next + 11) + "-" + (next + 12) + "                                  ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 11] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 12] }));
			str.append(" ");
			stb.append(str.toString());
			int range = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 11] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 12] })), 16);
			String rRemarks = new Integer(range).toString();

			if (range == 0)
				rRemarks = range + ":RANGE_UNASSIGNED ";
			else if (range == 1)
				rRemarks = range + ":RANGE_FAILED ";
			else if (range == Math.pow(2, 16) - 1)
				rRemarks = range + ":RANGE_OVERFLOW ";
			stb.append("                     ");
			stb.append(rRemarks);
			stb.append("\n");
			stb.append("                                                                                ");
			stb.append("Distance between the optical centre of the camera lens and the subject iris in mm");
			stb.append("\n");
			stb.append("\n");

			stb.append("Roll Angle Of Eye                     ");
			stb.append((next + 13) + "-" + (next + 14) + "                    ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 13] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 14] }));
			str.append(" ");

			stb.append(str.toString());
			int roll = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 13] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 14] })), 16);
			String rollS = String.valueOf(roll);
			if (roll == 65535) {
				rollS = roll + " : " + "ROLL_ANGLE_UNDEF ";
			}
			stb.append("                           ");
			stb.append(rollS);
			stb.append("\n");

			stb.append("Roll Angle Of Uncertinity            ");
			stb.append((next + 15) + "-" + (next + 16) + "                    ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 15] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 16] }));
			str.append(" ");

			stb.append(str.toString());
			int uncert = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 15] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 16] })), 16);
			String uncertS = String.valueOf(uncert);
			if (uncert == 65535) {
				uncertS = uncert + " : " + "ROLL_UNCERTAIN_UNDEF ";
			}
			stb.append("                           ");
			stb.append(uncertS);
			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");

			stb.append("Smallest X Cordinate                       ");
			stb.append((next + 17) + "-" + (next + 18) + "                               ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 17] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 18] }));
			str.append(" ");

			stb.append(str.toString());
			int centerX = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 17] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 18] })), 16);
			String centerXs = String.valueOf(centerX);
			if (centerX == 0) {
				centerXs = centerX + " : " + "COORDINATE_UNDEF ";
			}
			stb.append("                           ");
			stb.append(centerXs);
			stb.append("\n");
			stb.append("                                                                                                    ");
			stb.append("Smallest expected iris centre X coordinate in pixels, measured from the left side of the image");
			stb.append("\n");
			stb.append("\n");

			stb.append("Largest X Cordinate                       ");
			stb.append((next + 19) + "-" + (next + 20) + "                               ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 19] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 20] }));
			str.append(" ");

			stb.append(str.toString());
			int lX = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 19] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 20] })), 16);
			String lXs = String.valueOf(lX);
			if (lX == 0) {
				lXs = lX + " : " + "COORDINATE_UNDEF ";
			}
			stb.append("                           ");
			stb.append(lXs);
			stb.append("\n");
			stb.append("                                                                                                  ");
			stb.append("Largest expected iris centre X coordinate in pixels, measured from the left side of the image");
			stb.append("\n");
			stb.append("\n");

			stb.append("Smallest Y Cordinate                       ");
			stb.append((next + 21) + "-" + (next + 22) + "                               ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 21] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 22] }));
			str.append(" ");

			stb.append(str.toString());
			int smallY = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 21] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 22] })), 16);
			String smallYs = String.valueOf(smallY);
			if (smallY == 0) {
				smallYs = smallY + " : " + "COORDINATE_UNDEF ";
			}
			stb.append("                           ");
			stb.append(smallYs);
			stb.append("\n");
			stb.append("                                                                                                  ");
			stb.append("Smallest expected iris centre Y coordinate in pixels, measured from the top of the image ");
			stb.append("\n");
			stb.append("\n");

			stb.append("Largest Y Cordinate                       ");
			stb.append((next + 23) + "-" + (next + 24) + "                               ");

			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 23] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 24] }));
			str.append(" ");

			stb.append(str.toString());
			int largeY = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 23] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 24] })), 16);
			String largeYs = String.valueOf(largeY);
			if (largeY == 0) {
				largeYs = largeY + " : " + "COORDINATE_UNDEF ";
			}
			stb.append("                           ");
			stb.append(largeYs);
			stb.append("\n");
			stb.append("                                                                                                  ");
			stb.append("Largest expected iris centre Y coordinate in pixels, measured from the top of the image  ");
			stb.append("\n");
			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");

			stb.append("Smallest expected iris diameter in pixels       ");
			stb.append((next + 25) + "-" + (next + 26) + "                      ");
			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 25] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 26] }));
			str.append(" ");
			stb.append(str.toString());
			int diameter = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 25] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 26] })), 16);
			String diameterS = String.valueOf(diameter);
			if (diameter == 0) {
				diameterS = diameter + " : " + "COORDINATE_UNDEF ";
			}

			stb.append("                           ");
			stb.append(diameterS);
			stb.append("\n");

			stb.append("Largest expected iris diameter in pixels         ");
			stb.append((next + 27) + "-" + (next + 28) + "                      ");
			str = new StringBuffer();
			str.append(bytesToHex(new byte[] { bytes[next + 27] }));
			str.append(" ");
			str.append(bytesToHex(new byte[] { bytes[next + 28] }));
			str.append(" ");
			stb.append(str.toString());
			int diameterL = Integer.parseInt(String.valueOf(bytesToHex(new byte[] { bytes[next + 27] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 28] })), 16);
			String diadiameterLS = String.valueOf(diameterL);
			if (diameterL == 0) {
				diadiameterLS = diameterL + " : " + "COORDINATE_UNDEF ";
			}

			stb.append("                           ");
			stb.append(diadiameterLS);
			stb.append("\n");

			// Image length 4 bytes

			stb.append("Size of the image data                              ");
			stb.append((next + 29) + "-" + (next + 32) + "                 ");
			stb.append(bytesToHex(new byte[] { bytes[next + 29] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[next + 30] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[next + 31] }));
			stb.append(" ");
			stb.append(bytesToHex(new byte[] { bytes[next + 32] }));
			stb.append(" ");

			stb.append("                                     ");
			stb.append(Integer.parseInt(
					String.valueOf(bytesToHex(new byte[] { bytes[next + 29] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 30] }))
							+ String.valueOf(bytesToHex(new byte[] { bytes[next + 31] })) + String.valueOf(bytesToHex(new byte[] { bytes[next + 32] })), 16));
			stb.append("\n");

			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("------------------------------------------------------------------------------------------------------");
			stb.append("\n");

			printMessage(textPane, color, 12, stb.toString(), false);
			stb = null;

		} else {
			printMessage(textPane, "red", 12, "Image is less than 45 bytes", false);
		}

		textPane.setCaretPosition(0);
	}
}
