コード例 #1
0
ファイル: MainForm.Logic.cs プロジェクト: kyzmitch/Cip
 private void ApplyFilter(ImageFilter filter)
 {
     Raster raster = filter.ProcessRaster(UndoList[iCurrentIndexOfList], backgroundWorkerCip);
     if (raster != null)
     {
         this.IsNullRaster = false;
         if ((iCurrentIndexOfList + 1) < range)
         {
             UndoList[++iCurrentIndexOfList] = raster;
             iCurrentCountOfList = iCurrentIndexOfList + 1;
             this.currentBitmap = raster.ToBitmap();
             this.picBoxModifyed.Image = this.currentBitmap;
             this.CheckUndoToolStrip();
         }
         else
         {
             UndoList[range - 1] = raster;
             iCurrentCountOfList = range;
             iCurrentIndexOfList = range - 1;
             this.currentBitmap = raster.ToBitmap();
             this.picBoxModifyed.Image = this.currentBitmap;
             this.CheckUndoToolStrip();
         }
     }
     else
     {
         //MessageBox.Show("this method returns nothing");
         this.IsNullRaster = true;
     }
 }
コード例 #2
0
 private void ApplyFilter(ImageFilter imageFilter)
 {
     if (imageFilter != null)
     {
         scaledBitmap = imageFilter(scaledBitmap);
     }
 }
コード例 #3
0
        public async Task <PageResult <Image> > GetImagesAsync(ImageFilter filter)
        {
            var query = _imageRepository.Get();

            if (filter?.Id != null)
            {
                query = query.Where(i => i.Id == filter.Id.Value);
            }
            // In real life you may want to enforce some sort of user filter to reduce breach of security break
            if (filter?.UserId != null)
            {
                query = query.Where(i => i.UserId == filter.UserId.Value);
            }
            if (filter?.IsThumbnail != null)
            {
                query = query.Where(i => i.IsThumbnail == filter.IsThumbnail.Value);
            }

            var result = await query
                         .OrderBy(i => i.UserId)
                         .ThenBy(i => i.IsThumbnail)
                         .ThenBy(i => i.DisplayOrder)
                         .GetPage(filter)
                         .MaterializeAsync();

            return(result);
        }
コード例 #4
0
        public void TestIfImageWidthIsSmallerThan4()
        {
            Bitmap testBitmap        = new Bitmap(3, originalBitmapTest.Height);
            Bitmap receivedAfterTest = ImageFilter.RainbowFilter(testBitmap);

            Assert.AreEqual(testBitmap, receivedAfterTest);
        }
コード例 #5
0
ファイル: ImageInstruction.cs プロジェクト: zachlungu/Wyam
        public IMatrixFilter GetMatrixFilter(ImageFilter filter)
        {
            switch (filter)
            {
            case ImageFilter.BlackAndWhite: return(MatrixFilters.BlackWhite);

            case ImageFilter.Comic: return(MatrixFilters.Comic);

            case ImageFilter.Gotham: return(MatrixFilters.Gotham);

            case ImageFilter.GreyScale: return(MatrixFilters.GreyScale);

            case ImageFilter.HiSatch: return(MatrixFilters.HiSatch);

            case ImageFilter.Invert: return(MatrixFilters.Invert);

            case ImageFilter.Lomograph: return(MatrixFilters.Lomograph);

            case ImageFilter.LoSatch: return(MatrixFilters.LoSatch);

            case ImageFilter.Polariod: return(MatrixFilters.Polaroid);

            case ImageFilter.Sepia: return(MatrixFilters.Sepia);

            default: return(MatrixFilters.Comic);
            }
        }
コード例 #6
0
        public void TestApplyBlueFilter()
        {
            var         filename   = "test5.png";
            ImageFilter filter     = new ImageFilter();
            var         testBitmap = GetTestBitmap();

            SaveBitmap(testBitmap, filename);
            filter.Load(filename);
            try
            {
                TestLoadHelper(filter, testBitmap);
                AttachDummyEventHandler(filter);
                filter.ApplyFilter(Filter.Blue);
                var filteredBitmap = filter.FilteredImage;
                Assert.IsNotNull(filteredBitmap, $"ImageFilter - upon calling \'ApplyFilter\', property \'FilteredImage\' is null.");
                var originalBitmap = filter.OriginalImage;
                Assert.IsTrue(((originalBitmap.Width == filteredBitmap.Width) && (originalBitmap.Height == filteredBitmap.Height)),
                              $"ImageFilter - upon calling \'ApplyFilter\', property \'filteredImage\' has wrong size.");
                for (int x = 0; x < filteredBitmap.Width; x++)
                {
                    for (int y = 0; y < filteredBitmap.Height; y++)
                    {
                        var c = filteredBitmap.GetPixel(x, y);
                        Assert.IsTrue(
                            ((c.R == 0) && (c.G == 0)),
                            $"ImageFilter - upon calling \'ApplyFilter(Filter.Blue)\', property \'FilteredImage\' contains wrong bitmap.");
                    }
                }
            }
            finally
            {
                filter.OriginalImage.Dispose();
                filter.FilteredImage.Dispose();
            }
        }
コード例 #7
0
        /// <summary>
        /// Writes a set of images based on the settings specified in a ImagePropertiesInfo object.
        /// </summary>
        /// <param name="imageInfo">the image properties</param>
        /// <param name="allowEnlargement">if true, generated images will be scaled larger than the source image (if the imageInfo sizes are larger) </param>
        public void WriteImages(ImagePropertiesInfo imageInfo, bool allowEnlargement, ImageDecoratorInvocationSource invocationSource, CreateFileCallback inlineFileCreator, CreateFileCallback linkedFileCreator, IEditorOptions clientOptions)
        {
            string inlinePrefix = imageInfo.LinkTarget == LinkTargetType.IMAGE ? "_thumb" : "";

            ImageFilter inlineFilter = ImageFilterDecoratorAdapter.CreateImageDecoratorsFilter(imageInfo, ImageEmbedType.Embedded, invocationSource, clientOptions);
            ImageFilter targetFilter = ImageFilterDecoratorAdapter.CreateImageDecoratorsFilter(imageInfo, ImageEmbedType.Linked, invocationSource, clientOptions);

            using (Bitmap inlineBitmap = new Bitmap(imageInfo.ImageSourceUri.LocalPath))
            {
                string imgPath       = writeImage(inlineBitmap, imageInfo.ImageSourceUri.LocalPath, inlinePrefix, inlineFilter, inlineFileCreator);
                string inlineImgPath = new Uri(UrlHelper.CreateUrlFromPath(imgPath)).ToString();
                imageInfo.InlineImageUrl = inlineImgPath;
            }

            //Generate the link image
            //Warning! this imageInfo.LinkTarget check must be done after the inline image because the resize
            //         decorator will set the default link target for the image the first time it
            //         is applied.
            //imageInfo.LinkTarget = origLinkTarget;
            if (imageInfo.LinkTarget == LinkTargetType.IMAGE && !ImageDecoratorDirective.ShouldSuppressLinked)
            {
                using (Bitmap targetBitmap = new Bitmap(imageInfo.ImageSourceUri.LocalPath))
                {
                    string anchorPath = writeImage(targetBitmap, imageInfo.ImageSourceUri.LocalPath, "", targetFilter, linkedFileCreator);
                    string targetUrl  = new Uri(UrlHelper.CreateUrlFromPath(anchorPath)).ToString();
                    imageInfo.LinkTargetUrl = targetUrl;
                }
            }
        }
コード例 #8
0
 private IQueryable <ImageDAO> DynamicFilter(IQueryable <ImageDAO> query, ImageFilter filter)
 {
     if (filter == null)
     {
         return(query.Where(q => false));
     }
     query = query.Where(q => !q.DeletedAt.HasValue);
     if (filter.Id != null)
     {
         query = query.Where(q => q.Id, filter.Id);
     }
     if (filter.Name != null)
     {
         query = query.Where(q => q.Name, filter.Name);
     }
     if (filter.Url != null)
     {
         query = query.Where(q => q.Url, filter.Url);
     }
     if (filter.AlbumId != null)
     {
         if (filter.AlbumId.Equal.HasValue)
         {
         }
     }
     if (filter.StoreCheckingId != null)
     {
         if (filter.StoreCheckingId.Equal.HasValue)
         {
         }
     }
     query = OrFilter(query, filter);
     return(query);
 }
コード例 #9
0
        public void PushBackdropFilter(ImageFilter filter)
        {
            var layer = new BackdropFilterLayer();

            layer.set_filter(filter.ToSKImageFilter());
            PushLayer(layer);
        }
コード例 #10
0
 public override void ApplyFilter(ImageFilter imgFilter)
 {
     ////----------------------
     ///// <summary>
     ///// do filter at specific area
     ///// </summary>
     ///// <param name="filter"></param>
     ///// <param name="area"></param>
     //public override void DoFilterBlurStack(RectInt area, int r)
     //{
     //    ChildImage img = new ChildImage(_aggsx.DestImage, _aggsx.PixelBlender,
     //        area.Left, area.Bottom, area.Right, area.Top);
     //    filterMan.DoStackBlur(img, r);
     //}
     //public override void DoFilterBlurRecursive(RectInt area, int r)
     //{
     //    ChildImage img = new ChildImage(_aggsx.DestImage, _aggsx.PixelBlender,
     //        area.Left, area.Bottom, area.Right, area.Top);
     //    filterMan.DoRecursiveBlur(img, r);
     //}
     //public override void DoFilter(RectInt area, int r)
     //{
     //    ChildImage img = new ChildImage(_aggsx.DestImage, _aggsx.PixelBlender,
     //      area.Left, area.Top, area.Right, area.Bottom);
     //    filterMan.DoSharpen(img, r);
     //}
     //TODO: implement this
     //resolve internal img filter
     //switch (imgFilter.Name)
     //{
     //}
 }
コード例 #11
0
ファイル: GorgonWICImage.cs プロジェクト: tmp7701/Gorgon
        /// <summary>
        /// Function to create a WIC bitmap from a System.Drawing.Image object.
        /// </summary>
        /// <param name="bitmap">WIC bitmap to copy to our image data.</param>
        /// <param name="filter">Filter used to scale the image.</param>
        /// <param name="ditherFlags">Flags used to dither the image.</param>
        /// <param name="buffer">Buffer for holding the image data.</param>
        /// <param name="clip">TRUE to clip the data, FALSE to scale it.</param>
        public void AddWICBitmapToImageData(WIC.Bitmap bitmap, ImageFilter filter, ImageDithering ditherFlags, GorgonImageBuffer buffer, bool clip)
        {
            Guid conversionFormat = GetGUID(buffer.Format);
            bool needsResize      = (buffer.Width != bitmap.Size.Width) || (buffer.Height != bitmap.Size.Height);

            if (conversionFormat == Guid.Empty)
            {
                throw new GorgonException(GorgonResult.FormatNotSupported,
                                          string.Format(Resources.GORGFX_FORMAT_NOT_SUPPORTED, buffer.Format));
            }

            // Turn off filtering if we're not resizing.
            if (!needsResize)
            {
                filter = ImageFilter.Point;
            }

            // If the pixel format of the bitmap is not the same as our
            // conversion format, then we need to convert the image.
            if (bitmap.PixelFormat != conversionFormat)
            {
                ConvertFormat(bitmap.PixelFormat, conversionFormat, (WIC.BitmapDitherType)ditherFlags, (WIC.BitmapInterpolationMode)filter, bitmap, null, 0, buffer, needsResize, clip);
            }
            else
            {
                // Just dump without converting because our formats are equal.
                if ((!needsResize) || (!ResizeBitmap(bitmap, (WIC.BitmapInterpolationMode)filter, buffer, clip)))
                {
                    bitmap.CopyPixels(buffer.PitchInformation.RowPitch, buffer.Data.BasePointer, buffer.PitchInformation.SlicePitch);
                }
            }
        }
コード例 #12
0
        public void AddFilter(ImageFilter filter)
        {
            var filterVM = new SelectedFilterTileViewModel(filter.Name, filter);

            filterVM.ParamChanged.Subscribe(_ => _ParamChanged.OnNext(Unit.Default));
            filterVM.Remove.Subscribe(_ => _Filters.Remove(filterVM));
            filterVM.MoveUp.Subscribe(_ =>
            {
                var theList = _Filters.ToList();
                var curIdx  = theList.IndexOf(filterVM);
                if (curIdx != theList.Count - 1)
                {
                    _Filters.Move(curIdx, curIdx + 1);
                }
            });
            filterVM.MoveDown.Subscribe(_ =>
            {
                var theList = _Filters.ToList();
                var curIdx  = theList.IndexOf(filterVM);
                if (curIdx > 0)
                {
                    _Filters.Move(curIdx, curIdx - 1);
                }
            });

            Filters.Add(filterVM);
        }
コード例 #13
0
ファイル: UploadAvatar.cs プロジェクト: SGmuwa/InWords
        public override async Task <UploadAvatarQueryResult> HandleRequest(UploadAvatarQuery request, CancellationToken cancellationToken = default)
        {
            string avatarUrl;

            // proceed avatar
            using (var imageFilter = new ImageFilter(request.AvatarFile))
            {
                ImageFilter image = imageFilter
                                    .Resize(IMAGE_SIZE)
                                    .Crop(IMAGE_SIZE);

                string disposableWebP = image.CreateTempWebP();

                avatarUrl = await fileLoader
                            .UploadAsync(disposableWebP, ProjectDirectories.Avatars)
                            .ConfigureAwait(false);
            }

            User user = Context.Users.Find(request.UserId);

            // delete old file
            string oldAvatar = user.AvatarPath;

            user.AvatarPath = avatarUrl;
            await Context.SaveChangesAsync(cancellationToken)
            .ConfigureAwait(false);

            await fileLoader.DeleteAsync(oldAvatar)
            .ConfigureAwait(false);

            return(new UploadAvatarQueryResult()
            {
                AvatarPath = avatarUrl
            });
        }
コード例 #14
0
ファイル: Category.asmx.cs プロジェクト: Borna-f/MaadSun
        public ImageList GetImageInfo(string Imagename)
        {
            ImageFilter ImFilt = new ImageFilter();

            ImFilt.Image.Imagename = Imagename;
            return(MaadSun_Interface.MaadSun_In.GetFilteredImage(ImFilt));
        }
コード例 #15
0
 protected ModalRoute(
     RouteSettings settings = null,
     ImageFilter filter     = null
     ) : base(settings)
 {
     _filter = filter;
 }
コード例 #16
0
        public async Task <int> Count(ImageFilter filter)
        {
            IQueryable <ImageDAO> Images = DataContext.Image;

            Images = DynamicFilter(Images, filter);
            return(await Images.CountAsync());
        }
コード例 #17
0
 Widget _buildBottomTabBar()
 {
     return(new Positioned(
                left: 0,
                right: 0,
                bottom: 0,
                height: CConstant.TabBarHeight + this._bottomPadding,
                child: new BackdropFilter(
                    filter: ImageFilter.blur(25, 25),
                    child: new Container(
                        decoration: new BoxDecoration(
                            border: new Border(new BorderSide(CColors.Separator)),
                            color: this.widget.backgroundColor
                            ),
                        child: new Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: new List <Widget> {
         new Flexible(
             child: new Row(
                 mainAxisAlignment: MainAxisAlignment.spaceAround,
                 children: this._buildItems()
                 )
             ),
         new Container(height: this._bottomPadding)
     }
                            )
                        )
                    )
                ));
 }
コード例 #18
0
        private IQueryable <ImageDAO> OrFilter(IQueryable <ImageDAO> query, ImageFilter filter)
        {
            if (filter.OrFilter == null || filter.OrFilter.Count == 0)
            {
                return(query);
            }
            IQueryable <ImageDAO> initQuery = query.Where(q => false);

            foreach (ImageFilter ImageFilter in filter.OrFilter)
            {
                IQueryable <ImageDAO> queryable = query;
                if (ImageFilter.Id != null)
                {
                    queryable = queryable.Where(q => q.Id, ImageFilter.Id);
                }
                if (ImageFilter.Name != null)
                {
                    queryable = queryable.Where(q => q.Name, ImageFilter.Name);
                }
                if (ImageFilter.Url != null)
                {
                    queryable = queryable.Where(q => q.Url, ImageFilter.Url);
                }
                initQuery = initQuery.Union(queryable);
            }
            return(initQuery);
        }
コード例 #19
0
        public static int UpdateImage(ImageFilter IFilt)
        {
            MaadSunDB MDB = new MaadSunDB();
            int       U   = MDB.UpdateImage(IFilt);

            return(U);
        }
コード例 #20
0
 public static IResampler ImageFilterToResampler(ImageFilter filter)
 {
     return(filter switch
     {
         ImageFilter.Bilinear => KnownResamplers.Triangle,
         _ => KnownResamplers.NearestNeighbor
     });
コード例 #21
0
        private (Bitmap b, Bitmap kb) RenderFilter(ImageFilter filtername, ImageFilterParams ifparams, Bitmap inb, Bitmap inkb)
        {
            // select appropriate image filter
            switch (filtername)
            {
            case ImageFilter.SolidColorCanvas:
                return(ImageFilters.SolidColorCanvas(inb, inkb, ifparams as SolidColorCanvasFilterParams));

            case ImageFilter.CenterAssetFill:
                return(ImageFilters.CenterFillAsset(inb, inkb, ifparams as CenterAssetFillFilterParams));

            case ImageFilter.Crop:
                return(ImageFilters.Crop(inb, inkb, ifparams as CropFilterParams));

            case ImageFilter.UniformStretch:
                return(ImageFilters.UniformStretch(inb, inkb, ifparams as UniformStretchFilterParams));

            case ImageFilter.CenterOnBackground:
                return(ImageFilters.CenterOnBackground(inb, inkb, ifparams as CenterOnBackgroundFilterParams));

            case ImageFilter.ColorEdit:
                return(ImageFilters.ColorEdit(inb, inkb, ifparams as ColorEditFilterParams));
            }
            return(inb, inkb);
        }
コード例 #22
0
        public void TestIfExecuteFilterTestsNullEvent()
        {
            var filename = "test7a.png";

            TestIfExecuteFilterCallsEventHelper(filename);
            filename = "test7b.png";
            var filter     = new ImageFilter();
            var testBitmap = GetTestBitmap();

            SaveBitmap(testBitmap, filename);
            filter.Load(filename);

            try
            {
                TestLoadHelper(filter, testBitmap);
                try
                {
                    filter.ExecuteFilter((p) => { return(p); });
                }
                catch (Exception e)
                {
                    Assert.Fail($"Method \'ExecuteFilter\' calls event even if it is null: \'{e.GetType().ToString()}\' is thrown.");
                }
            }
            finally
            {
                filter.OriginalImage.Dispose();
                filter.FilteredImage.Dispose();
            }
        }
コード例 #23
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Bitmap img = null;

            DA.GetData(0, ref img);
            Color C = Color.White;

            DA.GetData(1, ref C);
            int X = 0;

            DA.GetData(2, ref X);
            int Y = 0;

            DA.GetData(3, ref Y);
            double S = 0;

            DA.GetData(4, ref S);
            int R = 2;

            DA.GetData(5, ref R);
            double O = 0.5;

            DA.GetData(6, ref O);

            Tuple <Bitmap, Bitmap> myResult = ImageFilter.DropShadow(img, X, Y, C, Convert.ToSingle(S), R, Convert.ToSingle(O));

            DA.SetData(0, myResult.Item1);
            DA.SetData(1, myResult.Item2);
        }
コード例 #24
0
ファイル: PictureService.cs プロジェクト: janaknm/HelloWorld
        public async Task<byte[]> ConvertToGrayScale(byte[] imageBytes, int height, int width)
        {
            using (InMemoryRandomAccessStream rasStream = new InMemoryRandomAccessStream())
            {
                await rasStream.WriteAsync(imageBytes.AsBuffer());
                var decoder = await BitmapDecoder.CreateAsync(rasStream);
                var pixelData = await decoder.GetPixelDataAsync();
                var pixels = pixelData.DetachPixelData();

                if (_filter == null)
                    _filter = new ImageFilter();

                await _filter.ToGrayScale(pixels.AsBuffer());

                BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, rasStream);
                encoder.SetPixelData(decoder.BitmapPixelFormat, BitmapAlphaMode.Ignore, (uint)width, (uint)height, decoder.DpiX, decoder.DpiY, pixels);
                await encoder.FlushAsync();

                using (BinaryReader br = new BinaryReader(rasStream.AsStreamForRead()))
                {
                    rasStream.Seek(0);
                    return br.ReadBytes((int)rasStream.AsStreamForRead().Length);
                }
            }
        }
コード例 #25
0
ファイル: MaadSunDB.cs プロジェクト: Borna-f/MaadSun
        public int UpdateImage(ImageFilter IFilt)
        {
            int result = 0;

            try
            {
                SqlCommand sqlCommand = ProjectConnection.CreateCommand();
                sqlCommand.CommandText = UPDATE_IMAGE_SP;
                sqlCommand.CommandType = CommandType.StoredProcedure;
                sqlCommand.Parameters.Add(new SqlParameter(IMAGE_IMAGEID_PARAM, SqlDbType.Int)).Value        = IFilt.Image.ImageID;
                sqlCommand.Parameters.Add(new SqlParameter(IMAGE_USERID_PARAM, SqlDbType.Int)).Value         = IFilt.Image.UserID;
                sqlCommand.Parameters.Add(new SqlParameter(IMAGE_CATEGORYID_PARAM, SqlDbType.Int)).Value     = IFilt.Image.CategoryID;
                sqlCommand.Parameters.Add(new SqlParameter(IMAGE_SUBCATEGORYID_PARAM, SqlDbType.Int)).Value  = IFilt.Image.SubCategoryID;
                sqlCommand.Parameters.Add(new SqlParameter(IMAGE_IMAGENAME_PARAM, SqlDbType.NVarChar)).Value = IFilt.Image.Imagename;
                ProjectConnection.Open();
                result = sqlCommand.ExecuteNonQuery();
                ProjectConnection.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("IMAGE", ex);
            }
            finally
            {
                if (ProjectConnection.State == ConnectionState.Open)
                {
                    ProjectConnection.Close();
                }
            }
            return(result);
        }
コード例 #26
0
        public void ImageFilter_Mul_PredifenedData()
        {
            IFilterImage filter = new ImageFilter();

            //long sum = filter.Sum(3, 4);

            //Assert.AreEqual(sum, 7);

            //List<ImageFilter_Mul> results = ImageFilterDAO.GetDataForImageFilter_Mul();

            var results = ImageFilterDAO.GetDataForImageFilter_Generic(
                (reader, records) =>
            {
                records.Add(new
                {
                    A      = (long)reader.GetValue(1), // A
                    B      = (long)reader.GetValue(2), // B
                    C      = (long)reader.GetValue(3), // C
                    Result = (long)reader.GetValue(4)  // Result
                });
            }, "ImageFilter_Mul");

            foreach (var r in results)
            {
                long a = ((dynamic)r).A;
                long b = ((dynamic)r).B;
                long c = ((dynamic)r).C;
                long expectedResult = ((dynamic)r).Result;
                long result         = filter.Mul(a, b, c);

                Assert.AreEqual(expectedResult, result);
            }
        }
コード例 #27
0
        public void _openContextMenu()
        {
            setState(() => {
                _childHidden = true;
            });

            _route = new _ContextMenuRoute(
                actions: widget.actions,
                barrierLabel: "Dismiss",
                filter: ImageFilter.blur(
                    sigmaX: 5.0f,
                    sigmaY: 5.0f
                    ),
                contextMenuLocation: _contextMenuLocation,
                previousChildRect: _decoyChildEndRect,
                builder: (BuildContext _context, Animation <float> animation) => {
                if (widget.previewBuilder == null)
                {
                    return(widget.child);
                }
                return(widget.previewBuilder(_context, animation, widget.child));
            }
                );
            Navigator.of(context, rootNavigator: true).push(_route);
            _route.animation.addStatusListener(_routeAnimationStatusListener);
        }
コード例 #28
0
        public void TestCreateShouldCreateImageFilter()
        {
            var filter = new ImageFilter(null, true, true);
            var result = _factory.Create(filter);

            Assert.That(result, Is.TypeOf <ImageFilterViewModel>());
            Assert.That(result.Filter, Is.EqualTo(filter));
        }
コード例 #29
0
 public async Task ApplyEffects()
 {
     while (this._filters.Count > 0)
     {
         ImageFilter filter = this._filters.Dequeue();
         this._image = await filter.Process(this._image);
     }
 }
コード例 #30
0
        private void pictureBoxBlur_Click(object sender, EventArgs e)
        {
            m_ImageFilter = ImageFactory.CreateImageFilter(
                Utilities.eFilterType.BLUR,
                m_AppLogicFacade.CurrentUserShown().ImageNormal);

            movingToPlayMode();
        }
コード例 #31
0
        static void Main()
        {
            ImageFilter imgFilt = new ImageFilter();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(imgFilt)); // Application.Run(new MainForm(new ImageFilter()));
        }
コード例 #32
0
        public ContentBuffer()
        {
            strokeFilter = new StrokeFilter();
            imageFilter = new ImageFilter();
            textFilter = new TextFilter();

            strokeDeltaFilter = new StrokeFilter();
            imageDeltaCollection = new ImageFilter();
        }
コード例 #33
0
        public override Widget build(BuildContext context)
        {
            List <Widget> children = new List <Widget> {
                new Flexible(child: new ClipRRect(
                                 borderRadius: BorderRadius.circular(12.0f),
                                 child: new BackdropFilter(
                                     filter: ImageFilter.blur(
                                         sigmaX: CupertinoActionSheetUtils._kBlurAmount,
                                         sigmaY: CupertinoActionSheetUtils._kBlurAmount),
                                     child: new _CupertinoAlertRenderWidget(
                                         contentSection: new Builder(builder: _buildContent),
                                         actionsSection: _buildActions()
                                         )
                                     )
                                 )
                             ),
            };

            if (cancelButton != null)
            {
                children.Add(_buildCancelButton()
                             );
            }

            Orientation?orientation = MediaQuery.of(context).orientation;

            float actionSheetWidth;

            if (orientation == Orientation.portrait)
            {
                actionSheetWidth = MediaQuery.of(context).size.width -
                                   (CupertinoActionSheetUtils._kEdgeHorizontalPadding * 2);
            }
            else
            {
                actionSheetWidth = MediaQuery.of(context).size.height -
                                   (CupertinoActionSheetUtils._kEdgeHorizontalPadding * 2);
            }

            return(new SafeArea(
                       child:  new CupertinoUserInterfaceLevel(
                           data: CupertinoUserInterfaceLevelData.elevatedlayer,
                           child: new Container(
                               width: actionSheetWidth,
                               margin: EdgeInsets.symmetric(
                                   horizontal: CupertinoActionSheetUtils._kEdgeHorizontalPadding,
                                   vertical: CupertinoActionSheetUtils._kEdgeVerticalPadding
                                   ),
                               child: new Column(
                                   children: children,
                                   mainAxisSize: MainAxisSize.min,
                                   crossAxisAlignment: CrossAxisAlignment.stretch
                                   ))
                           )

                       ));
        }
コード例 #34
0
        private string writeImage(Bitmap image, string srcFileName, string suffix, ImageFilter filter, CreateFileCallback createFileCallback)
        {
            string extension = Path.GetExtension(srcFileName).ToLower(CultureInfo.InvariantCulture);
            srcFileName = Path.GetFileNameWithoutExtension(srcFileName) + suffix + extension;
            try
            {
                //save the thumbnail to disk
                ImageFormat imageFormat;
                ImageHelper2.GetImageFormat(srcFileName, out extension, out imageFormat);
                string filename = createFileCallback(Path.GetFileNameWithoutExtension(srcFileName) + extension);
                try
                {
                    if (filter != null)
                        image = filter(image);

                    using (FileStream fs = new FileStream(filename, FileMode.Create))
                    {
                        ImageHelper2.SaveImage(image, imageFormat, fs);
                    }
                    return filename;
                }
                catch (Exception e)
                {
                    Trace.Fail("Failed to save image as format " + imageFormat.Guid + ": " + e.ToString());

                    //try to fall back to generating a PNG version of the image
                    imageFormat = ImageFormat.Png;
                    extension = ".png";
                    filename = createFileCallback(Path.GetFileNameWithoutExtension(srcFileName) + extension);

                    using (FileStream fs = new FileStream(filename, FileMode.Create))
                    {
                        ImageHelper2.SaveImage(image, ImageFormat.Png, fs);
                    }
                    return filename;
                }
            }
            catch (Exception e)
            {
                Trace.Fail("Error while trying to create thumbnail: " + e.Message, e.StackTrace);
                throw;
            }
        }
コード例 #35
0
 public static void SaveThumbnailImage(int width, int height, Bitmap image, ImageFormat newFormat, Stream thumbOut, ImageFilter filter)
 {
     ThumbMaker thumb = new ThumbMaker(image, newFormat);
     if (newFormat == ImageFormat.Jpeg)
     {
         //note: supports high quality JPEG thumbnailing
         thumb.ResizeToJpeg(width, height, JPEG_QUALITY, thumbOut, filter);
     }
     else if (newFormat == ImageFormat.Gif)
     {
         //note: supports transparent images
         thumb.ResizeToGif(width, height, thumbOut, filter);
     }
     else if (newFormat == ImageFormat.Png)
     {
         //note: nothing special needs to be done here since PNG format rules!
         thumb.ResizeToPng(width, height, thumbOut, filter);
     }
     else if (newFormat == ImageFormat.Bmp)
     {
         thumb.ResizeToBmp(width, height, thumbOut, filter);
     }
     else
     {
         throw new Exception("unsupported image format detected");
     }
 }
コード例 #36
0
ファイル: ImageInstruction.cs プロジェクト: ibebbs/Wyam
 public IMatrixFilter GetMatrixFilter(ImageFilter filter)
 {
     switch (filter)
     {
         case ImageFilter.BlackAndWhite: return MatrixFilters.BlackWhite;
         case ImageFilter.Comic: return MatrixFilters.Comic;
         case ImageFilter.Gotham: return MatrixFilters.Gotham;
         case ImageFilter.GreyScale: return MatrixFilters.GreyScale;
         case ImageFilter.HiSatch: return MatrixFilters.HiSatch;
         case ImageFilter.Invert: return MatrixFilters.Invert;
         case ImageFilter.Lomograph: return MatrixFilters.Lomograph;
         case ImageFilter.LoSatch: return MatrixFilters.LoSatch;
         case ImageFilter.Polariod: return MatrixFilters.Polaroid;
         case ImageFilter.Sepia: return MatrixFilters.Sepia;
         default: return MatrixFilters.Comic;
     }
 }
コード例 #37
0
 internal void ResizeToJpeg(int xSize, int ySize, long jQuality, string fileName, ImageFilter imageFilter)
 {
     Resize(xSize, ySize);
     ApplyFilter(imageFilter);
     this.Save(fileName, jQuality, ImageFormat.Jpeg);
 }
コード例 #38
0
 internal void ResizeToJpeg(int xSize, int ySize, long jQuality, Stream stream, ImageFilter imageFilter)
 {
     Resize(xSize, ySize);
     ApplyFilter(imageFilter);
     this.Save(stream, jQuality, ImageFormat.Jpeg);
 }
コード例 #39
0
		public UIViewController Demo (ImageFilter makeDemo)
		{
			var v = new UIViewController ();
			var imageView = new UIImageView (v.View.Bounds);
			v.View.AddSubview (imageView);
			
			var output = makeDemo ();
			var context = CIContext.FromOptions (null);
			var result = context.CreateCGImage (output, output.Extent);
			imageView.Image = UIImage.FromImage (result);
			return v;
		}	
コード例 #40
0
 internal void ResizeToPng(int xSize, int ySize, Stream stream, ImageFilter imageFilter)
 {
     Resize(xSize, ySize);
     ApplyFilter(imageFilter);
     this.Save(stream, ImageFormat.Png);
 }
コード例 #41
0
 private void ApplyFilter(ImageFilter imageFilter)
 {
     if (imageFilter != null)
         scaledBitmap = imageFilter(scaledBitmap);
 }
コード例 #42
0
ファイル: PictureService.cs プロジェクト: janaknm/HelloWorld
        /// <summary>
        /// Convert an image to grayscale
        /// </summary>
        /// <param name="imageBytes">The image to convert</param>
        /// <param name="height">The height of the image</param>
        /// <param name="width">The width of the image</param>
        /// <returns>The image, converted to grayscale</returns>
        public async Task<byte[]> ConvertToGrayScale(byte[] imageBytes, int height, int width)
        {
            using (MemoryStream stream = new MemoryStream(imageBytes))
            {
                WriteableBitmap bmp = PictureDecoder.DecodeJpeg(stream, height, width);
                var pixels = bmp.Pixels;
                var bytes = new byte[pixels.Length * 4];
                Buffer.BlockCopy(pixels, 0, bytes, 0, bytes.Length);

                if (_filter == null)
                    _filter = new ImageFilter();
                await _filter.ToGrayScale(bytes.AsBuffer());

                Buffer.BlockCopy(bytes, 0, pixels, 0, bytes.Length);
                MemoryStream outStream = new MemoryStream();
                bmp.SaveJpeg(outStream, height, width, 0, 100);
                return outStream.ToArray();
            }
        }
コード例 #43
0
ファイル: Image.cs プロジェクト: mono-soc-2011/axiom
		/// <summary>
		/// Scale a 1D, 2D or 3D image volume.
		/// </summary>
		/// <param name="src">PixelBox containing the source pointer, dimensions and format</param>
        /// <param name="scaled">PixelBox containing the destination pointer, dimensions and format</param>
		/// <param name="filter">Which filter to use</param>
		/// <remarks>
		/// This function can do pixel format conversion in the process.
		/// dst and src can point to the same PixelBox object without any problem
		/// </remarks>
		public static void Scale( PixelBox src, PixelBox scaled, ImageFilter filter )
		{
			Contract.Requires( PixelUtil.IsAccessible( src.Format ) );
			Contract.Requires( PixelUtil.IsAccessible( scaled.Format ) );

			byte[] buf; // For auto-delete
			PixelBox temp;
			switch ( filter )
			{
				default:
				case ImageFilter.Nearest:
					if ( src.Format == scaled.Format )
					{
						// No intermediate buffer needed
						temp = scaled;
					}
					else
					{
						// Allocate temporary buffer of destination size in source format 
						temp = new PixelBox( scaled.Width, scaled.Height, scaled.Depth, src.Format );
						buf = new byte[ temp.ConsecutiveSize ];
						temp.Data = GCHandle.Alloc( buf, GCHandleType.Pinned ).AddrOfPinnedObject();
					}

					// super-optimized: no conversion
					NearestResampler.Scale( src, temp );

					if ( temp.Data != scaled.Data )
					{
						// Blit temp buffer
						PixelConverter.BulkPixelConversion( temp, scaled );
					}
					break;

				case ImageFilter.Linear:
				case ImageFilter.Bilinear:
					switch ( src.Format )
					{
						case PixelFormat.L8:
						case PixelFormat.A8:
						case PixelFormat.BYTE_LA:
						case PixelFormat.R8G8B8:
						case PixelFormat.B8G8R8:
						case PixelFormat.R8G8B8A8:
						case PixelFormat.B8G8R8A8:
						case PixelFormat.A8B8G8R8:
						case PixelFormat.A8R8G8B8:
						case PixelFormat.X8B8G8R8:
						case PixelFormat.X8R8G8B8:
							if ( src.Format == scaled.Format )
							{
								// No intermediate buffer needed
								temp = scaled;
							}
							else
							{
								// Allocate temp buffer of destination size in source format 
								temp = new PixelBox( scaled.Width, scaled.Height, scaled.Depth, src.Format );
								buf = new byte[ temp.ConsecutiveSize ];
								temp.Data = GCHandle.Alloc( buf, GCHandleType.Pinned ).AddrOfPinnedObject();
							}

							// super-optimized: byte-oriented math, no conversion
							switch ( PixelUtil.GetNumElemBytes( src.Format ) )
							{
								case 1:
									( new LinearResampler.Byte( 1 ) ).Scale( src, temp );
									break;
								case 2:
									( new LinearResampler.Byte( 2 ) ).Scale( src, temp );
									break;
								case 3:
									( new LinearResampler.Byte( 3 ) ).Scale( src, temp );
									break;
								case 4:
									( new LinearResampler.Byte( 4 ) ).Scale( src, temp );
									break;
								default:
									throw new NotSupportedException( String.Format( "Scaling of images using {0} byte format is not supported.", PixelUtil.GetNumElemBytes( src.Format ) ) );
							}
							if ( temp.Data != scaled.Data )
							{
								// Blit temp buffer
								PixelConverter.BulkPixelConversion( temp, scaled );
							}
							break;
						case PixelFormat.FLOAT32_RGB:
						case PixelFormat.FLOAT32_RGBA:
							if ( scaled.Format == PixelFormat.FLOAT32_RGB || scaled.Format == PixelFormat.FLOAT32_RGBA )
							{
								// float32 to float32, avoid unpack/repack overhead
								( new LinearResampler.Float32( 32 ) ).Scale( src, scaled );
							}
							else
							{
								( new LinearResampler.Float32() ).Scale( src, scaled );
							}
							break;
						default:
							// non-optimized: floating-point math, performs conversion but always works
							( new LinearResampler.Float32() ).Scale( src, scaled );
							break;
					}
					break;
			}
		}
コード例 #44
0
        public static Size SaveScaledThumbnailImage(int maxWidth, int maxHeight, Bitmap image, ImageFormat format, Stream thumbOut, ImageFilter imageFilter)
        {
            // The dimensions of the image from which the thumbnail is needed
            float width = image.Width;
            float height = image.Height;
            float imageRatio = width / height;

            // The width/height ratio of the maximum thumbnail dimensions
            float maxRatio = (float)maxWidth / (float)maxHeight;

            // The dimensions of the thumbnail that we'll request
            float requestedWidth;
            float requestedHeight;

            if (imageRatio >= maxRatio)
            {
                // the image's width is the determinant in scaling, scale based upon that
                requestedWidth = maxWidth;
                requestedHeight = (requestedWidth * height) / width;
            }
            else
            {
                // the image's height is the determinant in scaling, scale based upon that
                requestedHeight = maxHeight;
                requestedWidth = (requestedHeight * width) / height;
            }

            Size scaledSize = new Size((int)requestedWidth, (int)requestedHeight);

            //save the thumbnail in the requested format using the scaled sizes.
            SaveThumbnailImage(scaledSize.Width, scaledSize.Height, image, format, thumbOut, imageFilter);

            return scaledSize;
        }
コード例 #45
0
 internal void ResizeToPng(int xSize, int ySize, string fileName, ImageFilter imageFilter)
 {
     Resize(xSize, ySize);
     ApplyFilter(imageFilter);
     this.Save(fileName, ImageFormat.Png);
 }
コード例 #46
0
ファイル: Image.cs プロジェクト: mono-soc-2011/axiom
		/// <summary>
		/// Resize a 2D image, applying the appropriate filter.
		/// </summary>
		/// <param name="width"></param>
		/// <param name="height"></param>
		/// <param name="filter"></param>
		public void Resize( int width, int height, ImageFilter filter )
		{
			// resizing dynamic images is not supported
			//TODO : Debug.Assert( this._bAutoDelete);
			Debug.Assert( this.Depth == 1 );

			// reassign buffer to temp image, make sure auto-delete is true
			Image temp = new Image();
			temp.FromDynamicImage( buffer, width, height, 1, format );
			// do not delete[] m_pBuffer!  temp will destroy it

			// set new dimensions, allocate new buffer
			this.width = width;
			this.height = height;
			size = PixelUtil.GetMemorySize( Width, Height, 1, Format );
			buffer = new byte[ size ];
			numMipMaps = 0; // Loses precomputed mipmaps

			// scale the image from temp into our resized buffer
			Scale( temp.GetPixelBox( 0, 0 ), GetPixelBox( 0, 0 ), filter );
		}