我正在尝试使用以下方法将示例GRAL饼图导出为jpg:
private byte[] getJpg() throws IOException {
BufferedImage bImage = new BufferedImage(800, 600, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bImage.createGraphics();
DrawingContext drawingContext = new DrawingContext(g2d, DrawingContext.Quality.QUALITY,
DrawingContext.Target.BITMAP);
PiePlot plot = getPlot();
plot.draw(drawingContext);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bImage, "jpg", baos);
baos.flush();
byte[] bytes = baos.toByteArray();
baos.close();
return bytes;
}
但是它渲染成一个黑色矩形,并带有一些图例信息(图例没问题)。谁知道从GRAL绘图中正确地渲染JPG的方法?