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

Images.kt map() does not check sizes of given images #719

Open
AlmasB opened this issue Dec 29, 2019 · 1 comment
Open

Images.kt map() does not check sizes of given images #719

AlmasB opened this issue Dec 29, 2019 · 1 comment
Assignees
Labels
type:bug Doesn't behave according to specification

Comments

@AlmasB
Copy link
Owner

AlmasB commented Dec 29, 2019

In Images.kt file, fun Image.map(overlay: Image, f: (Pixel, Pixel) -> Pixel): Image combines overlay and this to produce a new Image using the function f to map pixels from the two images. The call, as of now, will fail if overlay width or height is smaller than this.

I'm not sure what the expected (most intuitive?) behaviour should be. It appears we have the following options:

  1. Resize overlay to match this
  2. Use overlay "as is", then the returned image size has the highest width / height of the two (e.g. max(this.width, overlay.width)). Non-existent pixels are substituted with transparent color pixels.

Suggestions are welcome.

@AlmasB AlmasB added type:refactor Clean up / upgrade code help wanted Contributions welcome / high PR acceptance rate labels Dec 29, 2019
@AahzBrut
Copy link
Contributor

AahzBrut commented Aug 3, 2020

I think, another option it is to add to map function third parameter (let's say mapType enum), which will define the type of mapping:
STRICT - as it is;
CENTER - overlay will be applied to center of the image;
HORIZONTAL_FILL - overlay will be resized without change of proportions to match width of the image;
VERTICAL_FILL - same as horizontal, though with height matching;
STRETCH - resize overlay to fully fit the image;
STRETCH_PROPORTINAL - resize to fully fit the image, saving proprtions;
TILE - tile overlay over image;

well, maybe it is better to have them as different functions.

@AlmasB AlmasB added type:bug Doesn't behave according to specification and removed type:refactor Clean up / upgrade code labels Feb 18, 2021
@AlmasB AlmasB self-assigned this Mar 7, 2021
@AlmasB AlmasB removed the help wanted Contributions welcome / high PR acceptance rate label Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Doesn't behave according to specification
Projects
None yet
Development

No branches or pull requests

2 participants