Ejemplo n.º 1
0
 public static void SaveToPng( string FileName, string ToFileName, string XamlFileName )
 {
     PngReader pngr = FileHelper.CreatePngReader(FileName);
     PngWriter pngw = FileHelper.CreatePngWriter(ToFileName, pngr.ImgInfo, true);
     pngw.CopyChunksFirst(pngr, ChunkCopyBehaviour.COPY_ALL_SAFE);
     PngChunkSKIN mychunk = new PngChunkSKIN(pngw.ImgInfo);
     mychunk.Content = File.ReadAllText( XamlFileName );
     mychunk.Priority = true; // if we want it to be written as soon as possible
     pngw.GetChunksList().Queue(mychunk);
     for (int row = 0; row < pngr.ImgInfo.Rows; row++) {
         ImageLine l1 = pngr.ReadRow(row);
         pngw.WriteRow(l1, row);
     }
     pngw.CopyChunksLast(pngr, ChunkCopyBehaviour.COPY_ALL);
     pngr.End();
     pngw.End();
 }
Ejemplo n.º 2
0
        public static void SaveToPng(string FileName, string ToFileName, string XamlFileName)
        {
            PngReader pngr = FileHelper.CreatePngReader(FileName);
            PngWriter pngw = FileHelper.CreatePngWriter(ToFileName, pngr.ImgInfo, true);

            pngw.CopyChunksFirst(pngr, ChunkCopyBehaviour.COPY_ALL_SAFE);
            PngChunkSKIN mychunk = new PngChunkSKIN(pngw.ImgInfo);

            mychunk.Content  = File.ReadAllText(XamlFileName);
            mychunk.Priority = true; // if we want it to be written as soon as possible
            pngw.GetChunksList().Queue(mychunk);
            for (int row = 0; row < pngr.ImgInfo.Rows; row++)
            {
                ImageLine l1 = pngr.ReadRow(row);
                pngw.WriteRow(l1, row);
            }
            pngw.CopyChunksLast(pngr, ChunkCopyBehaviour.COPY_ALL);
            pngr.End();
            pngw.End();
        }
Ejemplo n.º 3
0
        public static ResourceDictionary LoadFromPng(string FileName)
        {
            // read all file
            PngReader pngr = FileHelper.CreatePngReader(FileName);

            pngr.ReadSkippingAllRows();
            pngr.End();
            // we assume there can be at most one chunk of this type...
            PngChunk chunk = pngr.GetChunksList().GetById1(PngChunkSKIN.ID); // This would work even if not registered, but then PngChunk would be of type PngChunkUNKNOWN

            if (chunk != null)
            {
                // the following would fail if we had not register the chunk
                PngChunkSKIN  chunkprop = (PngChunkSKIN)chunk;
                ParserContext pc        = new ParserContext();
                pc.XamlTypeMapper = XamlTypeMapper.DefaultMapper;
                //  pc.XmlSpace

                //MimeObjectFactory s;

                var rd1 = (ResourceDictionary)XamlReader.Parse(chunkprop.Content);

                // Application.Current.Resources.MergedDictionaries.Add(rd1);

                //  var rd2 = (ResourceDictionary)XamlReader.Parse(chunkprop.Content);

                ////  Application.Current.Resources.MergedDictionaries.Add(rd2);

                //  if (rd1 == rd2) {
                //  }

                return(rd1);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
            public override void CloneDataFromRead(PngChunk other)
            {
                PngChunkSKIN otherx = (PngChunkSKIN)other;

                this.Content = otherx.Content;
            }