6
コンポーネントの内容とそのすべてのサブコンポーネントをビットマップに描画する必要があります。コンポーネントをビットマップにペイントする
public void printComponent(Component c, String format, String filename) throws IOException {
// Create a renderable image with the same width and height as the component
BufferedImage image = new BufferedImage(c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
// Render the component and all its sub components
c.paintAll(image.getGraphics());
// Render the component and ignoring its sub components
c.paint(image.getGraphics());
// Save the image out to file
ImageIO.write(image, format, new File(filename));
}
しかし、私は、このコンポーネントの唯一地域を描画するための方法を見つけることができませんでした:私は、コンポーネント全体を描きたい場合は 次のコードは完璧に動作します。
ビットマップの点0,0で始まるコンポーネントの領域を描画しません! – Arutha
私が設定したクリップは一例です。このリージョンをあなたに役立つものに設定する必要があります。 – dacwe
ポイント(100,100)から100×100のシエズで始まる領域を描画するには、100 * 100のサイズのビットマップを作成する必要があるため、setClipメソッドのパラメータは何ですか? – Arutha