Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exception catch cases for invalid width and height parameters #60

Open
AbnerSquared opened this issue May 31, 2022 · 0 comments
Open
Labels
difficulty:easy This issue is a simple fix, and can be resolved quickly. priority:low This issue is queued to be worked on, but isn't important scope:drawing This issue focuses on the Orikivo.Drawing portion of this library. type:bug This issue is intended to resolve a visible bug in the class library.

Comments

@AbnerSquared
Copy link
Owner

AbnerSquared commented May 31, 2022

private static BorderDims GetBorderDims(int baseWidth, int baseHeight, int thickness, BorderEdge edge, BorderAllow allow)
{
var dims = new BorderDims
{
InnerLength = GetInnerLength(thickness, edge),
MaxInnerLength = (int)Math.Floor(baseWidth / (double)2),
OuterLength = GetOuterLength(thickness, edge)
};
if (dims.InnerLength > dims.MaxInnerLength)
dims.InnerLength = dims.MaxInnerLength;
int imageWidth = baseWidth;
int imageHeight = baseHeight;
if (dims.OuterLength > 0)
{
if (allow.HasFlag(BorderAllow.Left))
imageWidth += dims.OuterLength;
if (allow.HasFlag(BorderAllow.Right))
imageWidth += dims.OuterLength;
if (allow.HasFlag(BorderAllow.Top))
imageHeight += dims.OuterLength;
if (allow.HasFlag(BorderAllow.Bottom))
imageHeight += dims.OuterLength;
}
dims.ImageWidth = imageWidth;
dims.ImageHeight = imageHeight;
return dims;
}

This function can cause errors when attempting to draw outside of the given range of the size of an image.

@AbnerSquared AbnerSquared added type:bug This issue is intended to resolve a visible bug in the class library. priority:high This issue needs to be worked on as soon as possible. difficulty:easy This issue is a simple fix, and can be resolved quickly. scope:drawing This issue focuses on the Orikivo.Drawing portion of this library. labels May 31, 2022
@AbnerSquared AbnerSquared added priority:low This issue is queued to be worked on, but isn't important and removed priority:high This issue needs to be worked on as soon as possible. labels Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:easy This issue is a simple fix, and can be resolved quickly. priority:low This issue is queued to be worked on, but isn't important scope:drawing This issue focuses on the Orikivo.Drawing portion of this library. type:bug This issue is intended to resolve a visible bug in the class library.
Projects
None yet
Development

No branches or pull requests

1 participant