private void cbSourceSound_CheckedChanged(object sender, EventArgs e)
        {
            if (cbSourceSound.Checked)
            {
                tbAudioFile.Text = "Internal Sound";

                if (Lz77.IsLz77Compressed(sourceSound))
                {
                    Lz77 l = new Lz77(); sourceSound = l.Decompress(sourceSound);
                }

                foreach (Label thisLabel in gbWaveInfo.Controls)
                {
                    if (thisLabel.Name.ToLower().Contains("value"))
                    {
                        thisLabel.ForeColor = System.Drawing.Color.Black;
                        thisLabel.Text      = "Gathering";
                    }
                }

                bwGatherInfo.RunWorkerAsync(sourceSound);

                //this.Size = new System.Drawing.Size(510, 220);
                this.Size = new System.Drawing.Size(gbWaveInfo.Location.X + gbWaveInfo.Size.Width + 15, this.Size.Height);
            }
            else
            {
                if (tbAudioFile.Text == "Internal Sound")
                {
                    tbAudioFile.Text = string.Empty;
                }

                //this.Size = new System.Drawing.Size(358, 220);
                this.Size = new System.Drawing.Size(btnCancel.Location.X + btnCancel.Size.Width + 15, this.Size.Height);
            }
        }
Beispiel #2
0
        public Bitmap Decode()
        {
            MemoryStream Stream = new MemoryStream();

            Open().CopyTo(Stream);
            Stream.Position = 0;

            if (Compressed && SteamVersion.Value)
            {
                Stream = new MemoryStream(LZSSDecompress(Stream));
            }
            else if (Compressed)
            {
                var          Decompressor = new Lz77();
                MemoryStream Buffer       = new MemoryStream();
                Decompressor.Decompress(Stream).CopyTo(Buffer);
                Stream.Close();
                Stream = Buffer;
            }

            Bitmap Output;

            if (SteamVersion.Value)
            {
                Output = new Bitmap(TexSize.Width, TexSize.Height);
                byte[] Buffer = Stream.ToArray();
                fixed(void *pAddr = &Buffer[0])
                {
#if DEBUG
                    System.Diagnostics.Debug.Assert(Buffer.Length == TexSize.Width * TexSize.Height);
#endif
                    uint *pPixels = (uint *)pAddr;
                    int   Stride  = TexSize.Width;
                    for (int i = 0; i < Buffer.Length / 4; i++, pPixels++)
                    {
                        int X = i % Stride;
                        int Y = i / Stride;

                        unchecked
                        {
                            uint ARGB = *pPixels;

                            //ABGR => ARGB
                            ARGB = (ARGB & 0xFF00FF00) | ((ARGB & 0x00FF0000) >> 8 * 2) | ((ARGB & 0x000000FF) << 8 * 2);

                            Output.SetPixel(X, Y, Color.FromArgb((int)ARGB));
                        }
                    }
                }
            }
            else
            {
                Output = Image.FromStream(Stream) as Bitmap;
            }

            Stream.Close();

            TexSize = Output.Size;

            if (Tiled)
            {
                Output = Untile(Output);
            }

            return(Output);
        }