Пример #1
0
        public static bool CheckIsImage(string plistFilePath)
        {
            if (!PListImageReader.CheckFile(plistFilePath))
            {
                return(false);
            }
            PListRoot listRoot = (PListRoot)null;

            using (FileStream fileStream = File.Open(plistFilePath, FileMode.Open, FileAccess.Read))
                listRoot = PListRoot.Load((Stream)fileStream);
            return(PListImageReader.CheckPList(listRoot));
        }
Пример #2
0
        public PListImageReader(string plistFilePath)
        {
            PListImageReader.CheckFile(plistFilePath);
            PListRoot listRoot = (PListRoot)null;

            using (FileStream fileStream = File.Open(plistFilePath, FileMode.Open, FileAccess.Read))
                listRoot = PListRoot.Load((Stream)fileStream);
            if (listRoot == null || listRoot.Root == null || !(listRoot.Root is PListDict))
            {
                throw new ArgumentException("给定的PList文件格式不正确.");
            }
            if (!PListImageReader.CheckPList(listRoot))
            {
                throw new ArgumentException("给定的PList文件,不是大图合并的文件.");
            }
            this.rootElement         = listRoot.Root as PListDict;
            this.plistFilePath       = plistFilePath;
            this.plistFormatAnalysis = PlistImageFormatFactory.CreatePlistFormat(this.rootElement);
            this.ImageFilePath       = this.plistFormatAnalysis.GetImageFilePath(plistFilePath);
            if (this.ImageFilePath == null || !File.Exists(this.ImageFilePath))
            {
                throw new ArgumentException("对应的图片文件不存在.");
            }
        }