docs: public void sendData(HttpServletRequest req, HttpServletResponse res) 
          throws ServletException, IOException
      {
          String dataType = GIF_TYPE;
          res.setContentType(GIF_TYPE.equalsIgnoreCase(dataType) ? "image/gif" : "image/jpeg");
          OutputStream out = res.getOutputStream();
          String strParamField = this.getProperty("field");   // Display record
          ImageIcon imageIcon = null;
          Image image = null;
          int scaledW = 0;
          int scaledH = 0;
          if (strParamField != null)
          {
              Record record = ((DataAccessScreen)this.getScreenField()).getMainRecord();
              if (record != null)
              {
                  BaseField field = record.getField(strParamField);
                  if (field != null) if (!field.isNull())
                  {
                      if (field instanceof ImageField)
                      {
                          if (field.getData() instanceof ImageIcon)
                              imageIcon = (ImageIcon)field.getData();
                          else if (field.getData() instanceof PortableImage)
                          {
                              image = (Image)((PortableImage)field.getData()).getImage();
                              scaledW = ((PortableImage)field.getData()).getImageWidth();
                              scaledH = ((PortableImage)field.getData()).getImageHeight();
                          }
                      }
                  }                
              }
          }
          if ((imageIcon == null) && (image == null))
              imageIcon = new ImageIcon("images/icons/Noimage.gif", "Next button");
  
          if (imageIcon != null)
          {
              scaledW = imageIcon.getIconWidth();
              scaledH = imageIcon.getIconHeight();
              image = imageIcon.getImage();
          }
  
          BufferedImage outImage = new BufferedImage(scaledW, scaledH, BufferedImage.TYPE_INT_RGB);
          // Paint image.
          Graphics2D g2d = outImage.createGraphics();
          g2d.drawImage(image, null, null);
          g2d.dispose();
  
          ImageIO.write(outImage, dataType, out);
  /** This is the code (that works fine) when using the jai image encoder
          // This is the code to use with com.sun encoder:
          // JPEG-encode the image and write to file.
          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
  
          encoder.encode(outImage);
  /*
  /** This is the code (that works fine) when using the JAI toolkit
          ParameterBlock pb = new ParameterBlock();
          pb.add(image.getImage());
          
          // Create the AWTImage operation.
          PlanarImage im = (PlanarImage)JAI.create("awtImage", pb); // Store the image in the JPEG format.
          JPEGEncodeParam encodeParam = new JPEGEncodeParam();
          float fQuality = 1.0f;
          String strDestination = "test.gif";
          encodeParam.setQuality(fQuality);   // Medium quality
          JAI.create("encode", im, out, "JPEG", encodeParam);
  */
      }