コード例 #1
0
ファイル: DevelopRawRule.cs プロジェクト: zhaoyingju/resizer
        uint[] CheckGetSupported(MainForm form, bool supported, GetTriplet <uint> getter, DataEntry[] de, uint[] rgb)
        {
            uint[] value = null;
            try
            {
                uint r, g, b;
                getter(out r, out g, out b);
                if (supported)
                {
                    value = new uint[] { r, g, b };
                    if (rgb != null && (r != rgb[0] || g != rgb[1] || b != rgb[2]))
                    {
                        form.Add(this, getter.ToString(Resources._0_NotExpectedValue), de, new DataEntry(Resources.Expected, rgb), new DataEntry(Resources.Actual, value));
                    }
                }
                else
                {
                    form.Add(this, getter.ToString(Resources._0_ShouldFail), de, new DataEntry(Resources.Expected, WinCodecError.WINCODEC_ERR_UNSUPPORTEDOPERATION));
                }
            }
            catch (Exception e)
            {
                if (supported)
                {
                    form.Add(this, getter.ToString(Resources._0_Failed), de, new DataEntry(e));
                }
                else
                {
                    form.CheckHRESULT(this, WinCodecError.WINCODEC_ERR_UNSUPPORTEDOPERATION, e, de);
                }
            }

            return(value);
        }
コード例 #2
0
ファイル: DevelopRawRule.cs プロジェクト: zhaoyingju/resizer
        void CheckSetRgbWhitePointSupported(MainForm form, WinCodecError?error, IWICDevelopRaw raw, DataEntry[] de, Guid pixelFormatOriginal)
        {
            Notification[]            notifications = new Notification[] { new Notification(), new Notification(), null };
            GetTriplet <uint>         getter        = raw.GetWhitePointRGB;
            Action <uint, uint, uint> setter        = raw.SetWhitePointRGB;

            foreach (Notification n in notifications)
            {
                try
                {
                    raw.SetNotificationCallback(n);
                }
                catch (Exception e)
                {
                    form.Add(this, n == null ? e.TargetSite.ToString(Resources._0_Failed, "NULL") : e.TargetSite.ToString(Resources._0_Failed), de, new DataEntry(e));
                }

                uint r, g, b;
                r = g = b = uint.MaxValue;
                bool getSupported = false;
                try
                {
                    getter(out r, out g, out b);
                    getSupported = true;
                }
                catch
                {
                    break;
                }
                if (getSupported)
                {
                    try
                    {
                        notifications[0].Expect(WICRawChangeNotification.WICRawChangeNotification_RGBWhitePoint);
                        notifications[1].Expect(WICRawChangeNotification.WICRawChangeNotification_RGBWhitePoint);
                        setter(r, g, b);
                        if (error.HasValue)
                        {
                            form.Add(this, setter.ToString(Resources._0_ShouldFail), de, new DataEntry(Resources.Expected, error.Value));
                        }
                        else
                        {
                            if (n != null && !n.Notified)
                            {
                                form.Add(this, Resources.DevelopRawRule_NoNotification, de, new DataEntry(Resources.Actual, n.GetRaised()), new DataEntry(Resources.Expected, WICRawChangeNotification.WICRawChangeNotification_RGBWhitePoint), new DataEntry(Resources.Method, setter.ToString("{0}")), new DataEntry(Resources.Value, new uint[] { r, g, b }));
                            }
                            if (n != notifications[0] && notifications[0].Notified)
                            {
                                form.Add(this, Resources.DevelopRawRule_NotificationOnWrong, de, new DataEntry(Resources.Method, setter.ToString("{0}")), new DataEntry(Resources.Value, new uint[] { r, g, b }));
                            }

                            CheckGetSupported(form, true, getter, de, new uint[] { r, g, b });
                        }
                    }
                    catch (Exception e)
                    {
                        CheckGetSupported(form, true, getter, de, new uint[] { r, g, b });
                        if (error.HasValue)
                        {
                            form.CheckHRESULT(this, error.Value, e, de);
                        }
                        else
                        {
                            form.Add(this, setter.ToString(Resources._0_Failed), de, new DataEntry(e));
                        }
                    }
                }
                CheckPixelFormat(form, raw, de, pixelFormatOriginal);
            }
        }