Example #1
0
        public void Terminate()
        {
            foreach (var layer in layers)
            {
                layer.Dispose();
            }

            layers.Clear();

            if (doc != null)
            {
                doc.Dispose();
            }
            doc = null;
        }
Example #2
0
        void Reset()
        {
            foreach (var layer in layers)
            {
                layer.Dispose();
            }

            layers.Clear();

            if (doc != null)
            {
                doc.Dispose();
            }
            doc = null;

            // 画像を完全に破棄する。
            System.GC.Collect();
            System.GC.Collect();
            System.GC.WaitForFullGCComplete();
            System.GC.Collect();
            System.GC.Collect();
        }
Example #3
0
        public unsafe ErrorCode Load(string path)
        {
            Reset();

            if (!System.IO.File.Exists(path))
            {
                return(ErrorCode.FileIsNotFound);
            }

            var buf = System.IO.File.ReadAllBytes(path);

            fixed(byte *p = buf)
            {
                doc = swig.Document.Create((IntPtr)p, buf.Count());
            }

            if (doc == null)
            {
                return(ErrorCode.FailedToParse);
            }

            var depth = doc.GetDepth();

            if (depth > 8)
            {
                doc.Dispose();
                doc = null;
                return(ErrorCode.DepthIs16);
            }

            for (int i = 0; i < doc.GetLayerCount(); i++)
            {
                layers.Add(new Layer(doc.GetLayer(i)));
            }

            return(ErrorCode.Succeed);
        }
Example #4
0
        void Reset()
        {
            layers.Clear();

            if (doc != null)
            {
                doc.Release();
            }
            doc = null;
        }
Example #5
0
        public void Terminate()
        {
            layers.Clear();

            if(doc != null)
            {
                doc.Release();
            }
            doc = null;
        }
Example #6
0
        public unsafe ErrorCode Load(string path)
        {
            Reset();

            if (!System.IO.File.Exists(path)) return ErrorCode.FileIsNotFound;

            var buf = System.IO.File.ReadAllBytes(path);

            fixed(byte* p = buf)
            {
                doc = swig.Document.Create((IntPtr)p, buf.Count());
            }

            if (doc == null) return ErrorCode.FailedToParse;

            var depth = doc.GetDepth();
            if(depth > 8)
            {
                doc.Release();
                doc = null;
                return ErrorCode.DepthIs16;
            }

            for (int i = 0; i < doc.GetLayerCount(); i++ )
            {
                layers.Add(new Layer(doc.GetLayer(i)));
            }

            return ErrorCode.Succeed;
        }