@Override public boolean drawImage(Image img,int x,int y,int width,int height,Color bgcolor,ImageObserver observer){
  try {
    int[] pixels=new int[width * height];
    PixelGrabber grabber=new PixelGrabber(img,0,0,width,height,pixels,0,width);
    grabber.grabPixels();
    ColorModel model=ColorModel.getRGBdefault();
    m_printstream.println("gsave");
    m_printstream.println(xTransform(xScale(x)) + " " + (yTransform(yScale(y)) - yScale(height))+ " translate");
    m_printstream.println(xScale(width) + " " + yScale(height)+ " scale");
    m_printstream.println(width + " " + height+ " "+ "8"+ " ["+ width+ " 0 0 "+ (-height)+ " 0 "+ height+ "]");
    m_printstream.println("{<");
    int index;
    for (int i=0; i < height; i++) {
      for (int j=0; j < width; j++) {
        index=i * width + j;
        m_printstream.print(toHex(model.getRed(pixels[index])));
        m_printstream.print(toHex(model.getGreen(pixels[index])));
        m_printstream.print(toHex(model.getBlue(pixels[index])));
      }
      m_printstream.println();
    }
    m_printstream.println(">}");
    m_printstream.println("false 3 colorimage");
    m_printstream.println("grestore");
    return true;
  }
 catch (  Exception e) {
    e.printStackTrace();
    return false;
  }
}

@ Override public boolean drawImage ( Image img , int x , int y , int width , int height , Color bgcolor , ImageObserver observer ) { try { int [ ] pixels = new int [ width * height ] ; PixelGrabber grabber = new PixelGrabber ( img , 0 , 0 , width , height , pixels , 0 , width ) ; grabber . grabPixels ( ) ; ColorModel model = ColorModel . getRGBdefault ( ) ; m_printstream . println ( "gsave" ) ; m_printstream . println ( xTransform ( xScale ( x ) ) + " " + ( yTransform ( yScale ( y ) ) - yScale ( height ) ) + " translate" ) ; m_printstream . println ( xScale ( width ) + " " + yScale ( height ) + " scale" ) ; m_printstream . println ( width + " " + height + " " + "8" + " [" + width + " 0 0 " + ( - height ) + " 0 " + height + "]" ) ; m_printstream . println ( "{<" ) ; int index ; for ( int i = 0 ; i < height ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { index = i * width + j ; m_printstream . print ( toHex ( model . getRed ( pixels [ index ] ) ) ) ; m_printstream . print ( toHex ( model . getGreen ( pixels [ index ] ) ) ) ; m_printstream . print ( toHex ( model . getBlue ( pixels [ index ] ) ) ) ; } m_printstream . println ( ) ; } m_printstream . println ( ">}" ) ; m_printstream . println ( "false 3 colorimage" ) ; m_printstream . println ( "grestore" ) ; return true ; } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } }
ps see http : / / astronomy . swin . edu . au / ~ pbourke / geomformats / postscript / java http : / / show . docjava . com : 8086 / book / cgij / doc / ip / graphics / simpleimageframe . java . html
