Esempio n. 1
0
 private static void DrawImage(MagickWand destination, MagickWand source, float x, float y, float width, float height)
 {
     source.CurrentImage.ResizeImage(Convert.ToInt32(width), Convert.ToInt32(height));
     OverlayHelper.DrawImage(destination, source, x, y);
 }
Esempio n. 2
0
 public static void DrawImage(MagickWand destination, MagickWand source, Rectangle destinationRect, Rectangle sourceRect)
 {
     source.CurrentImage.CropImage(sourceRect.Width, sourceRect.Height, sourceRect.X, sourceRect.Y);
     OverlayHelper.DrawImage(destination, source, destinationRect);
 }
Esempio n. 3
0
 public static void DrawImage(MagickWand destination, MagickWand source, Rectangle rect)
 {
     OverlayHelper.DrawImage(destination, source, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height);
 }
        protected async Task <MagickWand> EnhanceImageAsyncInternal(IHasImages item, MagickWand originalImage, ImageType imageType, int imageIndex)
        {
            Logger.Debug("SoundCloudOverlayEnhancer will treat {0}", new object[] { item.PrimaryImagePath });

            Point point = new Point(0, 0);

            var folderItem = item as Folder;

            if (imageType != ImageType.Primary || folderItem == null || folderItem.SourceType != SourceType.Channel)
            {
                return(null);
            }

            var overlayType = GetOverlayFromFolderId(folderItem.ExternalId);

            string str = Plugin.Instance.GetExtractedResourceFilePath(overlayType);

            var width  = originalImage.CurrentImage.Width;
            var height = originalImage.CurrentImage.Height;

            if (File.Exists(str))
            {
                try
                {
                    var newImage = OverlayHelper.GetNewColorImage("#c9c9c9", width, height);

                    ////using (var saturation = new MagickWand(width, height, new PixelWand("#202020", 0.5)))
                    ////{
                    ////    originalImage.CurrentImage.CompositeImage(saturation, CompositeOperator.SaturateCompositeOp, 0, 0);
                    ////}

                    newImage.CurrentImage.CompositeImage(originalImage, CompositeOperator.SoftLightCompositeOp, point.X, point.Y);

                    using (MagickWand overlayWand = new MagickWand(str))
                    {
                        if (overlayWand.CurrentImage.Height != originalImage.CurrentImage.Height)
                        {
                            // our images are always square, so:
                            overlayWand.CurrentImage.ResizeImage(height, height);
                        }

                        using (var overlayShadowed = overlayWand.CloneMagickWand())
                        {
                            ////using (var whitePixelWand = new PixelWand(ColorName.White))
                            ////{
                            ////    overlayShadowed.CurrentImage.BackgroundColor = whitePixelWand;
                            ////    overlayShadowed.CurrentImage.ShadowImage(80, 5, 5, 5);
                            ////    overlayShadowed.CurrentImage.CompositeImage(overlayWand, CompositeOperator.CopyCompositeOp, 0, 0);
                            ////}

                            newImage.CurrentImage.CompositeImage(overlayShadowed, CompositeOperator.OverCompositeOp, point.X, point.Y);
                        }
                    }

                    return(newImage);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    this.Logger.ErrorException("Error loading overlay: {0}", exception, overlayType);
                }
            }
            else
            {
                this.Logger.Warn(string.Concat("SoundCloud - Undefined overlay type: ", overlayType), new object[0]);
            }

            return(originalImage);
        }