Android Question GetPixel() too slow

Discussion in 'Android Questions' started by Fusseldieb, Aug 16, 2015.

Similar threads

B4A Code Snippet Color Picker
B4A Question Bitmap.GetPixel color format
B4A Question Why imageview.GetPixel so slow?
B4A Question GetPixel from Zoomed Image
B4A Question Recursive Flood Fill Error
  1. Fusseldieb

    Fusseldieb Active Member Licensed User

    Last edited: Aug 16, 2015
  2. stevel05

    stevel05 Expert Licensed User

    To get help with this, please say what error you are getting and show the code that causes the error.
     
  3. Fusseldieb

    Fusseldieb Active Member Licensed User

    Thanks for the reply.
    I get that I cannot convert NumberToString.
    How do I use that function in that link?
    Is that an ItemArray, An Int or something else?
    I do not understand how to get values from that code...
    That's my question. Thanks ^^

    @klaus may undestand it
     
  4. klaus

    klaus Expert Licensed User

    The code you are refering to returns an array of Ints.
    The function comes from HERE.
     
  5. Fusseldieb

    Fusseldieb Active Member Licensed User

    But in B4A, how do I use it?
     
  6. DonManfred

    DonManfred Expert Licensed User

    Write a small java wrapper for this method or try to do it with javaobject or reflection
     
  7. klaus

    klaus Expert Licensed User

    Attached you find a small example demonstrating getPixels and setPixels.
    Clicking on the panel changes the color of the vertical line
     

    Attached Files:

    Fusseldieb and ellpopeb4a like this.
  8. Fusseldieb

    Fusseldieb Active Member Licensed User

    Wow! Thank you. I understood the code now :)
     
  9. Fusseldieb

    Fusseldieb Active Member Licensed User

    The only thing I didn't understand is that:
    Code:
    Log("-3 " & (pxlTest(pxlTest.Length - 3)))
        
    Log("-2 " & (pxlTest(pxlTest.Length - 2)))
        
    Log("-1 " & (pxlTest(pxlTest.Length - 1)))
    What is this supposed to do?

    pxlTest(1) gives me the first pixel... pxlTest(2) the second and so on, but I didn't understand pxlTest(pxlTest.Length - 1)
     
  10. klaus

    klaus Expert Licensed User

    pxlTest(0) gives the first pixel ! Not pxlTest(1) !
    pxlTest(pxlTest.Length - 1) gives the last pixel.
    pxlTest(pxlTest.Length - 2) gives the last but one pixel.
    etc.
     
    Fusseldieb likes this.
  11. Fusseldieb

    Fusseldieb Active Member Licensed User

    But ".Length" is the Lenght of a string, not?
    And with -1 you're cutting the last character from the string if I think right.
     
  12. klaus

    klaus Expert Licensed User

    pxlTest is an Array of Ints (integers) not a String !
    Length is the length, number of items, of the Array !
    The count begins with 0 so the first item is pxlTest(0) and the last item is pxlTest(pxlTest.Length - 1).
    If you Dim an Array like Dim MyVariable(200) As Int, the last item in the array is MyVariable(199) and not MyVariable(200).
    MyVariable.Length = 200, but the last item is 199 so MyVariable.Length - 1.
     
    Fusseldieb likes this.
  13. Fusseldieb

    Fusseldieb Active Member Licensed User

    Oh, thanks!!
    Now I fully understand this :)
    Thanks for your time :D
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice