We are attempting to convert a BufferedImage, to a standard Image. In
the code below, mSecondImage is a BufferedImage and imagea is an Image:

   imagea = toImage(mSecondImage);

This calls the toImage method, which is

   public static Image toImage(BufferedImage bufferedImage){
     return Toolkit.getDefaultToolkit().createImage
(bufferedImage.getSource());
     }

The toImage appears to complete the conversion, as we have previously
successfully written the resulting image imagea to jpg files.

The problem comes when we try to perform an operation on the pixel
array by getting the pixels with PixelGrabber. W do this with a
call to linearizeImage

    Image mSecondImageNotBuffered = linearizeImage(imagea, abVector);

linearizeImage is as follows:

private Image linearizeImage(Image i, Vector abVector)
{

 try {


  int width = i.getWidth(this);
  int height = i.getHeight(this);
  int pixels[] = new int [width * height];
  PixelGrabber pg = new PixelGrabber (i, 0, 0, width, height,
pixels, 0, width);
  if (pg.grabPixels() && ((pg.status() & ImageObserver.ALLBITS) !=0))
   {
    i = createImage (new MemoryImageSource (width, height,
linearizePixels
(pixels, width, height, abVector), 0, width));
   }
  else
  {
   System.out.println("Problem with pg.status()?" + pg.status() + " " +
ImageObserver.ALLBITS);
  }
 } catch (InterruptedException e)
 {
  e.printStackTrace();
 }
 return i;//return changed image
}

The height and width are coming back as valid numbers, as we've
succesfully
printed them.  However, in the PixelGrabber function, pixels seems to
be getting filled with 0's.  This may or
may not be the cause of our main error

    Problem with pg.status()=27

From what I understand, pg.status() returns the bitwise OR of all
the status
flags of the pixel grabber, and thus the following bit string 0001
1011 (27).
32  is the flag for ImageObserver.ALLBITS and corresponds to the
bitstring 0010
0000.  Therefore 0001 1011 & 0010 0000 = 0000 0000, presenting us with a
problem.  I guess we need the ALLBITS flag to be set in order for
this to pass.
 Any clue as to what is causing this behavior and possible solutions?

Thanks,
Tom


Thomas Busey, PhD
Associate Professor
Department of Psychology and Program in Cognitive Science
Indiana University, Bloomington
1101 E. 10th St
Bloomington, IN, 47405
(812) 855-4261
[EMAIL PROTECTED]
www.indiana.edu/~busey
AIM / IChat AV:  [EMAIL PROTECTED] (video feed)

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to