tailieunhanh - D Image Loading

Bạn đã thấy cách dễ dàng là để hiển thị một hình ảnh trên màn hình và có thể đoán rằng có nhiều đang xảy ra đằng sau hậu trường. Các getImage () và drawImage () phương pháp kích hoạt một loạt các sự kiện mà kết quả là hình ảnh đang được sẵn sàng cho hiển thị trên ImageObserver. Hình ảnh được lấy không đồng bộ trong chủ đề khác. * Toàn bộ quá trình diễn ra như sau: 1. Các cuộc gọi đến getImage () gây nên Toolkit để gọi createImage () cho InputStreamImageSource của hình ảnh (mà. | In this appendix How Images are Loaded A Brief Tour of D Image Loading How Images are Loaded You have seen how easy it is to display an image on screen and have probably guessed that there s more going on behind the scenes. The getImage and draw-Image methods trigger a series of events that result in the image being available for display on the ImageObserver. The image is fetched asynchronously in another thread. The entire process goes as follows 1. The call to getImage triggers Toolkit to call createImage for the image s InputStreamImageSource which is a URLImageSource in this case it would be a FileImageSource if we were loading the image from a local file . 2. The Toolkit registers the image as being desired. Desired just means that something will eventually want the image loaded. The system then waits until an ImageObserver registers its interest in the image. 3. The drawImage method use of MediaTracker or prepareImage registers an ImageObserver as interested. 4. Registering an ImageObserver kicks the image s ImageRepresentation into action this is the start of the loading process although image data isn t actually transferred until step 9. ImageRepresentation implements the ImageConsumer interface. 5. The start of production registers the image source ImageProducer URLImageSource with the ImageFetcher and also registers the ImageRepresentation as an ImageConsumer for the image. This summary covers Sun s implementation JDK . Implementations that don t derive from the JDK may behave completely differently. 1017 1018 Appendix D Image Loading 6. The ImageFetcher creates a thread to get the image from its source. 7. The ImageFetcher reads data and passes it along to the InputStreamImageSource which is a URLImageSource. 8. The URLImageSource determines that JPEGImageDecoder is the proper ImageDecoder for converting the input stream into an Image. Other ImageDecoders are used for other image types like GIF. 9. The ImageProducer starts reading the .

TỪ KHÓA LIÊN QUAN