コード例 #1
0
        private void SetArtwork(string imagePath, byte[] imageData)
        {
            // Get the size of the artwork
            if (imageData != null)
            {
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.StreamSource = new MemoryStream(imageData);
                bi.EndInit();
                // Use bi.PixelWidth and bi.PixelHeight instead of bi.Width and bi.Height:
                // bi.Width and bi.Height take DPI into account. We don't want that here.
                this.ArtworkSize = bi.PixelWidth + "x" + bi.PixelHeight;
            }
            else
            {
                this.ArtworkSize = string.Empty;
            }

            // Get the artwork data
            this.Artwork.SetValue(imagePath, imageData);

            this.ArtworkThumbnail = ImageOperations.ByteToBitmapImage(imageData, Convert.ToInt32(Constants.CoverLargeSize), Convert.ToInt32(Constants.CoverLargeSize));
            OnPropertyChanged(() => this.HasArtwork);
        }