Exemplo n.º 1
0
        /// <summary>
        /// Configures a new watermark, by calculating its offset and size depending on
        /// position and VideoStandard (Size of the video)
        /// </summary>
        /// <returns>The new configured watermark.</returns>
        /// <param name="position">Position.</param>
        /// <param name="videoStandard">Video standard.</param>
        public static Watermark ConfigureNewWatermark(WatermarkPosition position, VideoStandard videoStandard, Image image = null)
        {
            double videoWidth    = videoStandard.Width;
            double videoHeight   = videoStandard.Height;
            Image  originalImage = image ?? App.Current.ResourcesLocator.LoadEmbeddedImage(Constants.WATERMARK_RESOURCE_ID);

            double sizeChanged = (videoHeight * Sizes.WatermarkHeightNormalization) / originalImage.Height;
            int    newWidth    = (int)(originalImage.Width * sizeChanged);
            int    newHeight   = (int)(originalImage.Height * sizeChanged);

            Image newImage;

            if (image == null)
            {
                newImage = App.Current.ResourcesLocator.LoadEmbeddedImage(Constants.WATERMARK_RESOURCE_ID, newWidth, newHeight);
            }
            else
            {
                newImage = image.Scale(newWidth, newHeight);
            }
            double offsetX = 0;
            double offsetY = 0;

            switch (position)
            {
            case WatermarkPosition.TOP_LEFT:
                offsetX = Sizes.WatermarkPadding / videoWidth;
                offsetY = Sizes.WatermarkPadding / videoHeight;
                break;

            case WatermarkPosition.TOP_RIGHT:
                offsetX = (videoWidth - newImage.Width - Sizes.WatermarkPadding) / videoWidth;
                offsetY = Sizes.WatermarkPadding / videoHeight;
                break;

            case WatermarkPosition.BOTTOM_LEFT:
                offsetX = Sizes.WatermarkPadding / videoWidth;
                offsetY = (videoHeight - newImage.Height - Sizes.WatermarkPadding) / videoHeight;
                break;

            case WatermarkPosition.BOTTOM_RIGHT:
                offsetX = (videoWidth - newImage.Width - Sizes.WatermarkPadding) / videoWidth;
                offsetY = (videoHeight - newImage.Height - Sizes.WatermarkPadding) / videoStandard.Height;
                break;

            default:
                return(null);
            }
            return(new Watermark(newImage, Sizes.WatermarkHeightNormalization, offsetX, offsetY));
        }
Exemplo n.º 2
0
 public EncodingSettings(VideoStandard videoStandard, EncodingProfile encodingProfile,
                         EncodingQuality encodingQuality, uint fr_n, uint fr_d,
                         string outputFile, bool enableAudio, bool enableTitle,
                         uint titleSize, Watermark watermark)
 {
     VideoStandard   = videoStandard;
     EncodingProfile = encodingProfile;
     EncodingQuality = encodingQuality;
     Framerate_n     = fr_n;
     Framerate_d     = fr_d;
     OutputFile      = outputFile;
     TitleSize       = titleSize;
     EnableAudio     = enableAudio;
     EnableTitle     = enableTitle;
     Watermark       = watermark;
 }