コード例 #1
0
        /// <summary>
        /// Returns true if ImageSaveAsTIFFParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of ImageSaveAsTIFFParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ImageSaveAsTIFFParameters input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     FileId == input.FileId ||
                     (FileId != null &&
                      FileId.Equals(input.FileId))
                     ) &&
                 (
                     PageRange == input.PageRange ||
                     (PageRange != null &&
                      PageRange.Equals(input.PageRange))
                 ) &&
                 (
                     Compression == input.Compression ||
                     Compression.Equals(input.Compression)
                 ) &&
                 (
                     JpegQuality == input.JpegQuality ||
                     JpegQuality.Equals(input.JpegQuality)
                 ) &&
                 (
                     UseCMYK == input.UseCMYK ||
                     UseCMYK.Equals(input.UseCMYK)
                 ));
        }
コード例 #2
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (FileId != null)
         {
             hashCode = hashCode * 59 + FileId.GetHashCode();
         }
         if (PageRange != null)
         {
             hashCode = hashCode * 59 + PageRange.GetHashCode();
         }
         hashCode = hashCode * 59 + Compression.GetHashCode();
         hashCode = hashCode * 59 + JpegQuality.GetHashCode();
         hashCode = hashCode * 59 + UseCMYK.GetHashCode();
         return(hashCode);
     }
 }
コード例 #3
0
        /// <summary>
        /// Returns true if PdfSaveAsTIFFParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of PdfSaveAsTIFFParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PdfSaveAsTIFFParameters input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     FileId == input.FileId ||
                     (FileId != null &&
                      FileId.Equals(input.FileId))
                     ) &&
                 (
                     PageRange == input.PageRange ||
                     (PageRange != null &&
                      PageRange.Equals(input.PageRange))
                 ) &&
                 (
                     Compression == input.Compression ||
                     Compression.Equals(input.Compression)
                 ) &&
                 (
                     JpegQuality == input.JpegQuality ||
                     JpegQuality.Equals(input.JpegQuality)
                 ) &&
                 (
                     UseCMYK == input.UseCMYK ||
                     UseCMYK.Equals(input.UseCMYK)
                 ) &&
                 (
                     Resolution == input.Resolution ||
                     Resolution.Equals(input.Resolution)
                 ) &&
                 (
                     RenderFormFields == input.RenderFormFields ||
                     RenderFormFields.Equals(input.RenderFormFields)
                 ) &&
                 (
                     KeepRasterPDFResolution == input.KeepRasterPDFResolution ||
                     KeepRasterPDFResolution.Equals(input.KeepRasterPDFResolution)
                 ));
        }
コード例 #4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (FileId != null)
         {
             hashCode = hashCode * 59 + FileId.GetHashCode();
         }
         if (PageRange != null)
         {
             hashCode = hashCode * 59 + PageRange.GetHashCode();
         }
         hashCode = hashCode * 59 + Compression.GetHashCode();
         hashCode = hashCode * 59 + JpegQuality.GetHashCode();
         hashCode = hashCode * 59 + Resolution.GetHashCode();
         hashCode = hashCode * 59 + RenderFormFields.GetHashCode();
         hashCode = hashCode * 59 + KeepRasterPDFResolution.GetHashCode();
         return(hashCode);
     }
 }
コード例 #5
0
        /// <summary>
        /// Method for making screenshots.
        /// </summary>
        /// <param name="filepath">
        ///  Path for screenshots.
        /// </param>
        /// <param name="fileName">
        /// File name to save.
        /// </param>
        /// <param name="jpegQuality">
        ///
        /// </param>
        public void MakePrintScreen(string filepath, string fileName, JpegQuality jpegQuality)
        {
            if (filepath == null)
            {
                throw new ArgumentNullException(nameof(filepath));
            }
            if (fileName == null)
            {
                throw new ArgumentNullException(nameof(fileName));
            }
            if (!Enum.IsDefined(typeof(JpegQuality), jpegQuality))
            {
                throw new ArgumentOutOfRangeException(nameof(jpegQuality),
                                                      "Value should be defined in the JpegQuality enum.");
            }

            var widthResolution  = GetSystemMetrics(SystemMetric.SM_CXSCREEN);
            var heightResolution = GetSystemMetrics(SystemMetric.SM_CYSCREEN);
            var bmp = new Bitmap(widthResolution, heightResolution, PixelFormat.Format32bppArgb);

            using (var captureGraphic = Graphics.FromImage(bmp))
            {
                captureGraphic.CopyFromScreen(0, 0, 0, 0, bmp.Size);
                ImageCodecInfo encode = GetEncoderInfo("image/jpeg");
                try
                {
                    var param = new EncoderParameters(1);
                    param.Param[0] = new EncoderParameter(Encoder.Quality, (long)jpegQuality);
                    bmp.Save(filepath + fileName, encode, param);
                }
                catch (ArgumentNullException e)
                {
                    //  MessageBox.Show(e.ToString());
                }
            }
        }
コード例 #6
0
        /// <inheritdoc />
        /// <summary>
        /// Save given image to blob storage.
        /// </summary>
        /// <param name="imageUrl">Image url.</param>
        /// <param name="image">Image object.</param>
        /// <param name="format">Image object format.</param>
        /// <param name="jpegQuality">Target image quality.</param>
        public virtual async Task SaveImageAsync(string imageUrl, Image <Rgba32> image, IImageFormat format, JpegQuality jpegQuality)
        {
            using (var blobStream = _storageProvider.OpenWrite(imageUrl))
                using (var stream = new MemoryStream())
                {
                    if (format.DefaultMimeType == "image/jpeg")
                    {
                        var options = new JpegEncoder
                        {
                            Quality = (int)jpegQuality
                        };

                        image.Save(stream, options);
                    }
                    else
                    {
                        image.Save(stream, format);
                    }
                    stream.Position = 0;
                    await stream.CopyToAsync(blobStream);
                }
        }
コード例 #7
0
 /// <summary>
 /// Save given image to blob storage.
 /// </summary>
 /// <param name="imageUrl">Image url.</param>
 /// <param name="image">Image object.</param>
 /// <param name="format">Image object format.</param>
 /// <param name="quality">Target image quality.</param>
 public virtual async Task SaveImageAsync(string imageUrl, Image image, ImageFormat format, JpegQuality quality)
 {
     using (var blobStream = StorageProvider.OpenWrite(imageUrl))
         using (var stream = new MemoryStream())
         {
             if (format.Guid == ImageFormat.Jpeg.Guid)
             {
                 var codecInfo     = ImageCodecInfo.GetImageEncoders().FirstOrDefault(c => c.FormatID == format.Guid);
                 var encoderParams = new EncoderParameters
                 {
                     Param = new[] { new EncoderParameter(Encoder.Quality, (int)quality) }
                 };
                 image.Save(stream, codecInfo, encoderParams);
             }
             else
             {
                 image.Save(stream, format);
             }
             stream.Position = 0;
             await stream.CopyToAsync(blobStream);
         }
 }
コード例 #8
0
ファイル: ImageFunctions.cs プロジェクト: ppucik/DOZP
        public static void SaveJpeg(BitmapSource source, string fileName, JpegQuality quality = JpegQuality.High)
        {
            if (source == null) throw new ArgumentNullException("source");
            if (String.IsNullOrEmpty(fileName)) throw new ArgumentNullException("fileName");
            if ((int)quality < 1 || (int)quality > 100) throw new ArgumentOutOfRangeException("quality");
            //if (File.Exists(fileName)) File.Delete(fileName);

            if (source.Format != PixelFormats.Rgb24) source = new FormatConvertedBitmap(source, PixelFormats.Rgb24, null, 0);

            BitmapMetadata metadata = GetBitmapMetadata("jpg");

            using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                encoder.QualityLevel = (int)quality;
                encoder.Frames.Add(BitmapFrame.Create(source, null, metadata, null));
                encoder.Save(fs);
                fs.Close();
            }
        }