Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't know what you mean with 0- or 1-indexed, but here are some facts.</p> <p><code>BufferedImage</code> is a generic image, so pixels start at coordinate (0,0)</p> <p>If you want an array to work on, coming from this image, the upper-left corner will be in index 0 (unless otherwise specified)</p> <p><code>image.getRGB(0, 0, image.getWidth(), image.getHeight(), array, 0, image.getWidth());</code></p> <p><code>BufferedImage</code> doesn't support 1 BPP images natively, but either via a <em>Packed</em> mode with a Colormodel, or a 2-index palette. I can't tell which one you have without examples. </p> <p>Regardless of the internal format, the different getRGB() methods should always return one value per pixel, and one pixel per value. Note that the full-opacity value (0xFF000000, -16777216) will also be included in results.</p> <p>eg.</p> <pre><code> BufferedImage image = new BufferedImage(16, 16, BufferedImage.TYPE_BYTE_BINARY); image.setRGB(0, 0, 0xFFFFFFFF); image.setRGB(1, 0, 0xFF000000); image.setRGB(0, 1, 0xFF000000); image.setRGB(1, 1, 0xFFFFFFFF); System.out.println(image.getRGB(0, 0)); System.out.println(image.getRGB(1, 0)); System.out.println(image.getRGB(0, 1)); System.out.println(image.getRGB(1, 1)); int[] array = image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth()); System.out.println(array[0]); // at (0,0) System.out.println(array[1]); // at (1,0) System.out.println(array[16]); // at (0,1) System.out.println(array[17]); // at (1,1) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload