Exemplo n.º 1
0
        /// <summary>Test for load thumbnail function</summary>
        private void buttonThumbnail_Click(object sender, EventArgs e)
        {
            try
            {
                using (OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog())
                {
                    openFileDialog.Filter   = "WebP files (*.webp)|*.webp";
                    openFileDialog.FileName = "";
                    if (openFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        string pathFileName = openFileDialog.FileName;

                        byte[] rawWebP = File.ReadAllBytes(pathFileName);
                        using (WebP webp = new WebP())
                            this.pictureBox.Image = webp.Thumbnail(rawWebP, 200, 150);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\nIn WebPExample.buttonThumbnail_Click", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }