How to save Form into the picture!

zhaozj2021-02-08  247

Public void onsavejpg () {

Rectangle Rect = getBounds ();

BufferedImage Image =

(Bufferedimage) CreateImage (Rect.width, Rect.Height);

Graphics g = image.getgraphics ();

Paint (g);

g.dispose ();

Try {

FileOutputStream filestream =

New FileOutputStream ("E: //Test.jpg");

JPEGIMAGEENCODER ENCODER =

JPEGCODEC.CREATEJPEGENCODER (FILESTREAM);

Encoder.encode (image);

FileStream.close ();

} catch (exception e) {

System.out.Println ("Error Saving Jpeg File!");

}

}

转载请注明原文地址:https://www.9cbs.com/read-2992.html

New Post(0)