示例#1
0
        public void SaveObject(string filename, object configuration)
        {
            FileStream ddsStream = null;

            try
            {
                if (maps == null || !maps.Any())
                {
                    return;
                }

                DdsSaveConfig config = configuration as DdsSaveConfig ?? new DdsSaveConfig(FileFormat.Unknown, 0, 0, false, false);
                config.FileFormat = parsedImageFormat;

                //parse uncompressed image
                DdsFile ddsImage = new DdsFile(GetObjectStream());

                ddsStream = new FileStream(filename, FileMode.Create);
                ddsImage.Save(ddsStream, config);

                ddsStream.Close();
                ddsStream.Dispose();
            }
            finally
            {
                if (ddsStream != null)
                {
                    ddsStream.Dispose();
                }
            }
        }
示例#2
0
        public void SaveObject(string filename, object configuration)
        {
            if (maps == null || !maps.Any())
            {
                return;
            }

            DdsSaveConfig config = configuration as DdsSaveConfig ?? new DdsSaveConfig(FileFormat.Unknown, 0, 0, false, false);
            FileFormat    format;

            MipMap mipMap = maps.Where(mm => mm.uncompressedData != null && mm.uncompressedData.Length > 0).OrderByDescending(mm => mm.sizeX > mm.sizeY ? mm.sizeX : mm.sizeY).FirstOrDefault();

            if (mipMap == null)
            {
                return;
            }

            Stream memory = buildDdsImage(maps.IndexOf(mipMap), out format);

            if (memory == null)
            {
                return;
            }

            DdsFile    ddsImage  = new DdsFile(GetObjectStream());
            FileStream ddsStream = new FileStream(filename, FileMode.Create);

            config.FileFormat = format;
            ddsImage.Save(ddsStream, config);
            ddsStream.Close();

            memory.Close();
        }
示例#3
0
 public static void PNG_To_DDS(string From_PNG_File, string To_DDS_File, DdsFileFormat Format)
 {
     //こっちのコードもメモリリークしていますが、GCで解放されるため放置
     System.IO.FileStream fileStream = new System.IO.FileStream(To_DDS_File, System.IO.FileMode.Create);
     DdsFile.Save(fileStream, Format, DdsErrorMetric.Perceptual, BC7CompressionMode.Slow, false, false, ResamplingAlgorithm.Bilinear, Surface.CopyFromBitmap(new Bitmap(From_PNG_File)), null);
     fileStream.Close();
 }
        public override async Task SaveObject(string filename, object configuration)
        {
            if (MipMaps == null || !MipMaps.Any())
            {
                return;
            }

            DdsSaveConfig config = configuration as DdsSaveConfig ?? new DdsSaveConfig(FileFormat.Unknown, 0, 0, false, false);

            FileFormat format;

            DomainMipMap mipMap = MipMaps.Where(mm => mm.ImageData != null && mm.ImageData.Length > 0).OrderByDescending(mm => mm.Width > mm.Height ? mm.Width : mm.Height).FirstOrDefault();

            if (mipMap == null)
            {
                return;
            }

            Stream memory = buildDdsImage(MipMaps.IndexOf(mipMap), out format);

            if (memory == null)
            {
                return;
            }

            DdsFile ddsImage = new DdsFile(memory);

            FileStream ddsStream = new FileStream(filename, FileMode.Create);

            config.FileFormat = format;

            await Task.Run(() => ddsImage.Save(ddsStream, config));

            ddsStream.Close();

            memory.Close();
        }
示例#5
0
        private void exportToolStripButton_Click(object sender, EventArgs e)
        {
            //Prepare
            string filename = string.Empty;
            bool   save     = false;

            //Get Filename
            string[] parts = this.bitmap.Entry.Filename.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
            if (parts.Length > 0)
            {
                filename = parts[parts.Length - 1];
            }

            //Initialize
            using (SaveFileDialog saveDlg = new SaveFileDialog())
            {
                //Setup
                saveDlg.Filter   = "DirectDraw Surface Files (*.dds)|*.dds";
                saveDlg.Title    = "Save texture as...";
                saveDlg.FileName = filename;
                if (saveDlg.ShowDialog() == DialogResult.OK)
                {
                    filename = saveDlg.FileName;
                    save     = true;
                }
            }

            //Prepare
            HaloBitmap.BitmapProperties bitmap = null;
            int bitmapIndex = (int)bitmapUpDown.Value;

            //Check
            if (save)
            {
                //Get Bitmap
                bitmap = this.bitmap.Bitmaps[bitmapIndex];
                uint width = bitmap.Width, height = bitmap.Height, depth = bitmap.Depth;
                bool swizzled = (bitmap.Flags & HaloBitmap.BitmapFlags.Swizzled) == HaloBitmap.BitmapFlags.Swizzled;
                if ((bitmap.Flags & HaloBitmap.BitmapFlags.PowTwoDimensions) == 0 && bitmap.MipmapCount == 0)
                {
                    width = width + (16 - (width % 16) == 16 ? 0 : 16 - (width % 16));  //Pad width to 16 for some ungodly reason
                }
                //Setup DDS file
                DdsFile file = new DdsFile();
                file.Width             = width;
                file.Height            = height;
                file.MipmapCount       = bitmap.MipmapCount;
                file.DefinitionFlags  |= DirectDrawSurfaceDefinitionFlags.PixelFormat | DirectDrawSurfaceDefinitionFlags.Width | DirectDrawSurfaceDefinitionFlags.Height | DirectDrawSurfaceDefinitionFlags.Caps;
                file.Caps             |= DirectDrawCaps.Texture;
                file.PitchOrLinearSize = (uint)bitmap_GetLength(bitmap.Format, bitmap.Width, bitmap.Height);
                file.DefinitionFlags  |= DirectDrawSurfaceDefinitionFlags.LinearSize;
                if (file.MipmapCount > 0)
                {
                    file.Caps |= DirectDrawCaps.Mipmap | DirectDrawCaps.Complex; file.DefinitionFlags |= DirectDrawSurfaceDefinitionFlags.MipmapCount;
                }

                //Setup Pixel Format
                switch (bitmap.Format)
                {
                case HaloBitmap.BitmapFormat.Dxt1: file.RgbBitCount = 0; file.FourCC = "DXT1"; file.PixelFormatFlags |= DirectDrawPixelFormatFlags.FourCC; break;

                case HaloBitmap.BitmapFormat.Dxt3: file.RgbBitCount = 0; file.FourCC = "DXT3"; file.PixelFormatFlags |= DirectDrawPixelFormatFlags.FourCC; break;

                case HaloBitmap.BitmapFormat.Dxt5: file.RgbBitCount = 0; file.FourCC = "DXT5"; file.PixelFormatFlags |= DirectDrawPixelFormatFlags.FourCC; break;

                case HaloBitmap.BitmapFormat.V8u8: file.RgbBitCount = 16; file.PixelFormatFlags = DirectDrawPixelFormatFlags.VU; break;

                default: file.RgbBitCount = (uint)bitmapFormat_GetBitCount(bitmap.Format); break;
                }
                uint aMask = 0, rMask = 0, gMask = 0, bMask = 0;
                bitmapFormat_GetBitMask(bitmap.Format, out aMask, out rMask, out bMask, out gMask);
                file.AlphaBitmask = aMask; file.RedBitmask = rMask; file.GreenBitmask = gMask; file.BlueBitmask = bMask;

                //Setup Bits
                switch (bitmap.Format)
                {
                case HaloBitmap.BitmapFormat.A8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaPixels; break;

                case HaloBitmap.BitmapFormat.Y8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Luminance; break;

                case HaloBitmap.BitmapFormat.Ay8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaPixels; break;

                case HaloBitmap.BitmapFormat.G8b8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaLuminance; break;

                case HaloBitmap.BitmapFormat.A8y8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaLuminance; break;

                case HaloBitmap.BitmapFormat.R5g6b5: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Rgb; break;

                case HaloBitmap.BitmapFormat.A4r4g4b4: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Argb; break;

                case HaloBitmap.BitmapFormat.X8r8g8b8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Rgb; break;

                case HaloBitmap.BitmapFormat.A8r8g8b8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Argb; break;
                }

                //Prepare File Data
                int mapWidth = (int)width, mapHeight = (int)height;
                file.Data = new byte[bitmap.RawLengths[0]];
                using (MemoryStream ds = new MemoryStream(file.Data))
                    using (MemoryStream ms = new MemoryStream(bitmap_LoadData(bitmapIndex, 0)))
                        using (BinaryWriter writer = new BinaryWriter(ds))
                            using (BinaryReader reader = new BinaryReader(ms))
                                for (int i = 0; i <= bitmap.MipmapCount; i++)
                                {
                                    byte[] data = reader.ReadBytes(bitmap_GetLength(bitmap.Format, mapWidth, mapHeight));
                                    if (data.Length > 0)
                                    {
                                        writer.Write(swizzled ? Swizzler.Swizzle(data, mapWidth, mapHeight, (int)depth, (int)file.RgbBitCount, swizzled) : data);
                                    }
                                    mapWidth /= 2; mapHeight /= 2;
                                }

                //Save
                file.Save(filename);
            }
        }
示例#6
0
        private void dumpTexturesToolStripButton_Click(object sender, EventArgs e)
        {
            //Check
            if (bitmap == null)
            {
                return;
            }

            //Prepare
            string directory = string.Empty;
            bool   ok        = false;

            //Initialize
            using (FolderBrowserDialog folderDlg = new FolderBrowserDialog())
            {
                //Setup
                folderDlg.Description = "Select directory to dump textures.";

                //Show
                if (folderDlg.ShowDialog() == DialogResult.OK)
                {
                    directory = folderDlg.SelectedPath;
                    ok        = true;
                }
            }

            //Check
            if (ok)
            {
                //Prepare
                HaloBitmap.BitmapProperties bitmap = null;
                string[] parts    = this.bitmap.Entry.Filename.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
                string   filename = Path.Combine(directory, $"{parts[parts.Length - 1]}_{{0}}.dds");

                //Loop
                for (int b = 0; b < this.bitmap.BitmapCount; b++)
                {
                    //Get Bitmap
                    bitmap = this.bitmap.Bitmaps[b];
                    uint width = bitmap.Width, height = bitmap.Height, depth = bitmap.Depth;
                    bool swizzled = (bitmap.Flags & HaloBitmap.BitmapFlags.Swizzled) == HaloBitmap.BitmapFlags.Swizzled;
                    if ((bitmap.Flags & HaloBitmap.BitmapFlags.PowTwoDimensions) == 0 && bitmap.MipmapCount == 0)
                    {
                        width = (uint)Math.Ceiling(width / 16f) * 16;    //Pad width to 16 for some ungodly reason
                    }
                    //Setup DDS file
                    DdsFile file = new DdsFile();
                    file.Width             = width;
                    file.Height            = height;
                    file.MipmapCount       = bitmap.MipmapCount;
                    file.DefinitionFlags  |= DirectDrawSurfaceDefinitionFlags.PixelFormat | DirectDrawSurfaceDefinitionFlags.Width | DirectDrawSurfaceDefinitionFlags.Height | DirectDrawSurfaceDefinitionFlags.Caps;
                    file.Caps             |= DirectDrawCaps.Texture;
                    file.PitchOrLinearSize = (uint)bitmap_GetLength(bitmap.Format, bitmap.Width, bitmap.Height);
                    file.DefinitionFlags  |= DirectDrawSurfaceDefinitionFlags.LinearSize;
                    if (file.MipmapCount > 0)
                    {
                        file.Caps |= DirectDrawCaps.Mipmap | DirectDrawCaps.Complex; file.DefinitionFlags |= DirectDrawSurfaceDefinitionFlags.MipmapCount;
                    }

                    //Setup Pixel Format
                    switch (bitmap.Format)
                    {
                    case HaloBitmap.BitmapFormat.Dxt1: file.RgbBitCount = 0; file.FourCC = "DXT1"; file.PixelFormatFlags |= DirectDrawPixelFormatFlags.FourCC; break;

                    case HaloBitmap.BitmapFormat.Dxt3: file.RgbBitCount = 0; file.FourCC = "DXT3"; file.PixelFormatFlags |= DirectDrawPixelFormatFlags.FourCC; break;

                    case HaloBitmap.BitmapFormat.Dxt5: file.RgbBitCount = 0; file.FourCC = "DXT5"; file.PixelFormatFlags |= DirectDrawPixelFormatFlags.FourCC; break;

                    case HaloBitmap.BitmapFormat.V8u8: file.RgbBitCount = 16; file.PixelFormatFlags = DirectDrawPixelFormatFlags.VU; break;

                    default: file.RgbBitCount = (uint)bitmapFormat_GetBitCount(bitmap.Format); break;
                    }
                    uint aMask = 0, rMask = 0, gMask = 0, bMask = 0;
                    bitmapFormat_GetBitMask(bitmap.Format, out aMask, out rMask, out bMask, out gMask);
                    file.AlphaBitmask = aMask; file.RedBitmask = rMask; file.GreenBitmask = gMask; file.BlueBitmask = bMask;

                    //Setup Bits
                    switch (bitmap.Format)
                    {
                    case HaloBitmap.BitmapFormat.A8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaPixels; break;

                    case HaloBitmap.BitmapFormat.Y8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Luminance; break;

                    case HaloBitmap.BitmapFormat.Ay8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaPixels; break;

                    case HaloBitmap.BitmapFormat.G8b8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaLuminance; break;

                    case HaloBitmap.BitmapFormat.A8y8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.AlphaLuminance; break;

                    case HaloBitmap.BitmapFormat.R5g6b5: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Rgb; break;

                    case HaloBitmap.BitmapFormat.A4r4g4b4: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Argb; break;

                    case HaloBitmap.BitmapFormat.X8r8g8b8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Rgb; break;

                    case HaloBitmap.BitmapFormat.A8r8g8b8: file.PixelFormatFlags |= DirectDrawPixelFormatFlags.Argb; break;
                    }

                    //Prepare File Data
                    int mapWidth = (int)width, mapHeight = (int)height;
                    file.Data = new byte[bitmap.RawLengths[0]];
                    using (MemoryStream ds = new MemoryStream(file.Data))
                        using (MemoryStream ms = new MemoryStream(bitmap_LoadData(b, 0)))
                            using (BinaryWriter writer = new BinaryWriter(ds))
                                using (BinaryReader reader = new BinaryReader(ms))
                                    for (int i = 0; i <= bitmap.MipmapCount; i++)
                                    {
                                        byte[] data = reader.ReadBytes(bitmap_GetLength(bitmap.Format, mapWidth, mapHeight));
                                        if (data.Length > 0)
                                        {
                                            writer.Write(swizzled ? Swizzler.Swizzle(data, mapWidth, mapHeight, (int)depth, (int)file.RgbBitCount, swizzled) : data);
                                        }
                                        mapWidth /= 2; mapHeight /= 2;
                                    }

                    //Save
                    file.Save(string.Format(filename, b));
                }
            }
        }
示例#7
0
        protected override unsafe void OnSave( Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback )
		{
			DdsSaveConfigToken ddsToken = ( DdsSaveConfigToken )token;

			// We need to be able to feast on the goo inside..
			scratchSurface.Clear( ColorBgra.Transparent );

			using ( RenderArgs ra = new RenderArgs( scratchSurface ) )
			{
				input.Render( ra, true );
			}

			// Create the DDS file, and save it..
			DdsFile ddsFile = new DdsFile();
			ddsFile.Save( output, scratchSurface, ddsToken, callback );
		}
示例#8
0
        private void TattooGo_button_Click(object sender, EventArgs e)
        {
            float sortOrder;

            try
            {
                sortOrder = float.Parse(CASPsortOrder.Text);
            }
            catch
            {
                MessageBox.Show("Please enter a valid number for Sort Order in CAS");
                return;
            }
            if (String.CompareOrdinal(TattooName.Text, " ") <= 0)
            {
                MessageBox.Show("Please enter a name for the tattoo");
                return;
            }
            if (dds == null)
            {
                MessageBox.Show("Please select an image for the tattoo");
                return;
            }
            ulong  tatInstance;
            string tatName;

            if (TattooName.Text.IndexOf("uutattoo") < 0)
            {
                tatName = "uutattoo" + TattooName.Text;
            }
            else
            {
                tatName = TattooName.Text;
            }
            if (String.CompareOrdinal(TattooInstance.Text, " ") > 0)
            {
                if (!UInt64.TryParse(TattooInstance.Text, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out tatInstance))
                {
                    MessageBox.Show("Please enter a valid Tattoo Instance number in hexidecimal, or leave it blank");
                    return;
                }
            }
            else
            {
                tatInstance = FNVhash.FNV64(tatName);
            }

            PleaseWait_label.Visible = true;
            this.Refresh();

            uint  tatGroup     = FNVhash.FNV24(tatName);
            ulong txtcInstance = FNVhash.FNV64(tatName + "TattooTemplate_Top_diffuse");

            Package myPack;

            myPack = (Package)Package.NewPackage(0);

            NameMapResource.NameMapResource myMap = new NameMapResource.NameMapResource(0, null);
            myMap.Add(tatInstance, tatName);
            myMap.Add(tatGroup, tatName);
            myMap.Add(txtcInstance, tatName + "TattooTemplate_Top_diffuse");

            XmlDocument doc1 = PresetBuilder.presetXML(tatName, tatInstance, presets[0],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);
            XmlDocument doc2 = PresetBuilder.presetXML(tatName, tatInstance, presets[1],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);
            XmlDocument doc3 = PresetBuilder.presetXML(tatName, tatInstance, presets[2],
                                                       ChannelR_checkBox.Checked, ChannelG_checkBox.Checked, ChannelB_checkBox.Checked, ChannelA_checkBox.Checked);

            CASPartResource.CASPartResource myCasp;
            myCasp = new CASPartResource.CASPartResource(0, null);
            CASPartResource.CASPartResource.Preset pre1 = new CASPartResource.CASPartResource.Preset(0, null, doc1.OuterXml, 1);
            CASPartResource.CASPartResource.Preset pre2 = new CASPartResource.CASPartResource.Preset(0, null, doc2.OuterXml, 2);
            CASPartResource.CASPartResource.Preset pre3 = new CASPartResource.CASPartResource.Preset(0, null, doc3.OuterXml, 3);
            myCasp.Presets = new CASPartResource.CASPartResource.PresetList(null);
            myCasp.Presets.Add(pre1);
            myCasp.Presets.Add(pre2);
            myCasp.Presets.Add(pre3);
            myCasp.Unknown1     = tatName;
            myCasp.SortPriority = sortOrder;
            myCasp.Clothing     = ClothingType.TattooTemplate;
            myCasp.DataType     = DataTypeFlags.Body;
            myCasp.AgeGender    = new AgeGenderFlags(0, null, (CASPtodder_checkBox.Checked ? AgeFlags.Toddler : 0) |
                                                     (CASPchild_checkBox.Checked ? AgeFlags.Child : 0) | (CASPteen_checkBox.Checked ? AgeFlags.Teen : 0) |
                                                     (CASPadult_checkBox.Checked ? AgeFlags.YoungAdult | AgeFlags.Adult : 0) |
                                                     (CASPelder_checkBox.Checked ? AgeFlags.Elder : 0),
                                                     (CASPfemale_checkBox.Checked ? GenderFlags.Female : 0) | (CASPmale_checkBox.Checked ? GenderFlags.Male : 0),
                                                     0, 0);
            myCasp.ClothingCategory = ClothingCategoryFlags.Athletic | ClothingCategoryFlags.Career | ClothingCategoryFlags.Everyday |
                                      ClothingCategoryFlags.FireFighting | ClothingCategoryFlags.Formalwear | ClothingCategoryFlags.Makeover |
                                      ClothingCategoryFlags.MartialArts | ClothingCategoryFlags.Naked | ClothingCategoryFlags.Outerwear |
                                      ClothingCategoryFlags.SkinnyDippingTowel | ClothingCategoryFlags.Sleepwear | ClothingCategoryFlags.Swimwear |
                                      ClothingCategoryFlags.Singed | ClothingCategoryFlags.ValidForMaternity;
            myCasp.CasPart1Index         = 2;
            myCasp.CasPart2Index         = 2;
            myCasp.BlendInfoFatIndex     = 3;
            myCasp.BlendInfoFitIndex     = 4;
            myCasp.BlendInfoThinIndex    = 5;
            myCasp.BlendInfoSpecialIndex = 6;
            myCasp.OverlayPriority       = 2u;
            myCasp.VPXYIndexes           = new ByteIndexList(null);
            myCasp.VPXYIndexes.Add(7);
            myCasp.Diffuse1Indexes = new ByteIndexList(null);
            myCasp.Diffuse1Indexes.Add(8);
            myCasp.Specular1Indexes = new ByteIndexList(null);
            myCasp.Specular1Indexes.Add(9);
            myCasp.BONDIndexes = new ByteIndexList(null);
            myCasp.BONDIndexes.AddRange(new List <byte> {
                2, 2, 2, 2, 2
            });
            myCasp.Unknown4  = "bare";
            myCasp.TGIBlocks = new CountedTGIBlockList(null);
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.DDS, 0, tatInstance));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.XML, 0, 0xF7FC14B9EA85B390));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, 0, 0, 0));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0xCBE03A305F80FF50));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0xCBE032305F80F1F8));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0x540F4B31F0B42342));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.BBLN, 0, 0x82F02E48897E22B4));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.VPXY, 1, tatGroup));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, txtcInstance));
            myCasp.TGIBlocks.Add(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, 0xCBF29CE484222325));

            uint  fakeType     = (uint)tatInstance;
            uint  fakeGroup    = (uint)(tatInstance >> 32);
            ulong fakeInstance = (ulong)ResourceTypes.DDS << 32;

            TxtcResource.TxtcResource txtc = TattooTextureCompositor.TattooTxtc(new TGIBlock(0, null, fakeType, fakeGroup, fakeInstance));

            VPXY vpxy = new VPXY(0, null, 4, null, 2,
                                 new BoundingBox(0, null, new Vertex(0, null, -.0060f, 1.7157f, -.0060f), new Vertex(0, null, .0060f, 1.7277f, .0060f)),
                                 new byte[] { 0, 0, 0, 0 }, 0, 0, new TGIBlockList(null));
            GenericRCOLResource vpxyRcol = new GenericRCOLResource(0, null);

            vpxyRcol.Version      = 3;
            vpxyRcol.PublicChunks = 1;
            vpxyRcol.ChunkEntries = new GenericRCOLResource.ChunkEntryList(null);
            GenericRCOLResource.ChunkEntry vpxyChunk = new GenericRCOLResource.ChunkEntry(0, null, new TGIBlock(0, null, "ITG", (uint)ResourceTypes.VPXY, 1, tatGroup), vpxy);
            vpxyRcol.ChunkEntries.Add(vpxyChunk);
            IResourceIndexEntry rs = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.KEY, 0, tatInstance), myMap.Stream, true);

            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.CASP, 0, tatInstance), myCasp.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.TXTC, tatGroup, txtcInstance), txtc.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.VPXY, 1, tatGroup), vpxyRcol.Stream, true);
            rs.Compressed = (ushort)0xFFFF;
            MemoryStream ms = new MemoryStream();

            doc1.Save(ms);
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.XML, 0, tatInstance), ms, true);
            rs.Compressed = (ushort)0xFFFF;
            MemoryStream ms2 = new MemoryStream();

            dds.UseDXT          = false;
            dds.AlphaDepth      = 8;
            dds.GenerateMipmaps = true;
            dds.Save(ms2);
            rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.DDS, 0, tatInstance), ms2, true);
            rs.Compressed = (ushort)0xFFFF;
            if (thumbNail != null)
            {
                MemoryStream ms3 = new MemoryStream();
                thumbNail.Save(ms3, System.Drawing.Imaging.ImageFormat.Png);
                rs            = myPack.AddResource(new TGIBlock(0, null, (uint)ResourceTypes.THUM, 1, tatInstance), ms3, true);
                rs.Compressed = (ushort)0xFFFF;
            }

            PleaseWait_label.Visible = false;

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter          = PackageFilter;
            saveFileDialog1.Title           = "Save as a new package";
            saveFileDialog1.FileName        = TattooName.Text + ".package";
            saveFileDialog1.FilterIndex     = 1;
            saveFileDialog1.CheckFileExists = false;
            saveFileDialog1.CheckPathExists = true;
            saveFileDialog1.OverwritePrompt = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                myPack.SaveAs(saveFileDialog1.FileName);
            }
            ms.Dispose();
            ms2.Dispose();
        }
示例#9
0
 public static void DDS_To_DDS(string From_DDS_File, string To_DDS_File, DdsFileFormat Format)
 {
     System.IO.FileStream fileStream = new System.IO.FileStream(To_DDS_File, System.IO.FileMode.Create);
     DdsFile.Save(fileStream, Format, DdsErrorMetric.Perceptual, BC7CompressionMode.Slow, false, false, ResamplingAlgorithm.Bilinear, Load(From_DDS_File), null);
     fileStream.Close();
 }