From e0b347860efd3c9b97088117c1fb1f628c7fb6a0 Mon Sep 17 00:00:00 2001 From: Grigory Chudov Date: Sun, 21 Apr 2013 00:48:48 -0400 Subject: [PATCH] CUERipper: Preview large cover art --- CUERipper/frmCUERipper.Designer.cs | 2 ++ CUERipper/frmCUERipper.cs | 34 ++++++++++++++++++++++++++++++ CUERipper/frmCUERipper.resx | 4 ++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CUERipper/frmCUERipper.Designer.cs b/CUERipper/frmCUERipper.Designer.cs index 3b44a1f..dd76e83 100644 --- a/CUERipper/frmCUERipper.Designer.cs +++ b/CUERipper/frmCUERipper.Designer.cs @@ -715,6 +715,8 @@ namespace CUERipper this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.TabStop = false; this.pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick); + this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave); + this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); // // backgroundWorkerArtwork // diff --git a/CUERipper/frmCUERipper.cs b/CUERipper/frmCUERipper.cs index d625d14..2eb7e03 100644 --- a/CUERipper/frmCUERipper.cs +++ b/CUERipper/frmCUERipper.cs @@ -1590,6 +1590,40 @@ namespace CUERipper form.ShowDialog(this); resetEncoderModes(encoder); } + + private static Bitmap cropImage(Image imgToResize, Size boxSize, RectangleF srcRect) + { + Bitmap b = new Bitmap(boxSize.Width, boxSize.Height); + //area.Width / 2 - area.X, area.Height /2 - area.Y, area.Width, area.Height + Graphics g = Graphics.FromImage((Image)b); + g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; + g.DrawImage(imgToResize, new Rectangle(0, 0, boxSize.Width, boxSize.Height), srcRect, GraphicsUnit.Pixel); + g.Dispose(); + return b; + } + + private void pictureBox1_MouseMove(object sender, MouseEventArgs e) + { + if (currentAlbumArt < 0 || currentAlbumArt >= albumArt.Count || _config.advanced.coversSearch != CUEConfigAdvanced.CTDBCoversSearch.Large) + return; + + var isz = new RectangleF(0.0f, 0.0f, albumArt[currentAlbumArt].image.Width, albumArt[currentAlbumArt].image.Height); + float ratio = Math.Min(isz.Width / pictureBox1.ClientSize.Width, isz.Height / pictureBox1.ClientSize.Height); + ratio = Math.Min(ratio, 1.0f); + var rf = new RectangleF( + e.Location.X * (isz.Width / pictureBox1.ClientSize.Width - ratio), + e.Location.Y * (isz.Height / pictureBox1.ClientSize.Height - ratio), + pictureBox1.ClientSize.Width * ratio, + pictureBox1.ClientSize.Height * ratio); + pictureBox1.Image = cropImage(albumArt[currentAlbumArt].image, pictureBox1.ClientSize, rf); + } + + private void pictureBox1_MouseLeave(object sender, EventArgs e) + { + if (currentAlbumArt < 0 || currentAlbumArt >= albumArt.Count) + return; + pictureBox1.Image = albumArt[currentAlbumArt].image; + } } internal class BackgroundWorkerArtworkArgs diff --git a/CUERipper/frmCUERipper.resx b/CUERipper/frmCUERipper.resx index 40d6cad..e08791f 100644 --- a/CUERipper/frmCUERipper.resx +++ b/CUERipper/frmCUERipper.resx @@ -816,7 +816,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABy - CQAAAk1TRnQBSQFMAgEBBAEAAUwBAgFMAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CQAAAk1TRnQBSQFMAgEBBAEAAWwBAgFsAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAA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