Beispiel #1
0
        /// <summary>
        /// Retusn a Hashtable that contains the largest Images of the passed Textures
        /// </summary>
        /// <param name="txtrs"></param>
        /// <returns>The Keys of the Hashtabel are the Subset names, the values contain ImageStreams</returns>
        public Hashtable GetLargestImages(Hashtable txtrs)
        {
            Hashtable list = new Hashtable();

            foreach (string s in txtrs.Keys)
            {
                Rcol      rcol = (Rcol)txtrs[s];
                ImageData id   = (ImageData)rcol.Blocks[0];

                id.GetReferencedLifos();
                System.Drawing.Image img = id.LargestTexture.Texture;                //null;

                /*foreach (MipMapBlock mmp in id.MipMapBlocks)
                 * {
                 *      foreach (MipMap mm in mmp.MipMaps)
                 *      {
                 *              if (mm.Texture!=null) img=mm.Texture;
                 *      }
                 * }*/


                if (img != null)
                {
                    //img.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipX);
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                    list.Add(s, ms);
                }
            }

            return(list);
        }
Beispiel #2
0
        protected string AddTxtr(GenericRcol txtr, string unique, GenericRcol txmt, MaterialDefinition md)
        {
            string old = Hashes.StripHashFromName(txtr.FileName.Trim().ToLower());

            if (old.EndsWith("_txtr"))
            {
                old = old.Substring(0, old.Length - 5);
            }
            //Console.WriteLine("Adding Texture: "+old);

            string name = txtr.FileName.Trim();

            if (name.ToLower().EndsWith("_txtr"))
            {
                name = name.Substring(0, name.Length - 5);
            }

            string tname = RenameForm.ReplaceOldUnique(name, unique, true);

            txtr.FileName = tname + "_txtr";

            txtr.FileDescriptor = ScenegraphHelper.BuildPfd(txtr.FileName, Data.MetaData.TXTR, Data.MetaData.CUSTOM_GROUP);

            for (int i = 0; i < md.Listing.Length; i++)
            {
                if (Hashes.StripHashFromName(md.Listing[i].Trim().ToLower()) == old)
                {
                    md.Listing[i] = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + tname;
                }
            }

            //update References
            foreach (string k in txmt.ReferenceChains.Keys)
            {
                if (k == "TXTR" || k == "Generic")
                {
                    continue;
                }
                //Console.WriteLine("    Checking Property "+k);
                string thisname = Hashes.StripHashFromName(md.FindProperty(k).Value.Trim().ToLower());

                if (thisname == old)
                {
                    string nname = "##0x" + Helper.HexString(Data.MetaData.CUSTOM_GROUP) + "!" + tname;
                    //Console.WriteLine("    --> Updating to "+nname);
                    md.FindProperty(k).Value = nname;
                }
            }

            //Load the Lifos into the Texture File
            ImageData id = (ImageData)txtr.Blocks[0];

            id.GetReferencedLifos();

            return(name);
        }