private void ComboBox_CI_ColType_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem selItem = (ComboItem)ComboBox_ColType.SelectedItem;
            string    id      = Conversions.ToString(selItem.Tag);

            LabelX_MaxPixels.Text = $"Maximal Pixels: {TextureManager.GetMaxPixls(N64Graphics.StringCodec(id))}";
            if (!loadingtexItemSettings)
            {
                UpdateTextureListItemSettings(id);
            }
        }
        private void LoadN64TextureFormatTypes()
        {
            ComboBox_ColType.SuspendLayout();
            ComboBox_ColType.Items.Clear();
            var eType = typeof(N64Codec);
            var names = Enum.GetNames(eType);

            int[] values = (int[])Enum.GetValues(eType);
            for (int i = 0, loopTo = names.Count() - 2; i <= loopTo; i++)
            {
                var item = new ComboItem();
                item.Text = names[i];
                item.Tag  = N64Graphics.CodecString((N64Codec)values[i]);
                ComboBox_ColType.Items.Add(item);
            }

            ComboBox_ColType.ResumeLayout();
        }
Ejemplo n.º 3
0
        private void button6_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderOpen = new FolderBrowserDialog();

            if (folderOpen.ShowDialog() == DialogResult.OK)
            {
                foreach (string file in Directory.GetFiles(folderOpen.SelectedPath, "*.c"))
                {
                    string[]    fileData = File.ReadAllLines(file);
                    List <byte> byteList = new List <byte>();

                    //past the intro start at 1
                    for (int currentLine = 1; currentLine < fileData.Length - 2; currentLine++)
                    {
                        string thisLine = fileData[currentLine];

                        string[] itemArray = thisLine.Split(',');

                        foreach (var currentItem in itemArray)
                        {
                            if (currentItem.Length > 0)
                            {
                                string editedItem = currentItem.Replace("0x", "");
                                editedItem = editedItem.Replace("\"", "");
                                byteList.Add(Convert.ToByte(editedItem, 16));
                            }
                        }
                    }



                    string outPath = Path.Combine(Path.GetDirectoryName(file), "Output");



                    int addressAlign = 4 - (byteList.Count % 4);
                    if (addressAlign == 4)
                    {
                        addressAlign = 0;
                    }
                    for (int align = 0; align < addressAlign; align++)
                    {
                        byteList.Add(0xFF);
                    }

                    byte[] byteArray = byteList.ToArray();
                    Directory.CreateDirectory(outPath);
                    outPath = Path.Combine(outPath, Path.GetFileName(file));
                    File.WriteAllBytes(outPath + ".data.bin", byteArray);
                    TM64_Geometry mk = new TM64_Geometry();

                    try
                    {
                        byte[] textureData = mk.decompressMIO0(byteArray);


                        int    width, height = 0;
                        byte[] voidBytes = new byte[0];

                        if (textureData.Length == 0x800)
                        {
                            width  = 32;
                            height = 32;

                            Bitmap   exportBitmap   = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                            Graphics graphicsBitmap = Graphics.FromImage(exportBitmap);
                            N64Graphics.RenderTexture(graphicsBitmap, textureData, voidBytes, 0, width, height, 1, N64Codec.RGBA16, N64IMode.AlphaCopyIntensity);

                            string texturePath = (outPath + ".png");

                            exportBitmap.Save(texturePath, ImageFormat.Png);
                        }
                        else
                        {
                            width  = 32;
                            height = 64;

                            Bitmap   exportBitmap   = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                            Graphics graphicsBitmap = Graphics.FromImage(exportBitmap);
                            N64Graphics.RenderTexture(graphicsBitmap, textureData, voidBytes, 0, width, height, 1, N64Codec.RGBA16, N64IMode.AlphaCopyIntensity);

                            string texturePath = (outPath + ".32x64.png");

                            exportBitmap.Save(texturePath, ImageFormat.Png);

                            width  = 64;
                            height = 32;

                            exportBitmap   = new Bitmap(width, height, PixelFormat.Format32bppArgb);
                            graphicsBitmap = Graphics.FromImage(exportBitmap);
                            N64Graphics.RenderTexture(graphicsBitmap, textureData, voidBytes, 0, width, height, 1, N64Codec.RGBA16, N64IMode.AlphaCopyIntensity);

                            texturePath = (outPath + ".64x32.png");

                            exportBitmap.Save(texturePath, ImageFormat.Png);
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
            }
        }