コード例 #1
0
        public override void AnalyzeImage(IBitmapCore image)
        {
            int points = 100;	// TODO: Make option

            ToneStageOperationParameters pm = (ToneStageOperationParameters)Parameters;
            if (pm.AutoDarkTone)
            {
                mAnalyzedDarkTone = image.FindDarkTone(
                    pm.LightTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoDarkCenter,
                    pm.AutoDarkRadius,
                    points);
                toneselectorwidget1.SelectedDarkTone = mAnalyzedDarkTone;
                toneselectorwidget1.DarkToneSelectorSymbol = ToneSelectorSymbol.Dot;
            }
            if (pm.AutoLightTone)
            {
                mAnalyzedLightTone = image.FindLightTone(
                    pm.DarkTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoLightCenter,
                    pm.AutoLightRadius,
                    points);
                toneselectorwidget1.SelectedLightTone = mAnalyzedLightTone;
                toneselectorwidget1.LightToneSelectorSymbol = ToneSelectorSymbol.Dot;
            }
        }
コード例 #2
0
        public override void OnDo(IBitmapCore hdp)
        {
            BrightnessStageOperationParameters pm = (BrightnessStageOperationParameters)Parameters;


            Console.WriteLine("Calculating current median...");
            double median = hdp.AmplitudeFindMedian();

            Console.WriteLine("Setting brightness...");

            if (pm.Normalize)
            {
                hdp.AmplitudeMultiply(pm.Brightness * 0.5 / median,
                                      delegate(double progress) {
                    return(OnReportProgress(progress));
                }
                                      );
            }
            else
            {
                hdp.AmplitudeMultiply(pm.Brightness,
                                      delegate(double progress) {
                    return(OnReportProgress(progress));
                }
                                      );
            }
        }
コード例 #3
0
        public override void OnDo(IBitmapCore hdp)
        {
            BrightnessStageOperationParameters pm = (BrightnessStageOperationParameters)Parameters;

            Console.WriteLine("Calculating current median...");
            double median = hdp.AmplitudeFindMedian();

            Console.WriteLine("Setting brightness...");

            if (pm.Normalize)
            {
                hdp.AmplitudeMultiply(pm.Brightness * 0.5 / median,
                    delegate (double progress) {
                        return OnReportProgress(progress);
                    }
                );
            }
            else
            {
                hdp.AmplitudeMultiply(pm.Brightness,
                    delegate (double progress) {
                        return OnReportProgress(progress);
                    }
                );
            }
        }
コード例 #4
0
        public override void AnalyzeImage(IBitmapCore image)
        {
            int points = 100;                   // TODO: Make option

            ToneStageOperationParameters pm = (ToneStageOperationParameters)Parameters;

            if (pm.AutoDarkTone)
            {
                mAnalyzedDarkTone = image.FindDarkTone(
                    pm.LightTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoDarkCenter,
                    pm.AutoDarkRadius,
                    points);
                toneselectorwidget1.SelectedDarkTone       = mAnalyzedDarkTone;
                toneselectorwidget1.DarkToneSelectorSymbol = ToneSelectorSymbol.Dot;
            }
            if (pm.AutoLightTone)
            {
                mAnalyzedLightTone = image.FindLightTone(
                    pm.DarkTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoLightCenter,
                    pm.AutoLightRadius,
                    points);
                toneselectorwidget1.SelectedLightTone       = mAnalyzedLightTone;
                toneselectorwidget1.LightToneSelectorSymbol = ToneSelectorSymbol.Dot;
            }
        }
コード例 #5
0
        public override void OnDo(IBitmapCore hdp)
        {
            LimitSizeStageOperationParameters pm = (LimitSizeStageOperationParameters)Parameters;

            Console.WriteLine("Limiting size...");

            double w = hdp.Width, h = hdp.Height;

            if (pm.LimitWidth && w > pm.NewWidth)
            {
                h *= pm.NewWidth / w;
                w = pm.NewWidth;
            }

            if (pm.LimitHeight && h > pm.NewHeight)
            {
                w *= pm.NewHeight / h;
                h = pm.NewHeight;
            }

            if (pm.LimitWidth || pm.LimitHeight)
            {
                hdp.Resize((int)w, (int)h, 3,
                    delegate (double progress) {
                        return OnReportProgress(progress);
                    });
            }
        }
コード例 #6
0
        public override void OnDo(IBitmapCore hdp)
        {
            LimitSizeStageOperationParameters pm = (LimitSizeStageOperationParameters)Parameters;

            Console.WriteLine("Limiting size...");

            double w = hdp.Width, h = hdp.Height;

            if (pm.LimitWidth && w > pm.NewWidth)
            {
                h *= pm.NewWidth / w;
                w  = pm.NewWidth;
            }

            if (pm.LimitHeight && h > pm.NewHeight)
            {
                w *= pm.NewHeight / h;
                h  = pm.NewHeight;
            }

            if (pm.LimitWidth || pm.LimitHeight)
            {
                hdp.Resize((int)w, (int)h, 3,
                           delegate(double progress) {
                    return(OnReportProgress(progress));
                });
            }
        }
 public override void AnalyzeImage(IBitmapCore image)
 {
     double median = image.AmplitudeFindMedian();
     Application.Invoke(delegate {
         median_label.Text = median.ToString("0.00");
     });
 }
コード例 #8
0
        public override void AnalyzeImage(IBitmapCore image)
        {
            double median = image.AmplitudeFindMedian();

            Application.Invoke(delegate {
                median_label.Text = median.ToString("0.00");
            });
        }
コード例 #9
0
ファイル: ExtendedStage.cs プロジェクト: radtek/CatEye
 protected virtual void OnOperationDefrozen()
 {
     mFrozenImage = null;
     if (OperationDefrozen != null)
     {
         OperationDefrozen(this, EventArgs.Empty);
     }
 }
コード例 #10
0
        public override void OnDo(IBitmapCore hdp)
        {
            BlackPointStageOperationParameters pm = (BlackPointStageOperationParameters)Parameters;

            hdp.CutBlackPoint(pm.Cut, blur_radius, 0.2, 1024, 0.01,
                     delegate (double progress) {
                return OnReportProgress(progress);
            });
        }
コード例 #11
0
        public override void OnDo(IBitmapCore hdp)
        {
            BlackPointStageOperationParameters pm = (BlackPointStageOperationParameters)Parameters;

            hdp.CutBlackPoint(pm.Cut, blur_radius, 0.2, 1024, 0.01,
                              delegate(double progress) {
                return(OnReportProgress(progress));
            });
        }
コード例 #12
0
        public override void OnDo(IBitmapCore hdp)
        {
            SaturationStageOperationParameters pm = (SaturationStageOperationParameters)Parameters;

            Console.WriteLine("Basic operations: applying saturation...");
            hdp.ApplySaturation(pm.Saturation,
                                delegate(double progress) {
                return(OnReportProgress(progress));
            }
                                );
        }
コード例 #13
0
        public override void OnDo(IBitmapCore hdp)
        {
            SaturationStageOperationParameters pm = (SaturationStageOperationParameters)Parameters;

            Console.WriteLine("Basic operations: applying saturation...");
            hdp.ApplySaturation(pm.Saturation,
                delegate (double progress) {
                    return OnReportProgress(progress);
                }
            );
        }
コード例 #14
0
ファイル: HistogramCollector.cs プロジェクト: radtek/CatEye
        public void CollectData(IBitmapCore image)
        {
            double light_max = 0;

            for (int i = 0; i < image.Width; i++)
            {
                for (int j = 0; j < image.Height; j++)
                {
                    double light = Math.Sqrt(image.RedChannel[i, j] * image.RedChannel[i, j] +
                                             image.GreenChannel[i, j] * image.GreenChannel[i, j] +
                                             image.BlueChannel[i, j] * image.BlueChannel[i, j]) / Math.Sqrt(3);

                    int light_inx = (int)(light / mMaxLight * mLines);
                    if (light_inx >= mLines)
                    {
                        light_inx = mLines - 1;
                    }
                    mLightHistogramData[light_inx] += 1;
                    if (mLightHistogramData[light_inx] > light_max)
                    {
                        light_max = mLightHistogramData[light_inx];
                    }

                    int red_inx = (int)(image.RedChannel[i, j] / mMaxLight * mLines);
                    if (red_inx >= mLines)
                    {
                        red_inx = mLines - 1;
                    }
                    mRedHistogramData[red_inx] += 1;

                    int green_inx = (int)(image.GreenChannel[i, j] / mMaxLight * mLines);
                    if (green_inx >= mLines)
                    {
                        green_inx = mLines - 1;
                    }
                    mGreenHistogramData[green_inx] += 1;

                    int blue_inx = (int)(image.BlueChannel[i, j] / mMaxLight * mLines);
                    if (blue_inx >= mLines)
                    {
                        blue_inx = mLines - 1;
                    }
                    mBlueHistogramData[blue_inx] += 1;
                }
            }
            for (int i = 0; i < mLines; i++)
            {
                mLightHistogramData[i] /= light_max;
                mRedHistogramData[i]   /= light_max;
                mGreenHistogramData[i] /= light_max;
                mBlueHistogramData[i]  /= light_max;
            }
        }
コード例 #15
0
        public override void OnDo(IBitmapCore hdp)
        {
            int lines = 1024;
            double tailValueAtLeast = 0.01;

            HighlightStageOperationParameters sop = (HighlightStageOperationParameters)Parameters;
            hdp.CutHighlights(sop.Cut,
                              sop.Softness,
                              lines,
                              tailValueAtLeast,
                              delegate (double progress) {
                return OnReportProgress(progress);
            }
            );
        }
コード例 #16
0
        public override void OnDo(IBitmapCore hdp)
        {
            CompressSharpStageOperationParameters pm = (CompressSharpStageOperationParameters)Parameters;

            Console.WriteLine("Compressing and sharpening...");

            //if (pm.Type == LocalContrastStageOperationParameters.SharpType.Soft)
            //	pressure *= -1;

            hdp.SharpenLight(pm.Curve, pm.NoiseGate, pm.Pressure, pm.Contrast,
                             delegate(double progress) {
                return(OnReportProgress(progress));
            }
                             );
            hdp.SharpenEdges(pm.EdgePressure, 1, null);
        }
コード例 #17
0
        public override void OnDo(IBitmapCore hdp)
        {
            int    lines            = 1024;
            double tailValueAtLeast = 0.01;

            HighlightStageOperationParameters sop = (HighlightStageOperationParameters)Parameters;

            hdp.CutHighlights(sop.Cut,
                              sop.Softness,
                              lines,
                              tailValueAtLeast,
                              delegate(double progress) {
                return(OnReportProgress(progress));
            }
                              );
        }
コード例 #18
0
        public override void OnDo(IBitmapCore hdp)
        {
            CompressSharpStageOperationParameters pm = (CompressSharpStageOperationParameters)Parameters;

            Console.WriteLine("Compressing and sharpening...");

            //if (pm.Type == LocalContrastStageOperationParameters.SharpType.Soft)
            //	pressure *= -1;

            hdp.SharpenLight(pm.Curve, pm.NoiseGate, pm.Pressure, pm.Contrast,
                delegate (double progress) {
                    return OnReportProgress(progress);
                }
            );
            hdp.SharpenEdges(pm.EdgePressure, 1, null);
        }
コード例 #19
0
        size TrueSize(IBitmapCore hdp)
        {
            CrotateStageOperationParameters pm = (CrotateStageOperationParameters)Parameters;

            int trueWidth = hdp.Width, trueHeight = hdp.Height;

            double w1, h1;

            w1 = pm.CropWidth * hdp.Width;
            h1 = pm.CropHeight * hdp.Height;

            double asp_rat;

            if (pm.AspectRatioCustom)
            {
                asp_rat = pm.AspectRatio;
            }
            else
            {
                asp_rat = pm.PresetAspectRatioValues[pm.AspectRatioPreset];
            }

            switch (pm.Mode)
            {
            case Mode.Disproportional:
                trueWidth  = (int)w1;
                trueHeight = (int)h1;
                break;

            case Mode.ProportionalWidthFixed:
                trueWidth  = (int)w1;
                trueHeight = (int)(w1 / asp_rat);
                break;

            case Mode.ProportionalHeightFixed:
                trueWidth  = (int)(h1 * asp_rat);
                trueHeight = (int)h1;
                break;
            }

            size res = new size();

            res.width = trueWidth; res.height = trueHeight;
            return(res);
        }
コード例 #20
0
        public override void OnDo(IBitmapCore hdp)
        {
            Console.WriteLine("Rotating...");

            size trueSize = TrueSize(hdp);
            int trueWidth = trueSize.width, trueHeight = trueSize.height;

            CrotateStageOperationParameters pm = (CrotateStageOperationParameters)Parameters;
            Point c_pix = new Point(pm.Center.X * hdp.Width, pm.Center.Y * hdp.Height);

            // Calculating new picture's real dimensions

            hdp.Crotate(pm.Angle, c_pix, trueWidth, trueHeight, quality,
                delegate (double progress) {
                    return OnReportProgress(progress);
                }
            );
        }
コード例 #21
0
        public override void OnDo(IBitmapCore hdp)
        {
            Console.WriteLine("Rotating...");

            size trueSize = TrueSize(hdp);
            int  trueWidth = trueSize.width, trueHeight = trueSize.height;

            CrotateStageOperationParameters pm = (CrotateStageOperationParameters)Parameters;
            Point c_pix = new Point(pm.Center.X * hdp.Width, pm.Center.Y * hdp.Height);

            // Calculating new picture's real dimensions

            hdp.Crotate(pm.Angle, c_pix, trueWidth, trueHeight, quality,
                        delegate(double progress) {
                return(OnReportProgress(progress));
            }
                        );
        }
コード例 #22
0
ファイル: Stage.cs プロジェクト: radtek/CatEye
        public virtual bool LoadImage(string filename, int downscale_by)
        {
            CancelProcessing();

            IBitmapCore ibc = LoadRaw(filename, downscale_by);

            if (ibc != null)
            {
                // Result is not null, image is loaded successfully
                if (ImageLoadingCompleted != null)
                {
                    ImageLoadingCompleted(this, EventArgs.Empty);
                }
                SourceImage = ibc;
                return(true);
            }
            else
            {
                if (mCancelLoadingPending)
                {
                    // Result is null and mCancelLoadingPending flag is set
                    if (ImageLoadingCancelled != null)
                    {
                        ImageLoadingCancelled(this, EventArgs.Empty);
                    }
                    SourceImage = ibc;
                    return(false);
                }
                else
                {
                    if (ImageLoadingError != null)
                    {
                        ImageLoadingError(this, EventArgs.Empty);
                    }
                    SourceImage = ibc;
                    return(false);
                }
            }
        }
コード例 #23
0
        size TrueSize(IBitmapCore hdp)
        {
            CrotateStageOperationParameters pm = (CrotateStageOperationParameters)Parameters;

            int trueWidth = hdp.Width, trueHeight = hdp.Height;

            double w1, h1;

            w1 = pm.CropWidth * hdp.Width;
            h1 = pm.CropHeight * hdp.Height;

            double asp_rat;

            if (pm.AspectRatioCustom)
                asp_rat = pm.AspectRatio;
            else
                asp_rat = pm.PresetAspectRatioValues[pm.AspectRatioPreset];

            switch (pm.Mode)
            {
            case Mode.Disproportional:
                trueWidth = (int)w1;
                trueHeight = (int)h1;
                break;
            case Mode.ProportionalWidthFixed:
                trueWidth = (int)w1;
                trueHeight = (int)(w1 / asp_rat);
                break;
            case Mode.ProportionalHeightFixed:
                trueWidth = (int)(h1 * asp_rat);
                trueHeight = (int)h1;
                break;
            }

            size res = new size();
            res.width = trueWidth; res.height = trueHeight;
            return res;
        }
コード例 #24
0
        public override void OnDo(IBitmapCore hdp)
        {
            int points = 500;                   // TODO: Make option

            ToneStageOperationParameters pm = (ToneStageOperationParameters)Parameters;

            Tone darkTone  = pm.DarkTone;
            Tone lightTone = pm.LightTone;

            if (pm.AutoDarkTone)
            {
                darkTone = hdp.FindDarkTone(
                    pm.LightTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoDarkCenter,
                    pm.AutoDarkRadius,
                    points);
            }
            if (pm.AutoLightTone)
            {
                lightTone = hdp.FindLightTone(
                    pm.DarkTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoLightCenter,
                    pm.AutoLightRadius,
                    points);
            }

            Console.WriteLine("Basic operations: toning... ");
            hdp.ApplyTone(darkTone, lightTone, pm.Edge, pm.Softness,
                          delegate(double progress) {
                return(OnReportProgress(progress));
            }
                          );
        }
コード例 #25
0
        public override void OnDo(IBitmapCore hdp)
        {
            int points = 500;	// TODO: Make option

            ToneStageOperationParameters pm = (ToneStageOperationParameters)Parameters;

            Tone darkTone = pm.DarkTone;
            Tone lightTone = pm.LightTone;

            if (pm.AutoDarkTone)
            {
                darkTone = hdp.FindDarkTone(
                    pm.LightTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoDarkCenter,
                    pm.AutoDarkRadius,
                    points);
            }
            if (pm.AutoLightTone)
            {
                lightTone = hdp.FindLightTone(
                    pm.DarkTone,
                    pm.Edge,
                    pm.Softness,
                    pm.AutoLightCenter,
                    pm.AutoLightRadius,
                    points);
            }

            Console.WriteLine("Basic operations: toning... ");
            hdp.ApplyTone(darkTone, lightTone, pm.Edge, pm.Softness,
                delegate (double progress) {
                    return OnReportProgress(progress);
                }
            );
        }
コード例 #26
0
        public void CollectData(IBitmapCore image)
        {
            double light_max = 0;
            for (int i = 0; i < image.Width; i++)
            for (int j = 0; j < image.Height; j++)
            {
                double light = Math.Sqrt(image.RedChannel[i, j] * image.RedChannel[i, j] +
                                         image.GreenChannel[i, j] * image.GreenChannel[i, j] +
                                         image.BlueChannel[i, j] * image.BlueChannel[i, j]) / Math.Sqrt(3);

                int light_inx = (int)(light / mMaxLight * mLines);
                if (light_inx >= mLines) light_inx = mLines - 1;
                mLightHistogramData[light_inx] += 1;
                if (mLightHistogramData[light_inx] > light_max)
                    light_max = mLightHistogramData[light_inx];

                int red_inx = (int)(image.RedChannel[i, j] / mMaxLight * mLines);
                if (red_inx >= mLines) red_inx = mLines - 1;
                mRedHistogramData[red_inx] += 1;

                int green_inx = (int)(image.GreenChannel[i, j] / mMaxLight * mLines);
                if (green_inx >= mLines) green_inx = mLines - 1;
                mGreenHistogramData[green_inx] += 1;

                int blue_inx = (int)(image.BlueChannel[i, j] / mMaxLight * mLines);
                if (blue_inx >= mLines) blue_inx = mLines - 1;
                mBlueHistogramData[blue_inx] += 1;
            }
            for (int i = 0; i < mLines; i++)
            {
                mLightHistogramData[i] /= light_max;
                mRedHistogramData[i] /= light_max;
                mGreenHistogramData[i] /= light_max;
                mBlueHistogramData[i] /= light_max;
            }
        }
コード例 #27
0
ファイル: RenderingQueue.cs プロジェクト: radtek/CatEye
 protected virtual void OnQueueProgressMessageReport(string source, string destination, double progress, string status, IBitmapCore image)
 {
     if (QueueProgressMessageReport != null)
     {
         QueueProgressMessageReport(source, destination, progress, status, image);
     }
 }
コード例 #28
0
 public DoStageOperationEventArgs(IBitmapCore hdp)
 {
     _hdp = hdp;
 }
コード例 #29
0
 public override double CalculateEfforts(IBitmapCore hdp)
 {
     return hdp.Width * hdp.Height;
 }
コード例 #30
0
 public override double CalculateEfforts(IBitmapCore hdp)
 {
     return (double)hdp.Width * hdp.Height * (2 * blur_radius * 2 * blur_radius + 1);
 }
コード例 #31
0
 public override double CalculateEfforts(IBitmapCore hdp)
 {
     return(0);
 }
コード例 #32
0
 protected virtual void OnOperationDefrozen()
 {
     mFrozenImage = null;
     if (OperationDefrozen != null)
         OperationDefrozen(this, EventArgs.Empty);
 }
コード例 #33
0
        public override double CalculateEfforts(IBitmapCore hdp)
        {
            double k = 7;               // Some weight value

            return((double)hdp.Width * hdp.Height * quality * quality * k);
        }
コード例 #34
0
 public abstract double CalculateEfforts(IBitmapCore hdp);
コード例 #35
0
ファイル: StageOperation.cs プロジェクト: radtek/CatEye
 public abstract void OnDo(IBitmapCore hdp);
コード例 #36
0
 public override double CalculateEfforts(IBitmapCore hdp)
 {
     return((double)hdp.Width * hdp.Height);
 }
コード例 #37
0
 public override double CalculateEfforts(IBitmapCore hdp)
 {
     return 0;
 }
コード例 #38
0
        private void HandleRenderingQueueProgressMessageReport(string source, string destination, double progress, string status, IBitmapCore image)
        {
            Application.Invoke(delegate {
                source_label.Text = source;
                destination_label.Text = destination;
                processing_progressbar.Fraction = progress;
                processing_progressbar.Text = status;

                mProcessingStatusIcon.Tooltip = "Processing " + System.IO.Path.GetFileName(source) + ". " + status + " (" + ((int)(progress * 100)).ToString() + "%)";

                thumb_image.Visible = (image != null);

                if ((DateTime.Now - updateMoment).TotalMilliseconds > drawingTimeSpan.TotalMilliseconds * 5 && image != null && this.Visible)
                {
                    updateMoment = DateTime.Now;
                    // Drawing
                    int size = 300, margins = 30;

                    thumb_image.SetSizeRequest(size + margins, size + margins);
                    using (Gdk.Pixmap pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1))
                    {
                        using (Gdk.Pixbuf pb = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, image.Width, image.Height))
                        {
                            using (Gdk.GC gc = new Gdk.GC(thumb_image.GdkWindow))
                            {
                                ((FloatBitmapGtk)image).DrawToPixbuf(pb, null);

                                Gdk.Pixbuf pb2;

                                if (pb.Width > pb.Height)
                                    pb2 = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear);
                                else
                                    pb2 = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear);

                                pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins));

                                pm.DrawPixbuf(gc, pb2, 0, 0,
                                              (size + margins) / 2 - pb2.Width / 2,
                                              (size + margins) / 2 - pb2.Height / 2,
                                              pb2.Width, pb2.Height, Gdk.RgbDither.Max, 0, 0);

                                pb2.Dispose();

                                thumb_image.SetFromPixmap(pm, null);
                            }
                        }
                    }
                    drawingTimeSpan = DateTime.Now - updateMoment;
                }
            });
        }
コード例 #39
0
ファイル: ExtendedStage.cs プロジェクト: radtek/CatEye
        protected override void DoProcess()
        {
            mUpdatePending = false;
            if (SourceImage != null)
            {
                try
                {
                    SetUIState(UIState.Processing);

                    CancelProcessingPending = false;

                    if (mProcessImageDuringUpdate)
                    {
                        // Checking if the stage is frozen or not and is there a frozen image.
                        if (FrozenAt == null || mFrozenImage == null)
                        {
                            CurrentImage = (IBitmapCore)SourceImage.Clone();

                            if (mZoomAfterPrescaleValue < 0.999 || mZoomAfterPrescaleValue > 1.001)
                            {
                                CurrentImage.ScaleFast(mZoomAfterPrescaleValue, delegate(double progress) {
                                    OnProgressMessageReport(true, progress, "Applying zoom (downscaling)...", false);
                                    return(!CancelProcessingPending);
                                });
                            }
                            if (ImageChanged != null)
                            {
                                ImageChanged(this, EventArgs.Empty);
                            }
                        }
                        else
                        {
                            CurrentImage = (IBitmapCore)mFrozenImage.Clone();
                            if (ImageChanged != null)
                            {
                                ImageChanged(this, EventArgs.Empty);
                            }
                        }

                        // Making the list of stage operations to apply
                        List <StageOperation> operationsToApply = new List <StageOperation>();
                        List <double>         efforts           = new List <double>();
                        double full_efforts = 0;

                        int start_index = 0;
                        if (FrozenAt != null && mFrozenImage != null)
                        {
                            start_index = StageQueue.IndexOf(FrozenAt) + 1;
                        }

                        for (int i = start_index; i < StageQueue.Count; i++)
                        {
                            if (StageQueue[i] != _EditingOperation)
                            {
                                // Don't add inactives
                                if (StageQueue[i].Active == false)
                                {
                                    continue;
                                }

                                StageOperation newOperation = CallStageOperationFactory(StageQueue[i]);
                                operationsToApply.Add(newOperation);
                                efforts.Add(newOperation.CalculateEfforts(CurrentImage));
                                full_efforts += efforts[efforts.Count - 1];

                                newOperation.ReportProgress += delegate(object sender, ReportStageOperationProgressEventArgs e) {
                                    double cur_eff = 0;
                                    int    j       = 0;
                                    while (operationsToApply[j] != (StageOperation)sender)
                                    {
                                        cur_eff += efforts[j];
                                        j++;
                                    }
                                    cur_eff += e.Progress * efforts[j];
                                    string desc = StageOperationDescriptionAttribute.GetName(sender.GetType());

                                    OnProgressMessageReport(true,
                                                            cur_eff / full_efforts,
                                                            "" + (j + 1) + " of " + efforts.Count + ": " + desc + "...", true);

                                    if (CancelProcessingPending)
                                    {
                                        e.Cancel = true;
                                    }
                                };
                            }
                            else
                            {
                                break;
                            }
                        }

                        // Executing
                        for (int k = 0; k < operationsToApply.Count; k++)
                        {
                            Console.WriteLine("AnalyzeImage Calling for " + operationsToApply[k].GetType().Name);
                            _Holders[operationsToApply[k].Parameters].StageOperationParametersEditor.AnalyzeImage(CurrentImage);
                            operationsToApply[k].OnDo(CurrentImage);
                            if (operationsToApply[k].Parameters == FrozenAt)
                            {
                                // After the frozen line is reached,
                                // setting the current frozen image
                                mFrozenImage = (IBitmapCore)CurrentImage.Clone();
                            }
                        }
                    }

                    if (_EditingOperation != null)
                    {
                        Console.WriteLine("AnalyzeImage Calling for " + _EditingOperation.GetType().Name);
                        _Holders[_EditingOperation].StageOperationParametersEditor.AnalyzeImage(CurrentImage);
                    }

                    OnImageUpdatingCompleted();
                    SetUIState(UIState.Idle);
                }
                catch (UserCancelException)
                {
                    // The user cancelled processing.
                    // Setting to idle state
                    SetUIState(UIState.Idle);
                    // Unset cancelling flag.
                    AskUpdate();
                }
            }
        }
コード例 #40
0
 public override void OnDo(IBitmapCore hdp)
 {
     // Do nothing
 }
コード例 #41
0
        public override double CalculateEfforts(IBitmapCore hdp)
        {
            CompressSharpStageOperationParameters pm = (CompressSharpStageOperationParameters)Parameters;

            return((double)hdp.Width * hdp.Height * (5 * pm.Pressure + 1) * 20);
        }
コード例 #42
0
ファイル: RenderingQueueWindow.cs プロジェクト: radtek/CatEye
        private void HandleRenderingQueueProgressMessageReport(string source, string destination, double progress, string status, IBitmapCore image)
        {
            Application.Invoke(delegate {
                source_label.Text               = source;
                destination_label.Text          = destination;
                processing_progressbar.Fraction = progress;
                processing_progressbar.Text     = status;

                mProcessingStatusIcon.Tooltip = "Processing " + System.IO.Path.GetFileName(source) + ". " + status + " (" + ((int)(progress * 100)).ToString() + "%)";

                thumb_image.Visible = (image != null);

                if ((DateTime.Now - updateMoment).TotalMilliseconds > drawingTimeSpan.TotalMilliseconds * 5 && image != null && this.Visible)
                {
                    updateMoment = DateTime.Now;
                    // Drawing
                    int size = 300, margins = 30;

                    thumb_image.SetSizeRequest(size + margins, size + margins);
                    using (Gdk.Pixmap pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1))
                    {
                        using (Gdk.Pixbuf pb = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, image.Width, image.Height))
                        {
                            using (Gdk.GC gc = new Gdk.GC(thumb_image.GdkWindow))
                            {
                                ((FloatBitmapGtk)image).DrawToPixbuf(pb, null);

                                Gdk.Pixbuf pb2;

                                if (pb.Width > pb.Height)
                                {
                                    pb2 = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear);
                                }
                                else
                                {
                                    pb2 = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear);
                                }

                                pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins));

                                pm.DrawPixbuf(gc, pb2, 0, 0,
                                              (size + margins) / 2 - pb2.Width / 2,
                                              (size + margins) / 2 - pb2.Height / 2,
                                              pb2.Width, pb2.Height, Gdk.RgbDither.Max, 0, 0);

                                pb2.Dispose();

                                thumb_image.SetFromPixmap(pm, null);
                            }
                        }
                    }
                    drawingTimeSpan = DateTime.Now - updateMoment;
                }
            });
        }
コード例 #43
0
        public override double CalculateEfforts(IBitmapCore hdp)
        {
            CompressSharpStageOperationParameters pm = (CompressSharpStageOperationParameters)Parameters;

            return (double)hdp.Width * hdp.Height * (5 * pm.Pressure + 1) * 20;
        }
コード例 #44
0
 public abstract void OnDo(IBitmapCore hdp);
コード例 #45
0
 public override void OnDo(IBitmapCore hdp)
 {
     // Do nothing
 }
コード例 #46
0
        protected override void DoProcess()
        {
            mUpdatePending = false;
            if (SourceImage != null)
            {
                try
                {
                    SetUIState(UIState.Processing);

                    CancelProcessingPending = false;

                    if (mProcessImageDuringUpdate)
                    {
                        // Checking if the stage is frozen or not and is there a frozen image.
                        if (FrozenAt == null || mFrozenImage == null)
                        {
                            CurrentImage = (IBitmapCore)SourceImage.Clone();

                            if (mZoomAfterPrescaleValue < 0.999 || mZoomAfterPrescaleValue > 1.001)
                            {
                                CurrentImage.ScaleFast(mZoomAfterPrescaleValue, delegate (double progress) {
                                    OnProgressMessageReport(true, progress, "Applying zoom (downscaling)...", false);
                                    return !CancelProcessingPending;
                                });
                            }
                            if (ImageChanged != null) ImageChanged(this, EventArgs.Empty);
                        }
                        else
                        {
                            CurrentImage = (IBitmapCore)mFrozenImage.Clone();
                            if (ImageChanged != null) ImageChanged(this, EventArgs.Empty);

                        }

                        // Making the list of stage operations to apply
                        List<StageOperation> operationsToApply = new List<StageOperation>();
                        List<double> efforts = new List<double>();
                        double full_efforts = 0;

                        int start_index = 0;
                        if (FrozenAt != null && mFrozenImage != null)
                            start_index = StageQueue.IndexOf(FrozenAt) + 1;

                        for (int i = start_index; i < StageQueue.Count; i++)
                        {
                            if (StageQueue[i] != _EditingOperation)
                            {
                                // Don't add inactives
                                if (StageQueue[i].Active == false) continue;

                                StageOperation newOperation = CallStageOperationFactory(StageQueue[i]);
                                operationsToApply.Add(newOperation);
                                efforts.Add(newOperation.CalculateEfforts(CurrentImage));
                                full_efforts += efforts[efforts.Count - 1];

                                newOperation.ReportProgress += delegate(object sender, ReportStageOperationProgressEventArgs e) {
                                    double cur_eff = 0;
                                    int j = 0;
                                    while (operationsToApply[j] != (StageOperation)sender)
                                    {
                                        cur_eff += efforts[j];
                                        j++;
                                    }
                                    cur_eff += e.Progress * efforts[j];
                                    string desc = StageOperationDescriptionAttribute.GetName(sender.GetType());

                                    OnProgressMessageReport(true,
                                        cur_eff / full_efforts,
                                        "" + (j + 1) + " of " + efforts.Count +  ": " + desc + "...", true);

                                    if (CancelProcessingPending)
                                        e.Cancel = true;
                                };
                            }
                            else
                                break;
                        }

                        // Executing
                        for (int k = 0; k < operationsToApply.Count; k++)
                        {
                            Console.WriteLine("AnalyzeImage Calling for " + operationsToApply[k].GetType().Name);
                            _Holders[operationsToApply[k].Parameters].StageOperationParametersEditor.AnalyzeImage(CurrentImage);
                            operationsToApply[k].OnDo(CurrentImage);
                            if (operationsToApply[k].Parameters == FrozenAt)
                            {
                                // After the frozen line is reached,
                                // setting the current frozen image
                                mFrozenImage = (IBitmapCore)CurrentImage.Clone();
                            }
                        }
                    }

                    if (_EditingOperation != null)
                    {
                        Console.WriteLine("AnalyzeImage Calling for " + _EditingOperation.GetType().Name);
                        _Holders[_EditingOperation].StageOperationParametersEditor.AnalyzeImage(CurrentImage);
                    }

                    OnImageUpdatingCompleted();
                    SetUIState(UIState.Idle);
                }
                catch (UserCancelException)
                {
                    // The user cancelled processing.
                    // Setting to idle state
                    SetUIState(UIState.Idle);
                    // Unset cancelling flag.
                    AskUpdate();
                }
            }
        }
コード例 #47
0
 /// <summary>
 /// Handles that the image is changed. Should be called from the outside.
 /// Override it to do some recalculations.
 /// </summary>
 public virtual void AnalyzeImage(IBitmapCore image)
 {
 }
コード例 #48
0
 protected virtual void OnQueueProgressMessageReport(string source, string destination, double progress, string status, IBitmapCore image)
 {
     if (QueueProgressMessageReport != null)
     {
         QueueProgressMessageReport(source, destination, progress, status, image);
     }
 }
コード例 #49
0
ファイル: EventArgsTypes.cs プロジェクト: radtek/CatEye
 public DoStageOperationEventArgs(IBitmapCore hdp)
 {
     _hdp = hdp;
 }
コード例 #50
0
ファイル: StageOperation.cs プロジェクト: radtek/CatEye
 public abstract double CalculateEfforts(IBitmapCore hdp);
コード例 #51
0
ファイル: Stage.cs プロジェクト: bigfatbrowncat/CatEye
        protected virtual void DoProcess()
        {
            if (mSourceImage != null)
            {
                try
                {
                    mCancelProcessingPending = false;

                    mCurrentImage = (IBitmapCore)mSourceImage.Clone();

                    // Making the list of stage operations to apply
                    List<StageOperation> operationsToApply = new List<StageOperation>();
                    List<double> efforts = new List<double>();
                    double full_efforts = 0;

                    for (int i = 0; i < mStageQueue.Count; i++)
                    {
                        // Don't add inactives
                        if (mStageQueue[i].Active == false) continue;

                        StageOperation newOperation = CallStageOperationFactory(mStageQueue[i]);
                        operationsToApply.Add(newOperation);
                        efforts.Add(newOperation.CalculateEfforts(mCurrentImage));
                        full_efforts += efforts[efforts.Count - 1];

                        newOperation.ReportProgress += delegate(object sender, ReportStageOperationProgressEventArgs e) {
                            double cur_eff = 0;
                            int j = 0;
                            while (operationsToApply[j] != (StageOperation)sender)
                            {
                                cur_eff += efforts[j];
                                j++;
                            }
                            cur_eff += e.Progress * efforts[j];
                            string desc = StageOperationDescriptionAttribute.GetName(sender.GetType());

                            OnProgressMessageReport(true,
                                cur_eff / full_efforts,
                                "" + (j + 1) + " of " + efforts.Count +  ": " + desc + "...", true);

                            if (mCancelProcessingPending)
                                e.Cancel = true;
                        };

                    }

                    // Executing
                    for (int k = 0; k < operationsToApply.Count; k++)
                    {
                        operationsToApply[k].OnDo(mCurrentImage);
                    }
                    OnImageUpdatingCompleted();
                }
                catch (UserCancelException ex)
                {
                    throw ex;
                }
            }
        }
コード例 #52
0
 /// <summary>
 /// Handles that the image is changed. Should be called from the outside.
 /// Override it to do some recalculations.
 /// </summary>
 public virtual void AnalyzeImage(IBitmapCore image)
 {
 }
コード例 #53
0
 public override double CalculateEfforts(IBitmapCore hdp)
 {
     double k = 7;	// Some weight value
     return (double)hdp.Width * hdp.Height * quality * quality * k;
 }
コード例 #54
0
ファイル: Stage.cs プロジェクト: radtek/CatEye
        protected virtual void DoProcess()
        {
            if (mSourceImage != null)
            {
                try
                {
                    mCancelProcessingPending = false;

                    mCurrentImage = (IBitmapCore)mSourceImage.Clone();

                    // Making the list of stage operations to apply
                    List <StageOperation> operationsToApply = new List <StageOperation>();
                    List <double>         efforts           = new List <double>();
                    double full_efforts = 0;

                    for (int i = 0; i < mStageQueue.Count; i++)
                    {
                        // Don't add inactives
                        if (mStageQueue[i].Active == false)
                        {
                            continue;
                        }

                        StageOperation newOperation = CallStageOperationFactory(mStageQueue[i]);
                        operationsToApply.Add(newOperation);
                        efforts.Add(newOperation.CalculateEfforts(mCurrentImage));
                        full_efforts += efforts[efforts.Count - 1];

                        newOperation.ReportProgress += delegate(object sender, ReportStageOperationProgressEventArgs e) {
                            double cur_eff = 0;
                            int    j       = 0;
                            while (operationsToApply[j] != (StageOperation)sender)
                            {
                                cur_eff += efforts[j];
                                j++;
                            }
                            cur_eff += e.Progress * efforts[j];
                            string desc = StageOperationDescriptionAttribute.GetName(sender.GetType());

                            OnProgressMessageReport(true,
                                                    cur_eff / full_efforts,
                                                    "" + (j + 1) + " of " + efforts.Count + ": " + desc + "...", true);

                            if (mCancelProcessingPending)
                            {
                                e.Cancel = true;
                            }
                        };
                    }

                    // Executing
                    for (int k = 0; k < operationsToApply.Count; k++)
                    {
                        operationsToApply[k].OnDo(mCurrentImage);
                    }
                    OnImageUpdatingCompleted();
                }
                catch (UserCancelException ex)
                {
                    throw ex;
                }
            }
        }
コード例 #55
0
 public override double CalculateEfforts(IBitmapCore hdp)
 {
     return((double)hdp.Width * hdp.Height * (2 * blur_radius * 2 * blur_radius + 1));
 }