示例#1
0
        public static IGeoImage GeoOpen(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            if (System.IO.Path.GetExtension(path) == ".rst")
            {
                try
                {
                    GeoImage img = new GeoImage(path);
                    img.Tag = path;
                    return(img);
                }
                catch
                {
                    return(null);
                }
            }
            else
            {
                GeoNormalImage img = new GeoNormalImage();
                if ("" != img.Open(path))
                {
                    img.Dispose();
                    return(null);
                }
                img.Tag = path;
                return(img);
            }
        }
示例#2
0
        //..

        public unsafe GeoImage ToCompressImage(LCompressFormat s, string filename)
        {
            LImageInfo info = new LImageInfo();

            GetImageInfo(_imgPtr, ref info);

            IntPtr of = IntPtr.Zero;

            info.LCFormate = s;
            CreateLFile(filename, info, ref of);
            int nTileY      = info.nRows;
            int nTileX      = info.nCols;
            int size        = 512 * 512 * (info.bits / 8) * info.bands;
            int bytePerLine = 512 * (info.bits / 8) * info.bands;

            byte[] buf = new byte[size];
            int    r   = 0;

            fixed(void *ptr = buf)
            {
                for (int nLvl = 0; nLvl < info.levelCount; nLvl++)
                {
                    for (int i = 0; i < nTileY; i++)
                    {
                        for (int j = 0; j < nTileX; j++)
                        {
                            r = ReadTile(1, nLvl, i, j, buf, 0, s);
                            LTileIO(LFRWFlag.LF_Write, of, nLvl, i, j, ptr, 1, ref r);
                        }
                    }

                    nTileX = (nTileX + 1) >> 1;
                    nTileY = (nTileY + 1) >> 1;
                }
            }

            CloseLFile(of);

            GeoImage reader = new GeoImage();

            reader.Open(filename);
            return(reader);
        }