Android Question Read x,y from getPixels

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

  1. Fusseldieb

    Fusseldieb Active Member Licensed User

    I use getPixels() to get pixels from the entire image and I realize that I can read one pixel at a time defining 0,0 or 0,1 and so on, but everytime I use that funcion, it slows the app down. Knowing that, I want to read the entire image at once, store it into an Integer and read later with x and y.

    Dim p() As Int

    Here I read the entire image, but how can i later read an x and y coordinate? Like this:

    Obviously that doesn't work, but I can't figure out how to make that work.
  2. stevel05

    stevel05 Expert Licensed User

    From a quick test it appears that the returned array holds rows of pixels in sequence. So if the bitmap is 10 x 10, the contents of the array indices 0-9 will be row 1, 10 - 19 will be row 2 etc.

    So you can access each pixel as
    Pixels(X + Y * ImageWidth)
    Fusseldieb and DonManfred like this.
  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