Note that there are some explanatory texts on larger screens.

plurals
  1. POBufferedImage & ColorModel in Java
    primarykey
    data
    text
    <p>I am using a image processing library in java to manipulate images.The first step I do is I read an image and create a <code>java.awt.Image.BufferedImage</code> object. I do it in this way,</p> <pre><code>BufferedImage sourceImage = ImageIO.read( new File( filePath ) ); </code></pre> <p>The above code creates a <code>BufferedImage</code> object with a <code>DirectColorModel</code>:</p> <blockquote> <p>rmask=ff0000<br> gmask=ff00<br> bmask=ff<br> amask=0. </p> </blockquote> <p>This is what happens when I run the above code on my macbook.</p> <p>But when I run this same code on a linux machine (hosted server), this creates a <code>BufferedImage</code> object with <code>ColorModel</code>: </p> <blockquote> <p>pixelBits = 24<br> numComponents = 3<br> color space = java.awt.color.ICC_ColorSpace@c39a20<br> transparency = 1 has alpha = false<br> isAlphaPre = false.</p> </blockquote> <p>I used the same jpg image in both the cases. I don't know why the <code>ColorModel</code> of the same image is different when run on mac and linux. The <code>ColorModel</code> for mac has 4 components and the colormodel for linux has 3 components. </p> <p>There is a problem arising because of this, the image processing library that I use always assumes that there are always 4 components in the ColorModel of the image passed, and it throws an array out of bounds exception when run on the linux box. But on macbook, it runs fine.</p> <p>Adding a little more info, Once the image is read, I printed out <code>image.getType()</code></p> <ul> <li>On mac -> it returns <code>TYPE_INT_RGB</code> (a value of <code>1</code>)</li> <li>On linux -> it returns <code>TYPE_3BYTE_BGR</code> (a value of <code>5</code>)</li> </ul> <p>I am not sure if I am doing something wrong or there is a problem with the library. Please let me know your thoughts. Also ask me any questions if I am not making sense!</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.
 

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