Пример #1
0
        private void OpenImageClick(object sender, EventArgs e)
        {
            using OpenFileDialog openFileDialog = new OpenFileDialog
                  {
                      InitialDirectory = @"c:\",
                      Filter           = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*",
                      FilterIndex      = 2,
                      RestoreDirectory = true
                  };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //Get the path of specified file
                var filePath = openFileDialog.FileName;

                //Create image and display it.
                try
                {
                    var image = new Bitmap(filePath);
                    _state = new ImageEditorState(image);
                    RefreshImageState();
                }
                catch (ArgumentException)
                {
                    MessageBox.Show("Please submit a valid image file type.", "File not found");
                }
            }
        }
Пример #2
0
    public void Browse()
    {
        var searchPattern = "*.jpg;*.jpeg;*.bmp;*.png";

        explorerPanel = Instantiate(UIPanels.Instance.explorerPanel);
        explorerPanel.transform.SetParent(Canvass.main.transform, false);
        explorerPanel.GetComponent <ExplorerPanel>().Init("", searchPattern, "Select image", ExplorerPanel.SelectionMode.File, true);

        imageEditorState = ImageEditorState.Opening;
    }
Пример #3
0
    public void Init(string initialTitle, List <string> initialURLs)
    {
        title.text = initialTitle;
        title.onValueChanged.AddListener(_ => OnInputChange(title));

        if (initialURLs != null)
        {
            foreach (string initialURL in initialURLs)
            {
                CreateNewEntry(initialURL);
            }
        }

        UpdateAlbumSortButtons();
        imageEditorState = ImageEditorState.Showing;
    }
Пример #4
0
    public void Init(string initialTitle, List <string> initialURLs)
    {
        defaultColor      = title.image.color;
        defaultPanelColor = imageAlbumList.parent.parent.GetComponent <Image>().color;

        title.text = initialTitle;
        title.onValueChanged.AddListener(_ => OnInputChange(title));

        if (initialURLs != null)
        {
            foreach (string initialURL in initialURLs)
            {
                CreateNewEntry(initialURL);
            }
        }

        UpdateAlbumSortButtons();
        imageEditorState = ImageEditorState.Showing;
    }
Пример #5
0
    void Update()
    {
        if (imageEditorState == ImageEditorState.Opening)
        {
            if (explorerPanel != null)
            {
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    Destroy(explorerPanel.gameObject);
                    imageEditorState = ImageEditorState.Showing;
                }
            }

            if (explorerPanel != null && explorerPanel.answered)
            {
                foreach (string path in explorerPanel.answerPaths)
                {
                    if (entries.Count < MAXANSWERS)
                    {
                        CreateNewEntry(path, false);
                    }
                }

                imageEditorState = ImageEditorState.Showing;

                Destroy(explorerPanel.gameObject);

                //NOTE(Simon): Reset the background color, in case it was red/invalid previously
                var background = imageAlbumList.parent.parent.GetComponent <Image>();
                background.color = defaultPanelColor;
            }
        }

        if (imageEditorState == ImageEditorState.Showing)
        {
            var   titleRect = question.GetComponent <RectTransform>();
            float newHeight = UIHelper.CalculateInputFieldHeight(question, 3);
            titleRect.sizeDelta = new Vector2(titleRect.sizeDelta.x, newHeight);
        }
    }
Пример #6
0
        /// <summary>
        /// **NOTE: Expensive Calculation on Large Images**
        /// Blurs the image using a kernel of Gaussian distribution.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="size">The size of the kernel used to calculate the blur.</param>
        public static void GaussianBlur(this ImageEditorState @this, int size)
        {
            var newImage = ImageProcessor.Instance.GaussianBlur(@this.Image, size);

            @this.Update(newImage);
        }
        /// <summary>
        /// Rounds the corner of the image.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="radius">The radius of the corner to be added.</param>
        public static void RoundedCorners(this ImageEditorState @this, int radius)
        {
            var newImage = ImageProcessor.Instance.RoundedCorners(@this.Image, radius);

            @this.Update(newImage);
        }
Пример #8
0
        /// <summary>
        /// Alters the hue of the image by changing the overall color.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="degrees">The angle by which to alter the image. Any integer between 0 and 360.</param>
        /// <param name="rotate">Whether to rotate the hue of the entire image or each pixel individually.</param>
        public static void Hue(this ImageEditorState @this, int degrees, bool rotate = false)
        {
            var newImage = ImageProcessor.Instance.Hue(@this.Image, degrees, rotate);

            @this.Update(newImage);
        }
        /// <summary>
        /// Changes the brightness of the image.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="percentage">The amount of change in brightness of each pixel, as a percentage.</param>
        public static void Brightness(this ImageEditorState @this, int percentage)
        {
            var newImage = ImageProcessor.Instance.Brightness(@this.Image, percentage);

            @this.Update(newImage);
        }
        /// <summary>
        /// Changes the saturation of the image.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="percentage">The percentage by which the saturation will be affected.
        /// Any integer value between -100 and 100.</param>
        public static void Saturation(this ImageEditorState @this, int percentage)
        {
            var newImage = ImageProcessor.Instance.Saturation(@this.Image, percentage);

            @this.Update(newImage);
        }
Пример #11
0
        /// <summary>
        /// Sets the output quality of the image when saved using the ImageProcessor.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="percentage">The percentage by which to alter the image's quality. Any integer between 0 and 100.</param>
        public static void Quality(this ImageEditorState @this, int percentage)
        {
            var newImage = ImageProcessor.Instance.Quality(@this.Image, percentage);

            @this.Update(newImage);
        }
Пример #12
0
        /// <summary>
        /// Flips the image.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="verticalFlip">Whether the image will be flipped vertically or horizontally.</param>
        public static void Flip(this ImageEditorState @this, bool verticalFlip = false)
        {
            var newImage = ImageProcessor.Instance.Flip(@this.Image, verticalFlip);

            @this.Update(newImage);
        }
Пример #13
0
        /// <summary>
        /// Creates the main window for the Image Filter application.
        /// </summary>
        public ImageFilterView()
        {
            InitializeComponent();

            _state = new ImageEditorState(picMain.Image);
        }
        /// <summary>
        /// Crops an image to the area of greatest entropy.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="threshold">The threshold in bytes to control the detection level.</param>
        public static void EntropyCrop(this ImageEditorState @this, byte threshold = 128)
        {
            var newImage = ImageProcessor.Instance.EntropyCrop(@this.Image, threshold);

            @this.Update(newImage);
        }
Пример #15
0
        public static void Test(this ImageEditorState @this, int radius)
        {
            var newImage = ImageProcessor.Instance.Pixelate(@this.Image, radius);

            @this.Update(newImage);
        }
Пример #16
0
        /// <summary>
        /// Changes the contrast of an image.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="percentage">The amount of change in contrast of the image, as a percentage.</param>
        public static void Contrast(this ImageEditorState @this, int percentage)
        {
            var newImage = ImageProcessor.Instance.Contrast(@this.Image, percentage);

            @this.Update(newImage);
        }