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

Setting region to calculate palette from a specified area doesn't work #199

Open
amitkma opened this issue Jan 23, 2025 · 2 comments
Open

Comments

@amitkma
Copy link

amitkma commented Jan 23, 2025

When we specify a region using the setRegion method of palette builder, the region internally is always set as a full bitmap.

I think the issue is this code

public fun setRegion(left: Int, top: Int, right: Int, bottom: Int): Builder {
            val bitmap = imageBitmap
            if (bitmap != null) {
                if (region == null) {
                    region = Rect(0f, 0f, bitmap.width.toFloat(), bitmap.height.toFloat())
                }

                // Now just get the intersection with the region
                val other = Rect(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
                if (!region!!.overlaps(other)) {
                    throw IllegalArgumentException("The given region must intersect with "
                        + "the Bitmap's dimensions.")
                }
            }
            return this
        }

When we set a region, it should be initialised as region = Rect(left, top, right, bottom)

Let me know if I am incorrect or if there is a way to fix it.

@amitkma
Copy link
Author

amitkma commented Feb 3, 2025

Any ideas?

@jordond
Copy link
Owner

jordond commented Feb 3, 2025

I'm currently focused on #207 in the time I have to work on this project. So unfortunately this issue isn't on my radar currently. Feel free to submit a PR if you'd like. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants