Beispiel #1
0
 public static void SetQuality(bool bClickAdjustBtn, ImageQuality quality)
 {
     SetImageQuality(quality);
     //ApplyUIData();
     UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_SYSTEMSETTING_APPLYVEDIOSETTING, null);
     HighestSupportQuality = currData.currImageQuality;
 }
        public override bool TryConvertToJpegImageData(byte[] imageData, ImageQuality imageQuality, out byte[] jpegImageData)
        {
            string[] imageSharpImageFormats = new string[] { "jpeg", "bmp", "png", "gif" };
            string   imageFormat;

            if (this.TryGetImageFormat(imageData, out imageFormat) && imageSharpImageFormats.Contains(imageFormat.ToLower()))
            {
                using (Image imageSharp = Image.Load(imageData))
                {
                    imageSharp.Mutate(x => x.BackgroundColor(Color.White));

                    JpegEncoder options = new JpegEncoder
                    {
                        Quality = (int)imageQuality,
                    };

                    MemoryStream ms = new MemoryStream();
                    imageSharp.SaveAsJpeg(ms, options);

                    jpegImageData = ms.ToArray();
                }

                return(true);
            }

            jpegImageData = null;
            return(false);
        }
        public DocumentGenerator(ImageQuality imageQuality)
        {
            this.imageQuality = imageQuality;
            this.document     = new RadFixedDocument();

            this.GenerateDocumentContent();
        }
Beispiel #4
0
    void UpdateReslutUI(ImageQuality quality, ReslutImageFlags flag = ReslutImageFlags.None)
    {
        //PerformanceCheckUI_Reslut uiInstance = PerformanceCheckManager.Instance.flowShareData.ui_Reslut;
        //uiInstance.gameObject.SetActive(true);


        if (flag == ReslutImageFlags.OpenOhtersImageEffects)
        {
            //uiInstance.tips.text = "您的检测结果为<color=red>" + PerformanceCheckManager.GetImageQualityDesc(quality) + ",</color>由于您的计算机性能较高,系统为您开启了一些额外的渲染效果," +
            //           "您可以在<color=red>登入游戏后按[ESC]->视频设置</color>中修改您的选项。正在进入游戏.....";

            ImageSetting.Clear();
            EndPerformanceCheck();
        }
        else if (flag == ReslutImageFlags.NotSupportFullGoodImageEffect)
        {
            UpdateReslut_NotSupportGoodImangeEffect(quality);
        }
        else if (flag == ReslutImageFlags.NotSupportFullBestImageEffect)
        {
            UpdateReslut_NotSupportBestImangeEffect(quality);
        }
        else if (flag == ReslutImageFlags.NotSupportFullHighImageEffect)
        {
            UpdateReslut_NotSupportHighImangeEffect(quality);
        }
        else
        {
            //uiInstance.tips.text = "您的检测结果为<color=red>" + PerformanceCheckManager.GetImageQualityDesc(quality) + ",</color>" +
            //           "您可以在<color=red>登入游戏后按[ESC]->视频设置</color>中修改您的选项。正在进入游戏.....";

            ImageSetting.Clear();
            EndPerformanceCheck();
        }
    }
Beispiel #5
0
        public string GetImgSize(byte[] iByte, string filename, ImageQuality size)
        {
            string _url = string.Empty;

            try
            {
                MemoryStream ImageStream  = new MemoryStream(iByte);
                var          uploadParams = new ImageUploadParams()
                {
                    File           = new FileDescription(filename, ImageStream),
                    Transformation = new Transformation().Height((int)size).Crop("fit").AspectRatio(1.0),
                    PublicId       = filename,
                };
                var resp = GetNewConnection().Upload(uploadParams);
                if (resp.SecureUri != null)
                {
                    _url = resp.SecureUri.AbsoluteUri;
                }
                else
                {
                    Console.WriteLine(String.Format("INFO: Cloudinary: Response[{0}] : {1}", filename, resp.JsonObj.ToString()));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(String.Format("ERROR: Cloudinary[{0}]: {1}", filename, e.ToString()));
            }
            return(_url);
        }
Beispiel #6
0
    void UpdateReslut_NotSupportBestImangeEffect(ImageQuality quality)
    {
        //PerformanceCheckUI_Reslut uiInstance = PerformanceCheckManager.Instance.flowShareData.ui_Reslut;
        //uiInstance.tips.text = "您的检测结果为<color=red>" + PerformanceCheckManager.GetImageQualityDesc(quality) + ",</color>但由于你的计算机性能较低,一些额外的渲染效果没有开启,您可以从以下方案中选择一个";

        //uiInstance.ConfigTwoRoot.SetActive(true);
        //uiInstance.ConfigOneRoot.SetActive(true);

        //uiInstance.ConfigOneBtn.onClick.AddListener(NotSupportBestImangeEffect_ChooseDownResolution);
        //uiInstance.ConfigTwoBtn.onClick.AddListener(NotSupportBestImangeEffect_ChooseCloseImangeEffect);
        //currAutoSelect = NotSupportBestImangeEffect_ChooseDownResolution;
        //uiInstance.ConfigOneBtnDesc.text = "确认(" + AutoSelectTime + ")";
        //uiInstance.ConfigTwoBtnDesc.text = "确认";

        //int pixel = ImageSetting.GetResolutionPixels(ImageSetting.currResolution);

        ////计算出帧数差
        //float dealt = (PerformanceCheckManager.PassLevleFps - PerformanceCheck_FPS.currFPS);
        //dealt /= PerformanceCheckManager.PassLevleFps;

        //TargetResolution = ImageSetting.AdjustResolutionFromPixels(pixel, 1 - dealt);

        //uiInstance.ConfigOneDesc.text = "此方案,您将会<color=red>获得完整的画面效果</color>,但是您的游戏将会在<color=red>窗口模式下," +
        //                               "以" + TargetResolution + "分辨率</color>运行,您可以再在<color=red>登入游戏后按[ESC]->视频设置->全屏</color>以全屏模式运行游戏";

        //uiInstance.ConfigTwoDesc.text = "此方案您将在全屏模式下进行游戏,但是会<color=red>关闭图像后处理</color>来提升性能," +
        //                                "您可以再在<color=red>登入游戏后按[ESC]->视频设置->图像后处理</color>开启它";
        //WaitingSelect = true;
        NotSupportBestImangeEffect_ChooseCloseImangeEffect();
    }
Beispiel #7
0
        public ImageTypeRecord Get(string type, ImageQuality quality = ImageQuality.BestAvailable, bool acceptLower = true, bool mustHaveImage = false)
        {
            var typeName = type.ToUpper();
            var sorted   = ImageMappings.Where(r => r.Name == typeName).OrderByDescending(r => r.Quality);

            if (quality == ImageQuality.BestAvailable)
            {
                return(sorted.FirstOrDefault());
            }

            var exactMatch = sorted.SingleOrDefault(r => r.Quality == quality);

            if (exactMatch != null)
            {
                return(exactMatch);
            }

            // Don't have explicit size or have not asked for best available.
            if (acceptLower)
            {
                Debug.Assert(quality != ImageQuality.BestAvailable, "Must be an explicit quality");
                var newQuality = quality == ImageQuality.Large ? ImageQuality.Medium : ImageQuality.Small;
                if (newQuality != quality)
                {
                    return(Get(type, newQuality));
                }
            }

            return(mustHaveImage ? Get("Unknown", quality) : null);
        }
Beispiel #8
0
 private static void AdjustQuality(bool bClickAdjustBtn, ImageQuality quality)
 {
     //第一次进场景不需要弹窗直接更新,后续的才需要弹窗
     if (!FirstLoadScene && bClickAdjustBtn)
     {
         USpeedUI.TooltipAndDialog.UIDialogData data = new USpeedUI.TooltipAndDialog.UIDialogData(
             title: "系统设置",
             message: "已恢复系统默认设置",
             buttons: new UIWidgets.DialogActions()
         {
             { "调整", () =>
               {
                   SetQuality(bClickAdjustBtn, quality);
                   return(true);
               } },
             { "不调整", () => { return(true); } }
         }
             );
         UISystem.Instance.SendWndMessage(WndMsgID.WND_MSG_COMMON_DIALOG, data);
     }
     else if (FirstLoadScene)
     {
         SetQuality(bClickAdjustBtn, quality);
     }
 }
Beispiel #9
0
        public static void ViewImage(string url, ImageQuality quality)
        {
            void ViewImageInternal(string path)
            {
                string ext = Path.GetExtension(path);

                if (ImageUrl.ValidExtensions.Contains(ext))
                {
                    WindowsUtils.OpenAssociatedProgram(path);
                }
                else
                {
                    FormMessage.Error("Image Download", "Invalid file extension " + ext, FormMessage.OK);
                }
            }

            string file = Path.Combine(BrowserCache.CacheFolder, GetImageFileName(url) ?? Path.GetRandomFileName());

            if (FileUtils.FileExistsAndNotEmpty(file))
            {
                ViewImageInternal(file);
            }
            else
            {
                DownloadFileAuth(GetMediaLink(url, quality), file, () => {
                    ViewImageInternal(file);
                }, ex => {
                    FormMessage.Error("Image Download", "An error occurred while downloading the image: " + ex.Message, FormMessage.OK);
                });
            }
        }
Beispiel #10
0
        public void Register(string type, ImageQuality quality, string image)
        {
            Debug.Assert(quality != ImageQuality.BestAvailable, "Must use a specific size when registering");

            var typeName    = type.ToUpper();
            var imageRecord = Get(typeName, quality, false);

            var updated = false;

            if (imageRecord != null)
            {
                if (imageRecord.Image != image)
                {
                    imageRecord.Image = image;
                    updated           = true;
                }
            }
            else
            {
                ImageMappings.Add(new ImageTypeRecord(typeName, quality, image));
                updated = true;
            }

            if (updated)
            {
                OnPropertyChanged("ImageMappings");
            }
        }
Beispiel #11
0
        public ImageTypeRecord(string name, ImageQuality quality, string image)
        {
            this.name    = name;
            this.quality = quality;
            this.image   = image;

            DisplayName = name;
        }
Beispiel #12
0
        public DocumentGenerator(ImageSource imageSource, ImageQuality imageQuality)
        {
            this.imageSource  = imageSource;
            this.imageQuality = imageQuality;
            this.document     = new RadFixedDocument();

            this.AddPageWithImage();
        }
Beispiel #13
0
 public ImageLoadingOptions(double width, double height, bool fill, ImageQuality quality, bool cms)
 {
     this.FrameWidth  = width;
     this.FrameHeight = height;
     this.IsFill      = fill;
     this.Quality     = quality;
     this.CmsEnable   = cms;
 }
        public ImageTypeRecord(string name, ImageQuality quality, string image)
        {
            this.name = name;
            this.quality = quality;
            this.image = image;

            DisplayName = name;
        }
Beispiel #15
0
 private ImageLoadingOptions GenerateImageLoadOption(ImageQuality quality)
 {
     return(new ImageLoadingOptions(
                this.ViewWidth,
                this.ViewHeight,
                this.core.IsSlideshowResizeToFill,
                quality,
                this.core.IsCmsEnabled));
 }
Beispiel #16
0
    /// <summary>
    /// 设置图像等级
    /// </summary>
    /// <param name="quality"></param>
    public static void SetImageQuality(ImageQuality quality, bool bForce = false)
    {
        //if(OldImageQuality == quality)
        //{
        //    return;
        //}

        SetImageQualityData(quality);
        Apply(bForce);
    }
Beispiel #17
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            ImageQuality source = (ImageQuality)value;

            if (Enum.TryParse((string)parameter, out ImageQuality target))
            {
                return(source == target);
            }

            throw Ensure.Exception.NotSupported($"Not support converter parameter value '{parameter}'.");
        }
 public ImageRequest(string requestId, ImageRegion region, ImageSize size, ImageRotation rotation, ImageQuality quality, ImageFormat format, int maxWidth, int maxHeight, int maxArea)
 {
     Region    = region;
     Size      = size;
     Rotation  = rotation;
     Quality   = quality;
     Format    = format;
     RequestId = requestId;
     MaxArea   = maxArea;
     MaxWidth  = maxWidth;
     MaxHeight = maxHeight;
 }
 public ImageRequest(string requestId, ImageRegion region, ImageSize size, ImageRotation rotation, ImageQuality quality, ImageFormat format)
 {
     Region    = region;
     Size      = size;
     Rotation  = rotation;
     Quality   = quality;
     Format    = format;
     RequestId = requestId;
     MaxArea   = int.MaxValue;
     MaxWidth  = int.MaxValue;
     MaxHeight = int.MaxValue;
 }
Beispiel #20
0
        public static float DecodeCheckPSNR(string filename, Image <Rgba32> original)
        {
            using FileStream fs = File.OpenRead(filename);
            var ktx     = KtxFile.Load(fs);
            var decoder = new BcDecoder();

            using var img = decoder.Decode(ktx);
            var pixels  = original.GetPixelSpan();
            var pixels2 = img.GetPixelSpan();

            return(ImageQuality.PeakSignalToNoiseRatio(pixels, pixels2, true));
        }
Beispiel #21
0
        public static void DownloadImages(string[] urls, string username, ImageQuality quality)
        {
            if (urls.Length == 0)
            {
                return;
            }

            string firstImageLink = GetMediaLink(urls[0], quality);
            int    qualityIndex   = firstImageLink.IndexOf(':', firstImageLink.LastIndexOf('/'));

            string file = GetImageFileName(firstImageLink);
            string ext  = Path.GetExtension(file); // includes dot

            string[] fileNameParts = qualityIndex == -1 ? new string[] {
                Path.ChangeExtension(file, null)
            } : new string[] {
                username,
                Path.ChangeExtension(file, null),
                firstImageLink.Substring(qualityIndex + 1)
            };

            using (SaveFileDialog dialog = new SaveFileDialog {
                AutoUpgradeEnabled = true,
                OverwritePrompt = urls.Length == 1,
                Title = "Save image",
                FileName = $"{string.Join(" ", fileNameParts.Where(part => part.Length > 0))}{ext}",
                Filter = (urls.Length == 1 ? "Image" : "Images") + (string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
            }){
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    void OnFailure(Exception ex)
                    {
                        FormMessage.Error("Image Download", "An error occurred while downloading the image: " + ex.Message, FormMessage.OK);
                    }

                    if (urls.Length == 1)
                    {
                        BrowserUtils.DownloadFileAsync(firstImageLink, dialog.FileName, null, OnFailure);
                    }
                    else
                    {
                        string pathBase = Path.ChangeExtension(dialog.FileName, null);
                        string pathExt  = Path.GetExtension(dialog.FileName);

                        for (int index = 0; index < urls.Length; index++)
                        {
                            BrowserUtils.DownloadFileAsync(GetMediaLink(urls[index], quality), $"{pathBase} {index+1}{pathExt}", null, OnFailure);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Returns true if ImageSaveAsPDFMRCParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of ImageSaveAsPDFMRCParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ImageSaveAsPDFMRCParameters 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))
                 ) &&
                 (
                     Conformance == input.Conformance ||
                     Conformance.Equals(input.Conformance)
                 ) &&
                 (
                     ColorImageCompression == input.ColorImageCompression ||
                     ColorImageCompression.Equals(input.ColorImageCompression)
                 ) &&
                 (
                     BitonalImageCompression == input.BitonalImageCompression ||
                     BitonalImageCompression.Equals(input.BitonalImageCompression)
                 ) &&
                 (
                     ImageQuality == input.ImageQuality ||
                     ImageQuality.Equals(input.ImageQuality)
                 ) &&
                 (
                     DownscaleResolution == input.DownscaleResolution ||
                     DownscaleResolution.Equals(input.DownscaleResolution)
                 ) &&
                 (
                     PreserveSmoothing == input.PreserveSmoothing ||
                     PreserveSmoothing.Equals(input.PreserveSmoothing)
                 ) &&
                 (
                     FastWebView == input.FastWebView ||
                     FastWebView.Equals(input.FastWebView)
                 ) &&
                 (
                     JBIG2PMSThreshold == input.JBIG2PMSThreshold ||
                     JBIG2PMSThreshold.Equals(input.JBIG2PMSThreshold)
                 ));
        }
        public static void ViewImage(string url, ImageQuality quality)
        {
            DownloadTempImage(url, quality, path => {
                string ext = Path.GetExtension(path);

                if (ImageUrl.ValidExtensions.Contains(ext))
                {
                    App.SystemHandler.OpenAssociatedProgram(path);
                }
                else
                {
                    FormMessage.Error("Image Download", "Invalid file extension " + ext, FormMessage.OK);
                }
            });
        }
        public static void CopyImage(string url, ImageQuality quality)
        {
            DownloadTempImage(url, quality, path => {
                Image image;

                try{
                    image = Image.FromFile(path);
                }catch (Exception ex) {
                    FormMessage.Error("Copy Image", "An error occurred while copying the image: " + ex.Message, FormMessage.OK);
                    return;
                }

                ClipboardManager.SetImage(image);
            });
        }
Beispiel #25
0
        public static async Task<BitmapImage> LoadBitmapImage(SoundCloudTrack track, ImageQuality quality, DirectoryInfo albumDirectory)
        {
            var config = HurricaneSettings.Instance.Config;

            using (var client = new WebClient { Proxy = null })
            {
                var image = await ImageHelper.DownloadImage(client, string.Format(track.ArtworkUrl, GetQualityModifier(quality)));
                if (config.SaveCoverLocal)
                {
                    if (!albumDirectory.Exists) albumDirectory.Create();
                    await ImageHelper.SaveImage(image, string.Format("{0}_{1}", track.SoundCloudID, GetQualityModifier(quality)), albumDirectory.FullName);
                }
                return image;
            }
        }
Beispiel #26
0
 public bool TryGetImage
     (string path, ImageQuality quality, out ImageSourceContainer image)
 {
     if (this.TryGetImageData(path, quality, out var result))
     {
         if (result != null)
         {
             count++;
             image = result.GetImage(count);
             return(true);
         }
     }
     image = null;
     return(false);
 }
Beispiel #27
0
 public static string GetQualityModifier(ImageQuality quality)
 {
     switch (quality)
     {
         case ImageQuality.Small:
             return "large";  //100x100
         case ImageQuality.Medium:
             return "t300x300"; //300x300
         case ImageQuality.Large:
             return "crop"; //400x400
         case ImageQuality.Maximum:
             return "t500x500"; //500x500
         default:
             throw new ArgumentOutOfRangeException("quality");
     }
 }
Beispiel #28
0
        /// <summary>
        /// Returns true if ImageSaveAsPDFParameters instances are equal
        /// </summary>
        /// <param name="input">Instance of ImageSaveAsPDFParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ImageSaveAsPDFParameters 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))
                 ) &&
                 (
                     Conformance == input.Conformance ||
                     Conformance.Equals(input.Conformance)
                 ) &&
                 (
                     ColorImageCompression == input.ColorImageCompression ||
                     ColorImageCompression.Equals(input.ColorImageCompression)
                 ) &&
                 (
                     BitonalImageCompression == input.BitonalImageCompression ||
                     BitonalImageCompression.Equals(input.BitonalImageCompression)
                 ) &&
                 (
                     EnableColorDetection == input.EnableColorDetection ||
                     EnableColorDetection.Equals(input.EnableColorDetection)
                 ) &&
                 (
                     ImageQuality == input.ImageQuality ||
                     ImageQuality.Equals(input.ImageQuality)
                 ) &&
                 (
                     DownscaleResolution == input.DownscaleResolution ||
                     DownscaleResolution.Equals(input.DownscaleResolution)
                 ) &&
                 (
                     FastWebView == input.FastWebView ||
                     FastWebView.Equals(input.FastWebView)
                 ));
        }
        /// <summary>
        ///  Generate barcode and save on server
        /// </summary>
        /// <param name="name">The image name.</param>
        /// <param name="text">Barcode's text.</param>
        /// <param name="type">The barcode type.</param>
        /// <param name="format">The image format.</param>
        /// <param name="codeLocation">Property of the barcode.</param>
        /// <param name="grUnit">Measurement of barcode properties.</param>
        /// <param name="autoSize">Sets if barcode size will be updated automatically.</param>
        /// <param name="barHeight">Height of the bar.</param>
        /// <param name="imageHeight">Height of the image.</param>
        /// <param name="imageWidth">Width of the image.</param>
        /// <param name="imageQuality">Determines quality of the barcode image.</param>
        /// <param name="rotAngle">Angle of barcode orientation.</param>
        /// <param name="topMargin">Top margin.</param>
        /// <param name="bottomMargin">Bottom margin.</param>
        /// <param name="leftMargin">Left margin.</param>
        /// <param name="rightMargin">Right margin.</param>
        /// <param name="enableChecksum">Sets if checksum will be generated.</param>
        /// <param name="storage">Image's storage.</param>
        /// <param name="folder">Image's folder.</param>
        /// <param name="resolutionX">Horizontal resolution in DPI. Default is 96</param>
        /// <param name="resolutionY">Vertical resolution in DPI. Default is 96</param>
        /// <param name="dimensionX">Smallest width of barcode unit (bar or space). Default is 0.7</param>
        /// <param name="dimensionY">Smallest height of barcode unit (for 2D barcodes). Default is 2</param>
        public void GenerateBarCodeAndSaveOnServer(string name, string text, BarCodeType type,
                                                   float barHeight, float imageHeight, float imageWidth, float rotAngle,
                                                   float topMargin, float bottomMargin, float leftMargin, float rightMargin, string storage,
                                                   string folder,
                                                   BarCodeImageFormat format = BarCodeImageFormat.PNG, CodeLocation codeLocation = CodeLocation.Below, GrUnit grUnit = GrUnit.MM,
                                                   bool autoSize = true, ImageQuality imageQuality = ImageQuality.Default, EnableChecksum enableChecksum = EnableChecksum.No,
                                                   float resolutionX = 96, float resolutionY = 96, double dimensionX = 0.7, float dimensionY = 2)
        {
            // PUT 	barcode/{name}/generate?appSid={appSid}&text={text}&type={type}&format={format}&resolutionX={resolutionX}&resolutionY={resolutionY}&dimensionX={dimensionX}&dimensionY={dimensionY}&codeLocation={codeLocation}&grUnit={grUnit}&autoSize={autoSize}&barHeight={barHeight}&imageHeight={imageHeight}&imageWidth={imageWidth}&imageQuality={imageQuality}&rotAngle={rotAngle}&topMargin={topMargin}&bottomMargin={bottomMargin}&leftMargin={leftMargin}&rightMargin={rightMargin}&enableChecksum={enableChecksum}&storage={storage}&folder={folder}

            string apiUrl = string.Format(@"barcode/{0}/generate?text={1}&type={2}&format={3}&resolutionX={4}&resolutionY={5}&dimensionX={6}&dimensionY={7}&codeLocation={8}&grUnit={9}&autoSize={10}&barHeight={11}&imageHeight={12}&imageWidth={13}&imageQuality={14}&rotAngle={15}&topMargin={16}&bottomMargin={17}&leftMargin={18}&rightMargin={19}&enableChecksum={20}&storage={21}&folder={22}",
                                            name, text, type, format, resolutionX, resolutionY, dimensionX, dimensionY, codeLocation, grUnit, autoSize, barHeight,
                                            imageHeight, imageWidth, imageQuality, rotAngle, topMargin, bottomMargin, leftMargin, rightMargin, enableChecksum,
                                            storage, folder);

            ServiceController.Put(apiUrl, AppSid, AppKey);
        }
Beispiel #30
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (ImageQuality != null)
         {
             hashCode = hashCode * 59 + ImageQuality.GetHashCode();
         }
         if (ImageSupportedResolutions != null)
         {
             hashCode = hashCode * 59 + ImageSupportedResolutions.GetHashCode();
         }
         return(hashCode);
     }
 }
        /// <summary>
        ///  Generate barcode and save on server
        /// </summary>
        /// <param name="name">The image name.</param>
        /// <param name="text">Barcode's text.</param>
        /// <param name="type">The barcode type.</param>
        /// <param name="format">The image format.</param>
        /// <param name="codeLocation">Property of the barcode.</param>
        /// <param name="grUnit">Measurement of barcode properties.</param>
        /// <param name="autoSize">Sets if barcode size will be updated automatically.</param>
        /// <param name="barHeight">Height of the bar.</param>
        /// <param name="imageHeight">Height of the image.</param>
        /// <param name="imageWidth">Width of the image.</param>
        /// <param name="imageQuality">Determines quality of the barcode image.</param>
        /// <param name="rotAngle">Angle of barcode orientation.</param>
        /// <param name="topMargin">Top margin.</param>
        /// <param name="bottomMargin">Bottom margin.</param>
        /// <param name="leftMargin">Left margin.</param>
        /// <param name="rightMargin">Right margin.</param>
        /// <param name="enableChecksum">Sets if checksum will be generated.</param>
        /// <param name="storage">Image's storage.</param>
        /// <param name="folder">Image's folder.</param>
        /// <param name="resolutionX">Horizontal resolution in DPI. Default is 96</param>
        /// <param name="resolutionY">Vertical resolution in DPI. Default is 96</param>
        /// <param name="dimensionX">Smallest width of barcode unit (bar or space). Default is 0.7</param>
        /// <param name="dimensionY">Smallest height of barcode unit (for 2D barcodes). Default is 2</param>
        public void GenerateBarCodeAndSaveOnServer(string name, string text, BarCodeType type,
                                                   float barHeight, float imageHeight, float imageWidth, float rotAngle,
                                                   float topMargin, float bottomMargin, float leftMargin, float rightMargin, string storage,
                                                   string folder,
                                                   BarCodeImageFormat format = BarCodeImageFormat.PNG, CodeLocation codeLocation = CodeLocation.Below, GrUnit grUnit = GrUnit.MM,
                                                   bool autoSize             = true, ImageQuality imageQuality = ImageQuality.Default, EnableChecksum enableChecksum = EnableChecksum.No,
                                                   float resolutionX         = 96, float resolutionY           = 96, double dimensionX = 0.7, float dimensionY = 2)
        {
            // PUT  barcode/{name}/generate?appSid={appSid}&text={text}&type={type}&format={format}&resolutionX={resolutionX}&resolutionY={resolutionY}&dimensionX={dimensionX}&dimensionY={dimensionY}&codeLocation={codeLocation}&grUnit={grUnit}&autoSize={autoSize}&barHeight={barHeight}&imageHeight={imageHeight}&imageWidth={imageWidth}&imageQuality={imageQuality}&rotAngle={rotAngle}&topMargin={topMargin}&bottomMargin={bottomMargin}&leftMargin={leftMargin}&rightMargin={rightMargin}&enableChecksum={enableChecksum}&storage={storage}&folder={folder}

            string apiUrl = string.Format(@"barcode/{0}/generate?text={1}&type={2}&format={3}&resolutionX={4}&resolutionY={5}&dimensionX={6}&dimensionY={7}&codeLocation={8}&grUnit={9}&autoSize={10}&barHeight={11}&imageHeight={12}&imageWidth={13}&imageQuality={14}&rotAngle={15}&topMargin={16}&bottomMargin={17}&leftMargin={18}&rightMargin={19}&enableChecksum={20}&storage={21}&folder={22}",
                                          name, text, type, format, resolutionX, resolutionY, dimensionX, dimensionY, codeLocation, grUnit, autoSize, barHeight,
                                          imageHeight, imageWidth, imageQuality, rotAngle, topMargin, bottomMargin, leftMargin, rightMargin, enableChecksum,
                                          storage, folder);

            ServiceController.Put(apiUrl, AppSid, AppKey);
        }
        private static void DownloadTempImage(string url, ImageQuality quality, Action <string> process)
        {
            string file = Path.Combine(BrowserCache.CacheFolder, TwitterUrls.GetImageFileName(url) ?? Path.GetRandomFileName());

            if (FileUtils.FileExistsAndNotEmpty(file))
            {
                process(file);
            }
            else
            {
                DownloadFileAuth(TwitterUrls.GetMediaLink(url, quality), file, () => {
                    process(file);
                }, ex => {
                    FormMessage.Error("Image Download", "An error occurred while downloading the image: " + ex.Message, FormMessage.OK);
                });
            }
        }
Beispiel #33
0
        private bool TryGetImageData
            (string path, ImageQuality quality, out ImageBufferItem result)
        {
            if (path == null)
            {
                result = null;
                return(false);
            }

            /*
             #if DEBUG
             * if (this.thumbNailImages.Count > 0)
             * {
             *  result = this.thumbNailImages.First().Value;
             *  if (result != null)
             *  {
             *      return true;
             *  }
             * }
             #endif*/

            var key = path;

            if (quality == ImageQuality.ThumbNail)
            {
                return(this.thumbNailImages.TryGetOrRemove(key, out result));
            }

            if (this.images.TryGetOrRemoveWithQuality(key, quality, out result))
            {
                return(true);
            }


            if (quality == ImageQuality.LowQuality)
            {
                if (this.thumbNailImages.TryGetOrRemove(key, out result))
                {
                    return(true);
                }
            }

            result = null;
            return(false);
        }
Beispiel #34
0
        public void EnumFieldsTest()
        {
            IsoSpeedEnum     iso          = IsoSpeedEnum.iso640;
            ApertureEnum     aperture     = ApertureEnum.f72;
            ExposalEnum      exposal      = ExposalEnum.t6;
            ImageQualityEnum imageQuality = ImageQualityEnum.PPT_sRAW1;

            ConfigureMockCamera(null, null, null, new IsoSpeedEnum[] { }, new ApertureEnum[] { }, new ExposalEnum[] { }, new ImageQualityEnum[] { }, iso, aperture, exposal, imageQuality);

            CameraInfo cameraInfo = new CameraInfo(_camera);

            Assert.AreEqual(IsoSpeed.With(iso), cameraInfo.CurrentIsoSpeed);
            Assert.AreEqual(Aperture.With(aperture), cameraInfo.CurrentAperture);
            Assert.AreEqual(Exposal.With(exposal), cameraInfo.CurrentExposal);
            Assert.AreEqual(ImageQuality.With(imageQuality), cameraInfo.CurrentImageQuality);

            _mockery.VerifyAllExpectationsHaveBeenMet();
        }
Beispiel #35
0
        public ImageTypeRecord Get(string type, ImageQuality quality = ImageQuality.BestAvailable, bool acceptLower = true, bool mustHaveImage = false)
        {
            var typeName = type.ToUpper();
            var sorted = ImageMappings.Where(r => r.Name == typeName).OrderByDescending(r => r.Quality);

            if (quality == ImageQuality.BestAvailable)
            {
                return sorted.FirstOrDefault();
            }

            var exactMatch = sorted.SingleOrDefault(r => r.Quality == quality);
            if (exactMatch != null)
            {
                return exactMatch;
            }

            // Don't have explicit size or have not asked for best available.
            if (acceptLower)
            {
                Debug.Assert(quality != ImageQuality.BestAvailable, "Must be an explicit quality");
                var newQuality = quality == ImageQuality.Large ? ImageQuality.Medium : ImageQuality.Small;
                if (newQuality != quality)
                {
                    return Get(type, newQuality);
                }
            }

            return (mustHaveImage) ? Get("Unknown", quality) : null;
        }
Beispiel #36
0
        public async static Task<BitmapImage> GetImage(ImageQuality imagequality, bool saveimage, DirectoryInfo directory, PlayableBase track, bool trimtrackname, bool useArtist = true)
        {
            string apikey = SensitiveInformation.LastfmKey;

            string title = track.Title;
            string artist = useArtist ? track.Artist : string.Empty;
            if (trimtrackname) title = TrimTrackTitle(track.Title);

            string url = Uri.EscapeUriString(string.Format("http://ws.audioscrobbler.com/2.0/?method=track.search&track={0}{1}&api_key={2}", title.ToEscapedUrl(), !string.IsNullOrEmpty(artist) ? "&artist=" + artist.ToEscapedUrl() : string.Empty, apikey));
            using (WebClient web = new WebClient() { Proxy = null })
            {
                string result = await web.DownloadStringTaskAsync(new Uri(url));

                using (StringReader sr = new StringReader(result))
                {
                    XmlSerializer xmls = new XmlSerializer(typeof(lfm));
                    var item = (lfm)xmls.Deserialize(sr);
                    if (item.results.trackmatches.Length > 0)
                    {
                        var foundtrack = item.results.trackmatches[0];
                        url = Uri.EscapeUriString(string.Format("http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key={2}&track={0}&artist={1}", foundtrack.name, foundtrack.artist, apikey));
                        result = await web.DownloadStringTaskAsync(url);

                        using (StringReader srtrackinformation = new StringReader(result))
                        {
                            var trackinfo = (lfm)xmls.Deserialize(srtrackinformation);
                            if (trackinfo.track.album != null && trackinfo.track.album.image != null && trackinfo.track.album.image.Length > 0)
                            {
                                string imageurl = GetImageLink(trackinfo.track.album.image, imagequality);

                                if (imageurl != null && !imageurl.EndsWith("default_album_medium.png") && !imageurl.EndsWith("[unknown].png")) //We don't want the default album art
                                {
                                    BitmapImage img = await ImageHelper.DownloadImage(web, imageurl);
                                    string album;
                                    if (string.IsNullOrEmpty(trackinfo.track.album.title))
                                    {
                                        album = string.IsNullOrEmpty(track.Album) ? title : track.Album;
                                    }
                                    else { album = trackinfo.track.album.title; }
                                    if (saveimage) await ImageHelper.SaveImage(img, album, directory.FullName);

                                    return img;
                                }
                            }

                            if (directory.Exists)
                            {
                                foreach (var file in directory.GetFiles("*.png"))
                                {
                                    if (artist.ToEscapedFilename().ToLower() == Path.GetFileNameWithoutExtension(file.FullName).ToLower())
                                    {
                                        var img = new BitmapImage(new Uri(file.FullName));
                                        img.Freeze();
                                        return img;
                                    }
                                }
                            }

                            if (trackinfo.track.artist != null && !string.IsNullOrEmpty(trackinfo.track.artist.mbid))
                            {
                                url = string.Format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&mbid={0}&api_key={1}", trackinfo.track.artist.mbid, apikey);
                            }
                            else if (trackinfo.track.artist != null && !string.IsNullOrEmpty(trackinfo.track.artist.name))
                            {
                                url = string.Format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={0}&api_key={1}", trackinfo.track.artist.name, apikey);
                            }
                            else if (!string.IsNullOrEmpty(artist))
                            {
                                url = string.Format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={0}&autocorrect=1&api_key={1}", artist, apikey);
                            }

                            if (string.IsNullOrEmpty(url)) return null;
                            result = await web.DownloadStringTaskAsync(Uri.EscapeUriString(url));
                            using (StringReader srartist = new StringReader(result))
                            {
                                lfm artistinfo = (lfm)xmls.Deserialize(srartist);
                                if (artistinfo.artist != null && artistinfo.artist.image != null && artistinfo.artist.image.Length > 0)
                                {
                                    string imageurl = GetImageLink(artistinfo.artist.image, imagequality);
                                    if (imageurl == null) return null;
                                    if (!imageurl.EndsWith("default_album_medium.png") && !imageurl.EndsWith("[unknown].png")) //We don't want the default album art
                                    {
                                        BitmapImage img = await ImageHelper.DownloadImage(web, imageurl);
                                        string artistname;
                                        if (string.IsNullOrEmpty(artistinfo.artist.name))
                                        {
                                            artistname = string.IsNullOrEmpty(artist) ? track.Title : artist;
                                        }
                                        else { artistname = artistinfo.artist.name; }
                                        if (saveimage) await ImageHelper.SaveImage(img, artistname, directory.FullName);

                                        return img;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return null;
        }
Beispiel #37
0
 protected static string GetImageLink(lfmTrackAlbumImage[] image, ImageQuality quality)
 {
     if (image.Length == 1) return image[0].Value;
     switch (quality)
     {
         case ImageQuality.Small:
             return image.First().Value;
         case ImageQuality.Medium:
         case ImageQuality.Large:
             var items = image.Where((x) => x.size == (quality == ImageQuality.Large ? "large" : "medium"));
             if (items.Any()) return items.First().Value;
             break;
     }
     return image.Last().Value;
 }
        private void RescanImageQuality()
        {
            FileInfo fileInfo;
            ImageQuality imgQuality;  // Collect the image properties for for the 2nd pass...
            List<ImageQuality> imgQualityList = new List<ImageQuality>();

            // TODO:
            // MAKE DB UPDATE EFFICIENT
            var bgw = new BackgroundWorker() { WorkerReportsProgress = true };
            bgw.DoWork += (ow, ea) =>
            {   // this runs on the background thread; its written as an anonymous delegate
                //We need to invoke this to allow updates on the UI
                this.Dispatcher.Invoke(new Action(() =>
                {
                    ;
                    // First, change the UIprovide some feedback
                    //this.txtblockFeedback.Text += "Step 1/2: Examining images..." + Environment.NewLine;
                }));
                int count = dbData.dataTable.Rows.Count;
                int j = 1;
                for (int i = 0; i < count; i++)
                {
                    fileInfo = new FileInfo(System.IO.Path.Combine(dbData.FolderPath, dbData.dataTable.Rows[i][Constants.FILE].ToString()));

                    imgQuality = new ImageQuality();                            // We will store the various image properties here
                    imgQuality.FileName = dbData.dataTable.Rows[i][Constants.FILE].ToString();
                    imgQuality.ID = Int32.Parse(dbData.dataTable.Rows[i][Constants.ID].ToString());
                    imgQuality.OldImageQuality = dbData.dataTable.Rows[i][Constants.IMAGEQUALITY].ToString();

                    // If its not a valid image, say so and go onto the next one.
                    if (!imgQuality.OldImageQuality.Equals(Constants.IMAGEQUALITY_OK) && !imgQuality.OldImageQuality.Equals(Constants.IMAGEQUALITY_DARK))
                    {
                        imgQuality.NewImageQuality = "";
                        imgQuality.Update = false;
                        bgw.ReportProgress(0, imgQuality);
                        continue;
                    }

                    // Ok, we only have valid images at this point
                    try
                    {
                        // Get the image (if its there), get the new dates/times, and add it to the list of images to be updated
                        // Note that if the image can't be created, we will just to the catch.
                        imgQuality.Bmap = BitmapFrame.Create(new Uri(fileInfo.FullName), BitmapCreateOptions.None, BitmapCacheOption.None);

                        imgQuality.NewImageQuality = (PixelBitmap.IsDark(imgQuality.Bmap, this.darkPixelThreshold, this.darkPixelRatio, out this.darkPixelRatioFound, out this.isColor)) ? Constants.IMAGEQUALITY_DARK : Constants.IMAGEQUALITY_OK;
                        imgQuality.isColor = this.isColor;
                        imgQuality.DarkPixelRatioFound = this.darkPixelRatioFound;
                        if (imgQuality.OldImageQuality.Equals(imgQuality.NewImageQuality))
                        {
                            imgQuality.Update = false;
                        }
                        else
                        {
                            imgQuality.Update = true;
                            imgQualityList.Add(imgQuality);
                            dbData.RowSetValueFromID(Constants.IMAGEQUALITY, imgQuality.NewImageQuality, imgQuality.ID);
                        }
                    }
                    catch // Image isn't there
                    {
                        imgQuality.Update = false;
                    }
                    j++;
                    bgw.ReportProgress(0, imgQuality);
                }
            };
            bgw.ProgressChanged += (o, ea) =>
            {
                // this gets called on the UI thread
                ImageQuality iq = (ImageQuality)ea.UserState;
                this.img.Source = iq.Bmap;

                this.lblImageName.Content = iq.FileName;
                this.lblOriginalClassification.Content = iq.OldImageQuality;
                this.lblNewClassification.Content = iq.NewImageQuality;
                this.lblDarkPixelRatio.Content = String.Format("{0,3:##0}%", 100 * this.darkPixelRatio);
                this.lblRatioFound.Content = String.Format("{0,3:##0}", 100 * iq.DarkPixelRatioFound);

                if (iq.isColor) // color image
                {
                    this.lblThresholdMessage.Text = "Color image - therefore not dark";
                    this.txtPercent.Visibility = Visibility.Hidden;
                    this.lblRatioFound.Content = "";
                }
                else
                {
                    this.lblThresholdMessage.Text = "of the image pixels are darker than the threshold";
                    this.txtPercent.Visibility = Visibility.Visible;
                }

                // Size the bar to show how many pixels in the current image are at least as dark as that color
                this.RectDarkPixelRatioFound.Width = FeedbackCanvas.ActualWidth * iq.DarkPixelRatioFound;
                if (this.RectDarkPixelRatioFound.Width < 6) this.RectDarkPixelRatioFound.Width = 6; // Just so something is always visible
                this.RectDarkPixelRatioFound.Height = FeedbackCanvas.ActualHeight;
            };
            bgw.RunWorkerCompleted += (o, ea) =>
            {
                DisplayImageAndDetails();
                TimelapseWindow owner = this.Owner as TimelapseWindow;
                owner.MenuItemImageCounts_Click(null, null);
            };
            bgw.RunWorkerAsync();
        }
 /// <summary>
 /// Optimizes the specified raw image.
 /// </summary>
 /// <param name="rawImage">The raw image.</param>
 /// <param name="imageFormat">The image format.</param>
 /// <param name="quality">The quality.</param>
 /// <returns>System.Drawing.Image.</returns>
 public Image Optimize(Image rawImage, ImageFormat imageFormat, ImageQuality quality)
 {
     return Optimize(rawImage, imageFormat, (long)quality);
 }
Beispiel #40
0
 private static ImageSource CreateImageSource(string resourceImagePath, ImageQuality? imageQuality = null)
 {
     using (Stream stream = GetResourceStream(resourceImagePath))
     {
         if (imageQuality.HasValue)
         {
             return new ImageSource(stream, imageQuality.Value);
         }
         else
         {
             return new ImageSource(stream);
         }
     }
 }
Beispiel #41
0
        public void Register(string type, ImageQuality quality, string image)
        {
            Debug.Assert(quality != ImageQuality.BestAvailable, "Must use a specific size when registering");

            var typeName = type.ToUpper();
            var imageRecord = Get(typeName, quality, false);

            var updated = false;
            if (imageRecord != null)
            {
                if (imageRecord.Image != image)
                {
                    imageRecord.Image = image;
                    updated = true;
                }
            }
            else
            {
                ImageMappings.Add(new ImageTypeRecord(typeName, quality, image));
                updated = true;
            }

            if (updated)
            {
                OnPropertyChanged("ImageMappings");
            }
        }
        private void ReportProgress(ImageQuality imageQuality)
        {
            this.Image.Source = imageQuality.Bitmap;
            this.FileName.Content = imageQuality.FileName;
            this.FileName.ToolTip = this.FileName.Content;

            this.OriginalClassification.Content = imageQuality.OldImageQuality;
            this.NewClassification.Content = imageQuality.NewImageQuality;
            this.DarkPixelRatio.Content = String.Format("{0,3:##0}%", 100.0 * this.darkPixelRatio);
            this.RatioFound.Content = String.Format("{0,3:##0}", 100.0 * imageQuality.DarkPixelRatioFound);

            if (imageQuality.IsColor)
            {
                this.ThresholdMessage.Text = "Color - therefore not dark";
                this.RatioFound.Content = String.Empty;
            }
            else
            {
                this.ThresholdMessage.Text = "% of pixels are darker than the threshold";
            }

            // size the bar to show how many pixels in the current image are at least as dark as that color
            this.RectDarkPixelRatioFound.Width = this.FeedbackCanvas.ActualWidth * imageQuality.DarkPixelRatioFound;
            if (this.RectDarkPixelRatioFound.Width < 6)
            {
                this.RectDarkPixelRatioFound.Width = 6; // Just so something is always visible
            }
            this.RectDarkPixelRatioFound.Height = this.FeedbackCanvas.ActualHeight;

            // update file scroll bar position
            this.ScrollImages.Value = imageQuality.FileIndex - 1;
        }
        /// <summary>
        /// Redo image quality calculations with current thresholds for all images selected.  Updates the database.
        /// </summary>
        private async Task BeginUpdateImageQualityForAllSelectedImagesAsync()
        {
            List<ImageRow> selectedFiles = this.database.Files.ToList();
            this.ApplyDoneButton.Content = "_Done";
            this.ApplyDoneButton.IsEnabled = false;
            this.DarkPixelRatioThumb.IsEnabled = false;
            this.DarkThreshold.IsEnabled = false;
            this.PreviousFile.IsEnabled = false;
            this.NextFile.IsEnabled = false;
            this.ScrollImages.IsEnabled = false;
            this.ResetButton.IsEnabled = false;

            IProgress<ImageQuality> updateStatus = new Progress<ImageQuality>(this.ReportProgress);
            await Task.Run(() =>
            {
                TimeSpan desiredRenderInterval = TimeSpan.FromSeconds(1.0 / Constant.ThrottleValues.DesiredMaximumImageRendersPerSecondDefault);
                DateTime mostRecentStatusDispatch = DateTime.UtcNow - desiredRenderInterval;
                object renderLock = new object();

                int fileIndex = 0;
                List<ColumnTuplesWithWhere> filesToUpdate = new List<ColumnTuplesWithWhere>();
                Parallel.ForEach(
                    new SequentialPartitioner<ImageRow>(selectedFiles),
                    Utilities.GetParallelOptions(Environment.ProcessorCount), 
                    (ImageRow file, ParallelLoopState loopState) =>
                    {
                        if (this.stop)
                        {
                            loopState.Break();
                        }

                        // if it's not a valid image, say so and go onto the next one.
                        int currentFileIndex = Interlocked.Increment(ref fileIndex);
                        ImageQuality imageQuality = new ImageQuality(file);
                        if ((imageQuality.OldImageQuality != FileSelection.Ok) && (imageQuality.OldImageQuality != FileSelection.Dark))
                        {
                            imageQuality.FileIndex = currentFileIndex;
                            imageQuality.NewImageQuality = null;
                            updateStatus.Report(imageQuality);
                            return;
                        }

                        try
                        {
                            // find the new image quality and add file to the update list
                            // See remarks in CarnassialWindow.xaml.cs about synchronous loading.
                            imageQuality.Bitmap = file.LoadBitmapAsync(this.database.FolderPath).GetAwaiter().GetResult().AsWriteable();
                            imageQuality.FileIndex = currentFileIndex;
                            imageQuality.NewImageQuality = imageQuality.Bitmap.IsDark(this.darkPixelThreshold, this.darkPixelRatio, out this.darkPixelRatioFound, out this.isColor);
                            imageQuality.IsColor = this.isColor;
                            imageQuality.DarkPixelRatioFound = this.darkPixelRatioFound;
                            if (imageQuality.OldImageQuality != imageQuality.NewImageQuality.Value)
                            {
                                filesToUpdate.Add(new ColumnTuplesWithWhere(new List<ColumnTuple> { new ColumnTuple(Constant.DatabaseColumn.ImageQuality, imageQuality.NewImageQuality.Value.ToString()) }, file.ID));
                            }
                        }
                        catch (Exception exception)
                        {
                            // file isn't there?
                            Debug.Fail("Exception while assessing image quality.", exception.ToString());
                        }

                        DateTime utcNow = DateTime.UtcNow;
                        if (utcNow - mostRecentStatusDispatch > desiredRenderInterval)
                        {
                            lock (renderLock)
                            {
                                if (utcNow - mostRecentStatusDispatch > desiredRenderInterval)
                                {
                                    mostRecentStatusDispatch = utcNow;
                                    updateStatus.Report(imageQuality);
                                }
                            }
                        }
                    });

                    this.database.UpdateFiles(filesToUpdate);
                });

            await this.DisplayImageAndDetailsAsync();
            this.ApplyDoneButton.IsEnabled = true;
            this.CancelStopButton.IsEnabled = false;
        }
Beispiel #44
0
 public ImageTypeRecord(string name, ImageQuality quality, string image)
 {
     _name = name;
     _quality = quality;
     _image = image;
 }
Beispiel #45
0
 public Stream GetImage(string id, ImageQuality quality)
 {
     try
     {
         Console.WriteLine("Getting " + id + " in " + quality);
         var path = Imagedir + quality + "/" + id + ".png";
         return new FileStream(path, FileMode.Open);
     }
     catch (FileNotFoundException)
     {
         return null;
     }
 }
Beispiel #46
0
		public extern static  uint CreateImage(ImageFormat format, int width, int height, ImageQuality allowedQuality);
 /// <summary>
 /// Optimizes the specified image format based on the specified quality
 /// </summary>
 /// <param name="image">The image.</param>
 /// <param name="imageFormat">The image format.</param>
 /// <param name="quality">The quality.</param>
 /// <returns>Image.</returns>
 public static Image Optimize(this Image image, ImageFormat imageFormat, ImageQuality quality)
 {
     ImageManipulation imageManipulation = new ImageManipulation();
     return imageManipulation.Optimize(image, imageFormat, quality);
 }