Ejemplo n.º 1
0
        public static void ReplaceTexture(Image newImage, TextureListObject textureListObject)
        {
            ImageHeader   imageHeader   = textureListObject.imageHeader;
            PaletteHeader paletteHeader = textureListObject.paletteHeader;

            byte[] newPaletteData;
            byte[] newTextureData = TPL.ConvertToTextureMelee(newImage, textureListObject, out newPaletteData);

            if (newTextureData.Length != textureListObject.imageSize)
            {
                MessageBox.Show("Error: Selected image is not the same file size!");
                return;
            }

            if (paletteHeader != null && newPaletteData.Length > paletteHeader.colorCount0xC * 2)
            {
                MessageBox.Show(
                    "The selected image contains more colors than the original image. Please use no more than " + paletteHeader.colorCount0xC + " colors.");
                return;
            }

            Array.ConstrainedCopy(newTextureData, 0, file, (int)(imageHeader.imageOffset0x0 + dataOffset), newTextureData.Length);
            if (paletteHeader != null)
            {
                Array.ConstrainedCopy(newPaletteData, 0, file, (int)(paletteHeader.paletteOffset0x0 + dataOffset), Math.Min((paletteHeader.colorCount0xC * 2), newPaletteData.Length));
            }
            OpenDatFile(file, fileName, ref textureList);
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            openTextureDialog.InitialDirectory = Settings.Default.openTexturePath;
            openTextureDialog.FileName         = "";

            if (openTextureDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }


            Stream myStream = null;

            if ((myStream = openTextureDialog.OpenFile()) == null)
            {
                return;
            }
            var info = new FileInfo(openTextureDialog.FileName);

            Settings.Default.openTexturePath = Path.GetDirectoryName(info.FullName);

            Image             newImage       = new Bitmap(myStream);
            TextureListObject currentTexture = (TextureListObject)textureListBox.SelectedItem;
            int selectedTextureIndex         = textureListBox.SelectedIndex;

            DatFile.ReplaceTexture(newImage, currentTexture);
            textureListBox.SetSelected(selectedTextureIndex, true);
            textureListBox.Focus();
        }
Ejemplo n.º 3
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextureListObject tex = (TextureListObject)textureListBox.SelectedItem;

            if (tex != null)
            {
                buttonExportTexture.Enabled  = true;
                buttonReplaceTexture.Enabled = true;
            }
            else
            {
                buttonExportTexture.Enabled  = false;
                buttonReplaceTexture.Enabled = false;
            }
            texturePictureBox.Image = tex.imageBitmap;
            String colors = "";

            if (tex.paletteHeader != null)
            {
                colors = tex.paletteHeader.colorCount0xC.ToString();
            }
            textureInfoLabel.Text = "Size: " + tex.imageHeader.width0x4.ToString() + " x " + tex.imageHeader.height0x6.ToString() + "\nFormat: " + tex.imageHeader.imageFormatString + "\nColors: " + colors;
        }
Ejemplo n.º 4
0
        public static void ReplaceTexture(Image newImage, TextureListObject textureListObject)
        {
            ImageHeader imageHeader = textureListObject.imageHeader;
            PaletteHeader paletteHeader = textureListObject.paletteHeader;
            byte[] newPaletteData;
            byte[] newTextureData = TPL.ConvertToTextureMelee(newImage, textureListObject, out newPaletteData);

            if (newTextureData.Length != textureListObject.imageSize)
            {
                MessageBox.Show("Error: Selected image is not the same file size!");
                return;
            }

            if (paletteHeader != null && newPaletteData.Length > paletteHeader.colorCount0xC*2)
            {
                MessageBox.Show(
                    "The selected image contains more colors than the original image. Please use no more than " + paletteHeader.colorCount0xC + " colors.");
                return;
            }

            Array.ConstrainedCopy(newTextureData, 0, file, (int)(imageHeader.imageOffset0x0 + dataOffset), newTextureData.Length);
            if (paletteHeader != null) Array.ConstrainedCopy(newPaletteData, 0, file, (int)(paletteHeader.paletteOffset0x0 + dataOffset), Math.Min((paletteHeader.colorCount0xC * 2), newPaletteData.Length));
            OpenDatFile(file, fileName, ref textureList);
        }