/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter Unisharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

package com.pullenti.unitext.internal.misc;

public class TiffHelper {

    public static com.pullenti.unitext.UnitextDocument createDoc(byte[] content) throws Exception {
        com.pullenti.unitext.UnitextDocument res = com.pullenti.unitext.UnitextDocument._new47(com.pullenti.unitext.FileFormat.TIF);
        try (com.pullenti.unisharp.MemoryStream mem = new com.pullenti.unisharp.MemoryStream(content)) {
            try {
                Tiff ti = new Tiff(mem);
                int wi;
                int hei;
                int dpx;
                int dpy;
                boolean m;
                boolean hasTxt;
                if (ti.getPagesCount() == 1) {
                    com.pullenti.unitext.UnilayPage p = com.pullenti.unitext.UnilayPage._new158(content);
                    com.pullenti.unisharp.Outargwrapper<Integer> wrapwi159 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                    com.pullenti.unisharp.Outargwrapper<Integer> wraphei160 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                    com.pullenti.unisharp.Outargwrapper<Integer> wrapdpx161 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                    com.pullenti.unisharp.Outargwrapper<Integer> wrapdpy162 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                    com.pullenti.unisharp.Outargwrapper<Boolean> wrapm163 = new com.pullenti.unisharp.Outargwrapper<Boolean>();
                    com.pullenti.unisharp.Outargwrapper<Boolean> wraphasTxt164 = new com.pullenti.unisharp.Outargwrapper<Boolean>();
                    ti.getPageInfo(0, wrapwi159, wraphei160, wrapdpx161, wrapdpy162, wrapm163, wraphasTxt164);
                    wi = (wrapwi159.value != null ? wrapwi159.value : 0);
                    hei = (wraphei160.value != null ? wraphei160.value : 0);
                    dpx = (wrapdpx161.value != null ? wrapdpx161.value : 0);
                    dpy = (wrapdpy162.value != null ? wrapdpy162.value : 0);
                    m = (wrapm163.value != null ? wrapm163.value : false);
                    hasTxt = (wraphasTxt164.value != null ? wraphasTxt164.value : false);
                    p.width = wi;
                    p.height = hei;
                    res.pages.add(p);
                }
                else 
                    for (int i = 0; i < ti.getPagesCount(); i++) {
                        try (com.pullenti.unisharp.MemoryStream pm = new com.pullenti.unisharp.MemoryStream()) {
                            ti.store(i, pm);
                            com.pullenti.unitext.UnilayPage p = com.pullenti.unitext.UnilayPage._new158(pm.toByteArray());
                            com.pullenti.unisharp.Outargwrapper<Integer> wrapwi166 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                            com.pullenti.unisharp.Outargwrapper<Integer> wraphei167 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                            com.pullenti.unisharp.Outargwrapper<Integer> wrapdpx168 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                            com.pullenti.unisharp.Outargwrapper<Integer> wrapdpy169 = new com.pullenti.unisharp.Outargwrapper<Integer>();
                            com.pullenti.unisharp.Outargwrapper<Boolean> wrapm170 = new com.pullenti.unisharp.Outargwrapper<Boolean>();
                            com.pullenti.unisharp.Outargwrapper<Boolean> wraphasTxt171 = new com.pullenti.unisharp.Outargwrapper<Boolean>();
                            ti.getPageInfo(0, wrapwi166, wraphei167, wrapdpx168, wrapdpy169, wrapm170, wraphasTxt171);
                            wi = (wrapwi166.value != null ? wrapwi166.value : 0);
                            hei = (wraphei167.value != null ? wraphei167.value : 0);
                            dpx = (wrapdpx168.value != null ? wrapdpx168.value : 0);
                            dpy = (wrapdpy169.value != null ? wrapdpy169.value : 0);
                            m = (wrapm170.value != null ? wrapm170.value : false);
                            hasTxt = (wraphasTxt171.value != null ? wraphasTxt171.value : false);
                            p.width = wi;
                            p.height = hei;
                            res.pages.add(p);
                        }
                    }
            } catch (Exception ex) {
                res.errorMessage = ex.getMessage();
            }
        }
        return res;
    }

    /**
     * Работа с TIFF-документами
     */
    public static class Tiff {
    
        private byte[] m_Buf = new byte[32];
    
        private boolean m_Msb;
    
        private boolean m_Mdi;
    
        private java.util.ArrayList<Long> m_IfdOffset = new java.util.ArrayList<Long>();
    
        public boolean isMDI() {
            return m_Mdi;
        }
    
    
        private com.pullenti.unisharp.Stream m_Stream = null;
    
        public Tiff(com.pullenti.unisharp.Stream _stream) throws java.io.IOException {
            setStream(_stream);
        }
    
        public com.pullenti.unisharp.Stream getStream() {
            return m_Stream;
        }
    
        public com.pullenti.unisharp.Stream setStream(com.pullenti.unisharp.Stream value) throws java.io.IOException {
            if (value == null) 
                return value;
            m_Stream = value;
            m_IfdOffset.clear();
            m_Stream.setPosition(0L);
            m_Stream.read(m_Buf, 0, 2);
            m_Mdi = false;
            m_Msb = false;
            if (m_Buf[0] == ((byte)0x49) && m_Buf[1] == ((byte)0x49)) 
                m_Msb = false;
            else if (m_Buf[0] == ((byte)0x4D) && m_Buf[1] == ((byte)0x4D)) 
                m_Msb = true;
            else if (m_Buf[0] == ((byte)0x45) && m_Buf[1] == ((byte)0x50)) 
                m_Mdi = true;
            else {
                m_Stream = null;
                return value;
            }
            int i = this.readInt(2);
            while (true) {
                i = this.readInt(4);
                if (i <= 0) 
                    break;
                m_IfdOffset.add((long)i);
                m_Stream.setPosition((long)i);
                int cou = this.readInt(2);
                m_Stream.setPosition((long)(i + 2 + ((cou * 12))));
            }
            return value;
        }
    
    
        public int getPagesCount() {
            return m_IfdOffset.size();
        }
    
    
        /**
         * Сохранение страницы в отдельном файле
         * @param pageIndex 
         * @param FileName 
         */
        public void store(int pageIndex, com.pullenti.unisharp.Stream fout) throws Exception, java.io.IOException {
            if ((pageIndex < 0) || pageIndex >= m_IfdOffset.size()) 
                throw new Exception("Page index error");
            if (m_Msb) 
                m_Buf[0] = (m_Buf[1] = (byte)0x4D);
            else 
                m_Buf[0] = (m_Buf[1] = (byte)0x49);
            fout.write(m_Buf, 0, 2);
            this.writeInt(fout, 0x2A, 2);
            this.writeInt(fout, 8, 4);
            long baseoff = m_IfdOffset.get(pageIndex);
            m_Stream.setPosition(baseoff);
            int i;
            int j;
            int ii = 0;
            int dircount = this.readInt(2);
            int outpos = (8 + 2 + (12 * dircount)) + 4;
            int stripoffpos = 0;
            int stripoffitemsize = 0;
            boolean directData = false;
            int directDataPos = 0;
            int directDataLen = 0;
            java.util.ArrayList<Integer> stripPos = new java.util.ArrayList<Integer>();
            java.util.ArrayList<Integer> stripLen = new java.util.ArrayList<Integer>();
            this.writeInt(fout, dircount, 2);
            for (i = 0; i < dircount; i++) {
                m_Stream.setPosition(baseoff + (2L) + ((long)(i * 12)));
                int tag = this.readInt(2);
                int typ = this.readInt(2);
                int cou = this.readInt(4);
                int dsp = this.readInt(4);
                int itemsize = 1;
                fout.setPosition((long)(8 + 2 + (ii * 12)));
                ii++;
                this.writeInt(fout, tag, 2);
                this.writeInt(fout, typ, 2);
                this.writeInt(fout, cou, 4);
                switch (typ) { 
                case 3:
                    itemsize = 2;
                    break;
                case 4:
                    itemsize = 4;
                    break;
                case 5:
                    itemsize = 8;
                    break;
                case 8:
                    itemsize = 2;
                    break;
                case 9:
                    itemsize = 4;
                    break;
                case 10:
                    itemsize = 8;
                    break;
            }
            int len = itemsize * cou;
            if (len <= 4 && tag != 0x111) {
                this.writeInt(fout, dsp, 4);
                if (tag == 0x117) 
                    directDataLen = dsp;
                continue;
            }
            if (tag == 0x111) {
                stripoffpos = outpos;
                stripoffitemsize = itemsize;
                if (cou == 1) {
                    directData = true;
                    directDataPos = dsp;
                    stripoffpos = (int)fout.getPosition();
                    this.writeInt(fout, dsp, 4);
                    continue;
                }
                else {
                    m_Stream.setPosition((long)dsp);
                    for (j = 0; j < cou; j++) {
                        stripPos.add(this.readInt(itemsize));
                    }
                    m_Stream.setPosition((long)dsp);
                }
            }
            else if (tag == 0x117) {
                if (cou != stripPos.size()) {
                    fout.close();
                    throw new Exception("StripOffsetCount != StripCount");
                }
                m_Stream.setPosition((long)dsp);
                for (j = 0; j < cou; j++) {
                    stripLen.add(this.readInt(itemsize));
                }
                m_Stream.setPosition((long)dsp);
            }
            this.readBuf((long)dsp, len);
            this.writeInt(fout, outpos, 4);
            fout.setPosition((long)outpos);
            fout.write(m_Buf, 0, len);
            outpos += len;
            if (((outpos & 1)) == 1) {
                outpos++;
                this.writeInt(fout, 0, 1);
            }
            }
            fout.setPosition((long)(8 + 2 + (ii * 12)));
            this.writeInt(fout, 0, 4);
            fout.setPosition(8L);
            this.writeInt(fout, ii, 2);
            if (directData) {
                this.readBuf((long)directDataPos, directDataLen);
                fout.setPosition((long)stripoffpos);
                this.writeInt(fout, outpos, 4);
                fout.setPosition((long)outpos);
                fout.write(m_Buf, 0, directDataLen);
                outpos += directDataLen;
            }
            else {
                fout.setPosition((long)outpos);
                for (i = 0; i < stripPos.size(); i++) {
                    this.readBuf((long)(int)stripPos.get(i), stripLen.get(i));
                    com.pullenti.unisharp.Utils.putArrayValue(stripPos, i, outpos);
                    fout.write(m_Buf, 0, stripLen.get(i));
                    outpos += stripLen.get(i);
                }
                fout.setPosition((long)stripoffpos);
                for (i = 0; i < stripPos.size(); i++) {
                    this.writeInt(fout, stripPos.get(i), stripoffitemsize);
                }
            }
        }
    
        /**
         * Извлечение текста, сформированного MODI (хранится в теге 932Fh)
         * @param pageIndex номер страницы
         * @return текст (null при ошибке или отсутствии)
         */
        public String getPageText(int pageIndex) throws Exception, java.io.IOException {
            if ((pageIndex < 0) || pageIndex >= m_IfdOffset.size()) 
                throw new Exception("Page index error");
            long baseoff = m_IfdOffset.get(pageIndex);
            m_Stream.setPosition(baseoff);
            int i;
            int dircount = this.readInt(2);
            for (i = 0; i < dircount; i++) {
                m_Stream.setPosition(baseoff + (2L) + ((long)(i * 12)));
                int tag = this.readInt(2);
                int typ = this.readInt(2);
                int cou = this.readInt(4);
                int dsp = this.readInt(4);
                if (tag != 0x932F) 
                    continue;
                m_Stream.setPosition((long)dsp);
                if (this.readInt(2) != 1) 
                    return null;
                cou = this.readInt(4);
                if (cou < 1) 
                    return null;
                byte[] buf = new byte[cou];
                m_Stream.read(buf, 0, cou);
                int blen = buf.length;
                if (blen > 0 && buf[blen - 1] == ((byte)0)) 
                    blen--;
                if (blen == 0) 
                    return null;
                return com.pullenti.util.MiscHelper.decodeStringUtf8(buf, 0, blen);
            }
            return null;
        }
    
        public boolean getHasText() throws java.io.IOException {
            for (int p = 0; p < m_IfdOffset.size(); p++) {
                long baseoff = m_IfdOffset.get(p);
                m_Stream.setPosition(baseoff);
                int i;
                int dircount = this.readInt(2);
                for (i = 0; i < dircount; i++) {
                    m_Stream.setPosition(baseoff + (2L) + ((long)(i * 12)));
                    int tag = this.readInt(2);
                    int typ = this.readInt(2);
                    int cou = this.readInt(4);
                    int dsp = this.readInt(4);
                    if (tag == 0x932F) 
                        return true;
                }
            }
            return false;
        }
    
    
        /**
         * Это извлечение информации о самой картинке вместе с положением данных во входном потоке 
         * - используется для выделения CCITT-данных для PDF FaxDecode
         * @param pageIndex 
         * @param dataStartPos 
         * @param dataLength 
         * @param width 
         * @param height 
         * @return 
         */
        public boolean getDataInfo(int pageIndex, com.pullenti.unisharp.Outargwrapper<Integer> dataStartPos, com.pullenti.unisharp.Outargwrapper<Integer> dataLength, com.pullenti.unisharp.Outargwrapper<Integer> width, com.pullenti.unisharp.Outargwrapper<Integer> height, com.pullenti.unisharp.Outargwrapper<com.pullenti.unitext.internal.misc.TiffHelper.CCITT_Types> ccittTyp, com.pullenti.unisharp.Outargwrapper<Integer> pageNumber) throws Exception, java.io.IOException {
            dataStartPos.value = (dataLength.value = 0);
            pageNumber.value = 0;
            width.value = (height.value = 0);
            ccittTyp.value = com.pullenti.unitext.internal.misc.TiffHelper.CCITT_Types.G3_1D;
            if ((pageIndex < 0) || pageIndex >= m_IfdOffset.size()) 
                throw new Exception("Page index error");
            long baseoff = m_IfdOffset.get(pageIndex);
            m_Stream.setPosition(baseoff);
            int i;
            int dircount = this.readInt(2);
            for (i = 0; i < dircount; i++) {
                m_Stream.setPosition(baseoff + (2L) + ((long)(i * 12)));
                int tag = this.readInt(2);
                int typ = this.readInt(2);
                int cou = this.readInt(4);
                int dsp = this.readInt(4);
                if (tag == 0x100) 
                    width.value = dsp;
                else if (tag == 0x101) 
                    height.value = dsp;
                else if (tag == 0x111) 
                    dataStartPos.value = dsp;
                else if (tag == 0x117) 
                    dataLength.value = dsp;
                else if (tag == 0x103) 
                    ccittTyp.value = com.pullenti.unitext.internal.misc.TiffHelper.CCITT_Types.of(dsp);
                else if (tag == 0x129) {
                }
            }
            return dataLength.value > 0;
        }
    
        public void getPageInfo(int pageIndex, com.pullenti.unisharp.Outargwrapper<Integer> width, com.pullenti.unisharp.Outargwrapper<Integer> height, com.pullenti.unisharp.Outargwrapper<Integer> dpi_x, com.pullenti.unisharp.Outargwrapper<Integer> dpi_y, com.pullenti.unisharp.Outargwrapper<Boolean> isMono, com.pullenti.unisharp.Outargwrapper<Boolean> _hasText) throws java.io.IOException {
            width.value = (height.value = (dpi_x.value = (dpi_y.value = 0)));
            isMono.value = (_hasText.value = false);
            if ((pageIndex < 0) || pageIndex >= m_IfdOffset.size()) 
                return;
            long baseoff = m_IfdOffset.get(pageIndex);
            m_Stream.setPosition(baseoff);
            int i;
            int dircount = this.readInt(2);
            int mono = -1;
            int resUnit = 2;
            long resXpos = 0L;
            long resYpos = 0L;
            for (i = 0; i < dircount; i++) {
                m_Stream.setPosition(baseoff + (2L) + ((long)(i * 12)));
                int tag = this.readInt(2);
                int typ = this.readInt(2);
                int cou = this.readInt(4);
                int dsp = this.readInt(4);
                if (tag == 0x100) 
                    width.value = dsp;
                else if (tag == 0x101) 
                    height.value = dsp;
                else if (tag == 0x106 && (mono < 0)) 
                    mono = ((dsp == 0 || dsp == 1) ? 1 : 0);
                else if (tag == 0x102 && dsp > 1) 
                    mono = 0;
                else if (tag == 0x932F) 
                    _hasText.value = true;
                else if (tag == 0x128) 
                    resUnit = dsp;
                else if (tag == 0x11A) 
                    resXpos = (long)dsp;
                else if (tag == 0x11B) 
                    resYpos = (long)dsp;
            }
            isMono.value = mono == 1;
            if (((resUnit == 2 || resUnit == 3)) && resXpos > (0L)) {
                m_Stream.setPosition(resXpos);
                int v1 = this.readInt(4);
                int v2 = this.readInt(4);
                float a = (float)v1;
                if (v2 > 1) 
                    a /= ((float)v2);
                if (resUnit == 3) 
                    a *= 2.54F;
                dpi_x.value = (int)a;
            }
            if (((resUnit == 2 || resUnit == 3)) && resYpos > (0L)) {
                m_Stream.setPosition(resYpos);
                int v1 = this.readInt(4);
                int v2 = this.readInt(4);
                float a = (float)v1;
                if (v2 > 1) 
                    a /= ((float)v2);
                if (resUnit == 3) 
                    a *= 2.54F;
                dpi_y.value = (int)a;
            }
        }
    
        /**
         * Создание TIFF по чистым данным без заголовка (фактически обрамляет заголовком)
         * @param res 
         * @param width 
         * @param height 
         * @param typ 
         * @param xResolution 
         * @param yResolution 
         * @param data 
         */
        public void writeTiff(com.pullenti.unisharp.Stream res, int width, int height, com.pullenti.unitext.internal.misc.TiffHelper.CCITT_Types typ, float xResolution, float yResolution, boolean invert, byte[] data) throws java.io.IOException {
            res.write((byte)0x49);
            res.write((byte)0x49);
            this._WriteInt(res, 0x2A, 2);
            this._WriteInt(res, (8 + data.length + 8) + 8, 4);
            res.write(data, 0, data.length);
            this._WriteInt(res, (int)xResolution, 4);
            this._WriteInt(res, 1, 4);
            this._WriteInt(res, (int)yResolution, 4);
            this._WriteInt(res, 1, 4);
            int dirs = 0;
            this._WriteInt(res, 0, 2);
            this.writeDirEntry(res, 0xFE, 4, 1, 0);
            dirs++;
            this.writeDirEntry(res, 0x100, 3, 1, width);
            dirs++;
            this.writeDirEntry(res, 0x101, 3, 1, height);
            dirs++;
            this.writeDirEntry(res, 0x102, 3, 1, 1);
            dirs++;
            this.writeDirEntry(res, 0x103, 3, 1, typ.value());
            dirs++;
            this.writeDirEntry(res, 0x106, 3, 1, (invert ? 1 : 0));
            dirs++;
            this.writeDirEntry(res, 0x111, 4, 1, 8);
            dirs++;
            this.writeDirEntry(res, 0x115, 3, 1, 1);
            dirs++;
            this.writeDirEntry(res, 0x116, 3, 1, height);
            dirs++;
            this.writeDirEntry(res, 0x117, 4, 1, data.length);
            dirs++;
            this.writeDirEntry(res, 0x11A, 5, 1, 8 + data.length);
            dirs++;
            this.writeDirEntry(res, 0x11B, 5, 1, 8 + data.length + 8);
            dirs++;
            this.writeDirEntry(res, 0x128, 3, 1, 2);
            dirs++;
            this._WriteInt(res, 0, 4);
            res.setPosition((long)((8 + data.length + 8) + 8));
            this._WriteInt(res, dirs, 2);
        }
    
        private int readInt(int count) throws java.io.IOException {
            int res = 0;
            for (int i = 0; i < count; i++) {
                int j = m_Stream.read();
                if (j < 0) 
                    break;
                if (m_Msb) 
                    res |= j << (((count - 1 - i)) << 3);
                else 
                    res |= j << (i << 3);
            }
            return res;
        }
    
        private void readBuf(long pos, int size) throws java.io.IOException {
            if (m_Buf.length < size) 
                m_Buf = new byte[size];
            m_Stream.setPosition(pos);
            m_Stream.read(m_Buf, 0, size);
        }
    
        private byte[] fBuf2 = new byte[16];
    
        private void writeInt(com.pullenti.unisharp.Stream fOut, int val, int count) throws java.io.IOException {
            for (int i = 0; i < count; i++) {
                int j;
                if (m_Msb) 
                    j = ((val >> (((count - 1 - i)) << 3))) & 0xFF;
                else 
                    j = ((val >> (i << 3))) & 0xFF;
                fBuf2[i] = (byte)j;
            }
            fOut.write(fBuf2, 0, count);
        }
    
        private void _WriteInt(com.pullenti.unisharp.Stream fOut, int val, int count) throws java.io.IOException {
            for (int i = 0; i < count; i++) {
                int j = ((val >> (i << 3))) & 0xFF;
                fBuf2[i] = (byte)j;
            }
            fOut.write(fBuf2, 0, count);
        }
    
        private void writeDirEntry(com.pullenti.unisharp.Stream fOut, int tag, int typ, int count, int data) throws java.io.IOException {
            this._WriteInt(fOut, tag, 2);
            this._WriteInt(fOut, typ, 2);
            this._WriteInt(fOut, count, 4);
            this._WriteInt(fOut, data, 4);
        }
        public Tiff() {
        }
    }


    public static class CCITT_Types implements Comparable<CCITT_Types> {
    
        public static final CCITT_Types G3_1D; // 2
    
        public static final CCITT_Types G3_2D; // 3
    
        public static final CCITT_Types G4; // 4
    
    
        public int value() { return m_val; }
        private int m_val;
        private String m_str;
        private CCITT_Types(int val, String str) { m_val = val; m_str = str; }
        @Override
        public String toString() {
            if(m_str != null) return m_str;
            return ((Integer)m_val).toString();
        }
        @Override
        public int hashCode() {
            return (int)m_val;
        }
        @Override
        public int compareTo(CCITT_Types v) {
            if(m_val < v.m_val) return -1;
            if(m_val > v.m_val) return 1;
            return 0;
        }
        private static java.util.HashMap<Integer, CCITT_Types> mapIntToEnum; 
        private static java.util.HashMap<String, CCITT_Types> mapStringToEnum; 
        private static CCITT_Types[] m_Values; 
        private static java.util.Collection<Integer> m_Keys; 
        public static CCITT_Types of(int val) {
            if (mapIntToEnum.containsKey(val)) return mapIntToEnum.get(val);
            CCITT_Types item = new CCITT_Types(val, ((Integer)val).toString());
            mapIntToEnum.put(val, item);
            mapStringToEnum.put(item.m_str.toUpperCase(), item);
            return item; 
        }
        public static CCITT_Types of(String str) {
            str = str.toUpperCase(); 
            if (mapStringToEnum.containsKey(str)) return mapStringToEnum.get(str);
            return null; 
        }
        public static boolean isDefined(Object val) {
            if(val instanceof Integer) return m_Keys.contains((Integer)val); 
            return false; 
        }
        public static CCITT_Types[] getValues() {
            return m_Values; 
        }
        static {
            mapIntToEnum = new java.util.HashMap<Integer, CCITT_Types>();
            mapStringToEnum = new java.util.HashMap<String, CCITT_Types>();
            G3_1D = new CCITT_Types(2, "G3_1D");
            mapIntToEnum.put(G3_1D.value(), G3_1D);
            mapStringToEnum.put(G3_1D.m_str.toUpperCase(), G3_1D);
            G3_2D = new CCITT_Types(3, "G3_2D");
            mapIntToEnum.put(G3_2D.value(), G3_2D);
            mapStringToEnum.put(G3_2D.m_str.toUpperCase(), G3_2D);
            G4 = new CCITT_Types(4, "G4");
            mapIntToEnum.put(G4.value(), G4);
            mapStringToEnum.put(G4.m_str.toUpperCase(), G4);
            java.util.Collection<CCITT_Types> col = mapIntToEnum.values();
            m_Values = new CCITT_Types[col.size()];
            col.toArray(m_Values);
            m_Keys = new java.util.ArrayList<Integer>(mapIntToEnum.keySet());
        }
    }

    public TiffHelper() {
    }
    public static TiffHelper _globalInstance;
    
    static {
        try { _globalInstance = new TiffHelper(); } 
        catch(Exception e) { }
    }
}
