title: Dynamically set the size of buffered image
body: <p>I'm using this to set the size of my buffered image.</p>
  
  <pre><code>Dimension imgDim = new Dimension(700, 380);
  
  BufferedImage gridImage = new BufferedImage(imgDim.width, imgDim.height,
      BufferedImage.TYPE_INT_RGB);
  </code></pre>
  
  <p>instead of this, I would like to set the size of the image using something like:</p>
  
  <pre><code>Dimension imgDim = d;
  
  BufferedImage gridImage = new BufferedImage(d.width/8, d.height/8,
      BufferedImage.TYPE_INT_RGB);
  </code></pre>
  
  <p>but I'm getting <code>negativeArraySizeException</code></p>
  
  <p><code>d</code> is the dimensions of my <code>JFrame</code> which I'm getting using <code>getMaximumSize()</code> method</p>
  
  <p>when I print out the value of <code>d.width/8</code> its something like 268435455 which I can't make sense of. Is there another way to do this please help </p>
  
  <p>Thank you </p>