}
static public void toFile(Context context, RgbImage rgb, int nQuality, String szPath)
throws IOException
{
OutputStream os = new FileOutputStream(szPath);
try {
Bitmap bmp = toBitmap(rgb);
Bitmap.CompressFormat format = Bitmap.CompressFormat.JPEG;
szPath = szPath.toLowerCase();
if (szPath.endsWith("jpg") || szPath.endsWith("jpeg")) { //$NON-NLS-1$ //$NON-NLS-2$
format = Bitmap.CompressFormat.JPEG;
} else if (szPath.endsWith("png")) { //$NON-NLS-1$
format = Bitmap.CompressFormat.PNG;
}
bmp.compress(format, nQuality, os);
} finally {
os.close();
}
}