iOS Question Custom color picker bar - b4a example not portable?

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, I've the necessity to create a custom color picker that loos like this (made with Adobe XD).
Schermata 2023-03-09 alle 17.35.25.png


Graphically speaking I've already done it using panels and an ImageView, based on this B4A example by @Erel concept, that is just what I needed.
Unfortunately I realized that there are two major problems porting this to B4i...
  1. In B4A the image is loaded in the panel itself, NOT an imageview, that does not have the _Touch event (but I think this can be fixed by putting an equal-sized panel on top of it)
  2. In B4i the Bitmap object does not have th .getPixel(x,y) method šŸ˜³... that one is true problem.
To solve the point [2.] I tried to:
  1. Create an ImageView with the color spectrum
  2. Create a Panel on top of it with EXACT same sizes and location fo the imageview, in order to use the _Touch event of it, and get the coordinates to refer the pixel I want by the ImageView
  3. Use this snippet by @JanPRO to get the color from the ImageView using .GetBitmap
But this method didn't work for me.. it seems that the bitmap which the function is referring to is not sized in the same way you see on the screen.

The red bar represent the one you see in the above screenshot (with all colors), the blue rectangle instead represent what it seems to "read" the .GetPixelColor function.

In fact if, I slide the finger on the bar it reads (wrong) colors, at a certain point it stops, and it can still reading colors even if you tap on the bar and then go down where the bar is not present...
Schermata 2023-03-09 alle 17.51.35.png



SO, the question is:
Is there, today, a better way to achieve the same graphical result as shown? or any way actually?


Thanks in advance. I hope to have been clear...


Edit:
Here you are an example project
try to slide the finger on the colored bar... you can notice that a certain point beyond the green it can't go.. and also the color is totally wrong (respect where you tap)
 

Attachments

  • test_color_picker.zip
    59.2 KB · Views: 15
Last edited:

Mike1970

Well-Known Member
Licensed User
Longtime User
Solved in this post:
 
Upvote 0
Solution
Top