// ----------------------------------------------------------
private void drawAWTImage(OutputStream outStr, int iThumbWidth, int iThumbHeight, float fQuality) throws IOException, InstantiationException, InterruptedException {
String sInputURI;
Frame awtFrame;
JPEGImageEncoder encoder;
JPEGEncodeParam param;
BufferedImage thumbImage;
Graphics2D graphics2D;
URL oURI;
if (DebugFile.trace) {
DebugFile.writeln("Begin Image.drawAWTImage([OutputStream], " + String.valueOf(iThumbWidth) + "," + String.valueOf(iThumbHeight) + "," + String.valueOf(fQuality));
DebugFile.incIdent();
}
sInputURI = getString(DB.path_image);
if (sInputURI.startsWith("http://") || sInputURI.startsWith("https://")) {
oURI = new URL(sInputURI);
if (DebugFile.trace) DebugFile.writeln("java.awt.Toolkit.getDefaultToolkit().getImage([java.net.URL])");
oImg = Toolkit.getDefaultToolkit().getImage(oURI);
}
else {
if (DebugFile.trace) DebugFile.writeln("java.awt.Toolkit.getDefaultToolkit().getImage(sInputURI)");
oImg = Toolkit.getDefaultToolkit().getImage(sInputURI);
}
int iImageWidth = oImg.getWidth(null);
int iImageHeight = oImg.getHeight(null);
double thumbRatio = ((double) iThumbWidth) / ((double) iThumbHeight);
double imageRatio = ((double) iImageWidth) / ((double) iImageHeight);
if (thumbRatio < imageRatio)
iImageHeight = (int)(iThumbWidth / imageRatio);
else
iThumbWidth = (int)(iThumbHeight * imageRatio);
if (null==mediaTracker) {
if (DebugFile.trace) DebugFile.writeln("new java.awt.;Frame()");
try {
awtFrame = new Frame();
} catch (Exception e) { throw new InstantiationException("Cannot instantiate java.awt.Frame " + (e.getMessage()!=null ? e.getMessage() : "")); }
if (DebugFile.trace) DebugFile.writeln("new MediaTracker([Frame])");
mediaTracker = new MediaTracker(awtFrame);