public static Image convertToArdor3DImage(BufferedImage bImage,boolean flip){
  WritableRaster raster=bImage.getRaster();
  ImageDataFormat format=ImageDataFormat.RGBA;
  if (bImage.getType() == BufferedImage.TYPE_4BYTE_ABGR) {
    swapBytes(raster.getDataBuffer());
    format=ImageDataFormat.BGRA;
  }
 else   if (bImage.getType() == BufferedImage.TYPE_INT_ARGB_PRE) {
    swapBytes(raster.getDataBuffer());
    format=ImageDataFormat.RGBA;
  }
 else   if ((bImage.getType() == BufferedImage.TYPE_INT_RGB) && Dert.isMac) {
    swapBytes(raster.getDataBuffer());
    format=ImageDataFormat.RGB;
  }
 else   if (bImage.getType() == BufferedImage.TYPE_3BYTE_BGR) {
    format=ImageDataFormat.BGR;
  }
 else   if (bImage.getType() == BufferedImage.TYPE_BYTE_GRAY) {
    format=ImageDataFormat.Luminance;
  }
  return (convertToArdor3DImage(raster,bImage.getColorModel(),format,flip));
}

public static Image convertToArdor3DImage ( BufferedImage bImage , boolean flip ) { WritableRaster raster = bImage . getRaster ( ) ; ImageDataFormat format = ImageDataFormat . RGBA ; if ( bImage . getType ( ) == BufferedImage . TYPE_4BYTE_ABGR ) { swapBytes ( raster . getDataBuffer ( ) ) ; format = ImageDataFormat . BGRA ; } else if ( bImage . getType ( ) == BufferedImage . TYPE_INT_ARGB_PRE ) { swapBytes ( raster . getDataBuffer ( ) ) ; format = ImageDataFormat . RGBA ; } else if ( ( bImage . getType ( ) == BufferedImage . TYPE_INT_RGB ) && Dert . isMac ) { swapBytes ( raster . getDataBuffer ( ) ) ; format = ImageDataFormat . RGB ; } else if ( bImage . getType ( ) == BufferedImage . TYPE_3BYTE_BGR ) { format = ImageDataFormat . BGR ; } else if ( bImage . getType ( ) == BufferedImage . TYPE_BYTE_GRAY ) { format = ImageDataFormat . Luminance ; } return ( convertToArdor3DImage ( raster , bImage . getColorModel ( ) , format , flip ) ) ; }
convert a java bufferedimage to an ardor3d image .
