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

Color Picker Brightness and Alpha slider issue on a #92

Open
chazilian opened this issue Aug 1, 2022 · 0 comments
Open

Color Picker Brightness and Alpha slider issue on a #92

chazilian opened this issue Aug 1, 2022 · 0 comments

Comments

@chazilian
Copy link

chazilian commented Aug 1, 2022

Please complete the following information:

  • Library Version 2.2.4
  • Affected Device(s) Pixel 4 API 26

Describe the Bug:

When using the colorPickerDialog.colorPickerView.setPaletteDrawable loading in an image that the user has previously drawn. When the color picker dialog appears, the image shows up fine on it. However, an issue arises when I select certain drawn lines that have had their brightness reduced. The color that is being given by the ColorEnvelope is a color that has its brightness set to Max. This becomes really bad when I try to select the color black and the ColorEnvelope returns the color white.

I have included a code snippet of color picker dialog being used
I also included screenshots of the color picker using the color wheel and using an image

    private fun openEyeDropper() {
        try {
            val bubbleFlag = CustomFlag(requireContext(), R.layout.bubble_flag)
            bubbleFlag.flagMode = FlagMode.LAST

            val colorPickerDialog = ColorPickerDialog.Builder(requireContext())
                .setTitle("Color Eye Dropper")
                .setPositiveButton(getString(R.string.confirm),
                    ColorEnvelopeListener { envelope, fromUser ->
                        defaultColor = envelope.color
                        draw_View.setDrawingColor(envelope.color)
                        changeToolColors()
                    })
                .setNegativeButton(
                    getString(R.string.cancel)
                ) { dialogInterface, i -> dialogInterface.dismiss() }
                .attachAlphaSlideBar(false) // the default value is true.
                .attachBrightnessSlideBar(true) // the default value is true.
                .setBottomSpace(12) // set a bottom space between the last slidebar and buttons.

            colorPickerDialog.colorPickerView.setPaletteDrawable(draw_View.bitmap.toDrawable(requireContext().resources))
            colorPickerDialog.colorPickerView.flagView = bubbleFlag
            colorPickerDialog.show()
        } catch (e: Exception){
            Log.e( "Error Exception" , e.message.toString())
        }
    }

Picking a color and lowering the brightness
01 08 2022_01 46 08_REC
Color picker making black have max brightness
01 08 2022_01 16 45_REC
Color picker making the same color I just picked have max brightness
01 08 2022_01 15 25_REC

Expected Behavior:

What I expect to happen when I select a point on an image is that it returns the color and retains the same brightness level and alpha level.

Suggestion
The issue seems to occur in the AbstractSlider class on the notifyColor method. It calls colorPickerView.getPureColor() which seems to reset the alpha and brightness levels. I do understand why this implementation is important when using the color wheel, however, I think an image should allow you to retain the alpha and brightness values of a color point. Especially if you use the default color wheel to create a drawing and you want to retrieve a previous color from it. A possible solution could be giving a flag to the color listener to see if it using the color wheel or a custom image. Then in the color listener, you can check if it is an image and if it is then you don't have to reset the alpha and brightness of a color.

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

1 participant