Java swing loads and displays images using image and bufferedimage

Source: Internet
Author: User
Image is an abstract column, and bufferedimage is the implementation of image.
Image and bufferedimage are mainly used to load a pair of images into the memory.
Java loads an image to the memory by using the following methods:
Java code  
  1. String imgpath = "C: // demo.jpg ";
  2. Bufferedimage image = ImageIO. Read (New fileinputstream (imgpath ));

This method can obtain detailed information about the image, for example, obtaining the image width: image. getwidth (null). The image can be further processed only when it is loaded into memory.

There is also a method for Java code 

  1. String imgpath = "C: // demo.jpg ";
  2. Image imagetoolkit. getdefatooltoolkit (). getimage (imgpath );

However, this method cannot load the image into the memory, but only obtains the image, so it cannot obtain the image information, and the image length and width cannot be obtained.

Article: http://javapub.iteye.com/blog/683944

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.