Giter Site home page Giter Site logo

ui-cropping-image's People

Contributors

arxen42 avatar dmitryshelamov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ui-cropping-image's Issues

Cropped image size is too small

Thanks for posting your code for this project.

Testing it out I noticed an issue where the saved image size would be somewhat too small. The resulting cropped image (saved to disk) appears to be cut off somewhat on the right / bottom at least.

The simplest test cases is:

  1. Run sample program
  2. Load any sample image
  3. Select the entire image as the crop area
  4. Save
  5. Resulting saved image is smaller than the original

I am running in 120 DPI, I'm not sure if that is related to this issue.

Many thanks

[Enhancement] Added code to keep Rectangle size even (square) and prevent from selecting out of canvas

I needed to crop the pictures into even sided rectangle (square) without having to -painfully- resize it manually to be exact.
For that, I had to set the width to be equal to height.
While testing that, I discovered that there's no protection from creating a square that is still inferior to the canvas in size but still overflowing outside of the canvas borders, so I also added a code that would resize it back inside and within the original canvas. It's working wonders for my project, maybe you'd want to add as a setting and include the code in a future release.

I'm doing my own build to run and include in my project for now.

Code added:

public RectangleManager(Canvas canvasOverlay)
{
            .....
            _originalCanvas = canvasOverlay;
            .....
}
public void UpdateRectangle(double newX, double newY, double newWidth, double newHeight)
 {
            //dont use negative value
            if (newHeight >= 0 && newWidth >= 0)
            {
                Canvas.SetLeft(_rectangle, newX);
                Canvas.SetTop(_rectangle, newY);
                _rectangle.Height = newHeight;
                _rectangle.Width = newHeight;

                if (_rectangle.Height > _originalCanvas.ActualWidth)
                {
                    Canvas.SetLeft(_rectangle, 0);
                    _rectangle.Height = _originalCanvas.ActualWidth;
                    _rectangle.Width = _originalCanvas.ActualWidth;
                }

                if (_rectangle.Height + newX > _originalCanvas.ActualWidth)
                {
                    Canvas.SetLeft(_rectangle, _originalCanvas.ActualWidth - _rectangle.ActualWidth);
                }
                //we need to update dashed rectangle too
                UpdateDashedRectangle();
            }
 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.