Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Make sure you are using the correct color model for reading and writing.</p> <p>According to the <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html#getRGB%28int,%20int,%20int,%20int,%20int%5B%5D,%20int,%20int%29" rel="nofollow">BufferedImage.getRGB() documentation</a>, </p> <blockquote> <p>Returns an array of integer pixels in the default RGB color model (TYPE_INT_ARGB) and default sRGB color space, from a portion of the image data. Color conversion takes place if the default model does not match the image ColorModel. There are only 8-bits of precision for each color component in the returned data when using this method. With a specified coordinate (x, y) in the image, the ARGB pixel can be accessed in this way:</p> </blockquote> <pre><code>pixel = rgbArray[offset + (y-startY)*scansize + (x-startX)]; </code></pre> <p><strong>[Edit]</strong></p> <p>You need to use the constructor <code>BufferedImage(width, height, type, ColorModel)</code>, as indicated in the <a href="http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html#TYPE_BYTE_BINARY" rel="nofollow">Javadoc for your image type</a> (<code>TYPE_BYTE_BINARY</code>):</p> <blockquote> <p>When this type is used as the imageType argument to the BufferedImage constructor that takes an imageType argument but <strong>no ColorModel argument, a 1-bit image is created</strong> with an IndexColorModel with two colors in the default sRGB ColorSpace: {0, 0, 0} and {255, 255, 255}.</p> <p>Images with 2 or 4 bits per pixel may be constructed via the <strong>BufferedImage constructor that takes a ColorModel argument</strong> by supplying a ColorModel with an appropriate map size.</p> </blockquote> <p>(emphasis mine)</p>
    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. 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.
 

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