Új hozzászólás Aktív témák

  • dabadab

    titán

    Mivel a cikkben lévő hibaleírás nem votl igazán érthető, kikerestem a konkrét kódot, ami elhasal:

    private int[] getHistogram(Bitmap grayscale) {
    int width = grayscale.getWidth();
    int height = grayscale.getHeight();
    // TODO: Fine tune the performance here, tracking on b/123615079.
    int[] histogram = new int[256];
    for (int row = 0; row < height; row++) {
    for (int col = 0; col < width; col++) {
    int pixel = grayscale.getPixel(col, row);
    int y = Color.red(pixel) + Color.green(pixel) + Color.blue(pixel);
    histogram[y]++;
    }
    }
    return histogram;
    }

    A probléma a histogram[y]++; sor, mivel itt a más color space miatt az y simán lehet nagyobb, mint 255, ami miatt túlszalad az index a tömbön, puff.

    [ Szerkesztve ]

    DRM is theft

Új hozzászólás Aktív témák