コード例 #1
0
ファイル: Compiler.cs プロジェクト: rgiot/phactory
        public bool Compile(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);
            if (fileInfo == null)
            {
                return false;
            }

            if (!IsResourceSupported(resource))
            {
                return false;
            }

            var compiler = new Phactory.Modules.RawBitmap.Compiler.RawCompiler();

            Document.Document tempDocument = Host.XMLRead<Document.Document>(Host.GetFileInfo(resource).FullName);
            if (!tempDocument.CompileInternal())
            {
                return false;
            }

            List<string> outputFilenames = new List<string>();

            foreach (Document.Item item in tempDocument.Items)
            {
                App.Controller.View.AppDoEvents();

                PhactoryHost.Database.Resource resItem = Host.GetResource(item.ResourceID);
                if (resItem == null)
                {
                    Host.Log("Unknown resource identifier : " + item.ResourceID);
                    return false;
                }

                FileInfo resFileInfo = Host.GetFileInfo(resItem);
                string outputFilename = resFileInfo.FullName;

                if (Host.IsVerboseOutput())
                {
                    Host.Log(outputFilename);
                }

                Document.ItemType type = item.Type;

                if (type == CPCRawBitmap.Document.ItemType.Raw)
                {
                    string outputTopFilename = outputFilename + ".rawBin";

                    if (!compiler.WriteRawBinFile(outputTopFilename,
                                                        item.IntermediateImage.Width,
                                                        item.IntermediateImage.Height,
                                                        item.IntermediateImage.Data,
                                                        false))
                    {
                        return false;
                    }
                }
                else if (type == CPCRawBitmap.Document.ItemType.VerticalRaw)
                {
                    string outputTopFilename = outputFilename + ".verticalRawBin";

                    if (!compiler.WriteRawBinFile(outputTopFilename,
                                                        item.IntermediateImage.Width,
                                                        item.IntermediateImage.Height,
                                                        item.IntermediateImage.Data,
                                                        true))
                    {
                        return false;
                    }
                }
            }

            return true;
        }
コード例 #2
0
        public bool Compile(PhactoryHost.Database.Resource resource)
        {
            FileInfo fileInfo = Host.GetFileInfo(resource);

            if (fileInfo == null)
            {
                return(false);
            }

            if (!IsResourceSupported(resource))
            {
                return(false);
            }

            var compiler = new Phactory.Modules.RawBitmap.Compiler.RawCompiler();

            Document.Document tempDocument = Host.XMLRead <Document.Document>(Host.GetFileInfo(resource).FullName);
            if (!tempDocument.CompileInternal())
            {
                return(false);
            }

            List <string> outputFilenames = new List <string>();

            foreach (Document.Item item in tempDocument.Items)
            {
                App.Controller.View.AppDoEvents();

                PhactoryHost.Database.Resource resItem = Host.GetResource(item.ResourceID);
                if (resItem == null)
                {
                    Host.Log("Unknown resource identifier : " + item.ResourceID);
                    return(false);
                }

                FileInfo resFileInfo    = Host.GetFileInfo(resItem);
                string   outputFilename = resFileInfo.FullName;

                if (Host.IsVerboseOutput())
                {
                    Host.Log(outputFilename);
                }

                Document.ItemType type = item.Type;

                if (type == CPCRawBitmap.Document.ItemType.Raw)
                {
                    string outputTopFilename = outputFilename + ".rawBin";

                    if (!compiler.WriteRawBinFile(outputTopFilename,
                                                  item.IntermediateImage.Width,
                                                  item.IntermediateImage.Height,
                                                  item.IntermediateImage.Data,
                                                  false))
                    {
                        return(false);
                    }
                }
                else if (type == CPCRawBitmap.Document.ItemType.VerticalRaw)
                {
                    string outputTopFilename = outputFilename + ".verticalRawBin";

                    if (!compiler.WriteRawBinFile(outputTopFilename,
                                                  item.IntermediateImage.Width,
                                                  item.IntermediateImage.Height,
                                                  item.IntermediateImage.Data,
                                                  true))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }