Example #1
0
        public void ExecuteFitler(IInPlaceFilter filter)
        {
            BitmapSource bitmapSource = currentImageHandler.GetCropedImageSource().Clone();
              Bitmap bitmap = ImageHelper.BitmapFromSource(bitmapSource);

              filter.ApplyInPlace(bitmap);
              BitmapSource newBitmapSouce = ImageHelper.ConvertBitmap(bitmap);
              this.currentImageHandler.CurrentImage.Source = newBitmapSouce;
        }
Example #2
0
        public void ApplyInPlace(BitmapData imageData)
        {
            BeforeApplyingFilter(imageData);
            IInPlaceFilter inPlaceFilter = filter as IInPlaceFilter;

            if (inPlaceFilter != null)
            {
                inPlaceFilter.ApplyInPlace(imageData);
            }
            FilterApplied(imageData);
        }
Example #3
0
 public void ApplyFilterInPlace(IInPlaceFilter filter)
 {
     try
     {
         SetUndo();
         filter.ApplyInPlace(bitmap);
         MenuItemUndo.Enabled = true;
         toolStripButtonUndo.Enabled = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "SPixel", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     this.imageDisplay.Invalidate();
 }
Example #4
0
 public void ApplyFilter(ref System.Drawing.Bitmap resultBitmap)
 {
     iInPlaceFilter.ApplyInPlace(resultBitmap);
 }
Example #5
0
        public override ulong Create(BitmapData image)
        {
            var data = new DenseMatrix(32, 32);

            using (var unmanaged = new UnmanagedImage(image))
            {
                using (var filtered = ExtractChannel.Apply(unmanaged))
                {
                    Filter.ApplyInPlace(filtered);

                    using (var imgdata = Resize.Apply(filtered))
                    {
                        unsafe
                        {
                            var src    = (byte *)imgdata.ImageData.ToPointer();
                            var offset = imgdata.Stride - imgdata.Width;
                            var width  = imgdata.Width;
                            var height = imgdata.Height;
                            for (var y = 0; y < height; y++)
                            {
                                for (var x = 0; x < width; x++, src++)
                                {
                                    data.At(y, x, (float)*src / 255);
                                }
                                src += offset;
                            }
                        }
                    }
                }
            }

            var dct = DctMatrix.FastDCT(data);

            var vals      = new double[dctsize * dctsize];
            var valscount = 0;

            for (var r = 1; r <= dctsize; r++)
            {
                for (var c = 1; c <= dctsize; c++)
                {
                    vals[valscount] = dct.At(r, c);
                    ++valscount;
                }
            }

            var sorted = new double[dctsize * dctsize];

            Array.Copy(vals, sorted, vals.Length);
            Array.Sort(sorted);

            var mid    = dctsize * dctsize / 2;
            var median = (sorted[mid - 1] + sorted[mid]) / 2d;

            ulong index  = 1;
            ulong result = 0;

            for (var i = 0; i < dctsize * dctsize; i++)
            {
                if (vals[i] > median)
                {
                    result |= index;
                }

                index = index << 1;
            }

            return(result);
        }
Example #6
0
 //Easier to chain filters
 public static Bitmap ApplyInPlace(this Bitmap bitmap, IInPlaceFilter filter)
 {
     filter.ApplyInPlace(bitmap);
     return bitmap;
 }