dmitryshelamov / ui-cropping-image Goto Github PK
View Code? Open in Web Editor NEWWPF visual cropping image library
License: MIT License
WPF visual cropping image library
License: MIT License
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:
I am running in 120 DPI, I'm not sure if that is related to this issue.
Many thanks
Lightshot also follows this rule.
Regards
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.
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();
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.