Get image method

xiaoxiao2021-03-05  18

Similar to the HTML code, the IE kernel has a "download-> decoded-> display" process for the IE kernel. Considering the abstraction of the display code, there is a variety of image formats, including JPG, GIF, PNG, TIFF, etc., which are unified in the bitmap format after decoding, and the original format data is from decoding Released in memory, only file backups in the Cache of IE. If you do not allow local Cache, you don't even have this backup. When IE is selected by right-button, the picture is saved as ... ", it is actually copying the file backup in cache. If there is no backup in Cache, you can only save the bitmap (*." BMP). Now I understand why some pictures are clearly a JPG format, but I can only save it to "no title. BMP" with IE? Therefore, it is rare to get the image file more than getting the HTML file. Moreover, it is clear in the MSDN. You can only get the link link with the IHTMLDocument2 interface. Use MIME Filter to get image data in the web page, so you need to find another way. I have thought about it, I have tried: first copy the image to the clipboard, then get the image data from the clipboard, then encode into the original image format according to the image file extension (can be parsed from the URL of the image element), including JPG, PNG, GIF, TIFF, etc. This method is relatively simple, to the MSDN KB search Q293125, copy images to the existing source code of the clipboard, the source code of the image encoding can refer to CXIMAGE, this is also Google. However, this method is far from being perfect: a). For PNG, GIF, etc., which allows the transparent background, which is not transparent to use this method. b). After the GIF animation is handled, it can only display one of the frames. c). For the lossless compression format of JPG, each compression is lost once, and more compressed several times may not be seen. d) In the e-book, the clipboard can be invalidated by standard Windows API functions. Navigate the IE kernel to the image, then get the copy of the picture via the iViewObject interface. This method is basically the same as the above method, but the image can be prevented from being blocked because the clipboard is blocked by the clipboard. Use the IE image decoding plugin. After the IE core is downloaded to some format image file, the corresponding decoder is called, and the image is decoded (similar to MIME Filter). For ease of expansion, the decoder is in the form of a plugin. If you do an image decoder plugin, intercept the decoding request, you can get the original image format data before decoding. The interface of the decoder, the implementation method does not have any clues in the Microsoft public code, but in the legendary source code, there is not only a detailed interface specification, but there are several embedded image decoders to implement code for reference. . Surprisingly, although I can't find it in MSDN, I found a Japanese in my own personal website, I have given a detailed image decoder plug-in implementation method. Step by step. It is very clear, and the amount of money is December 2002! It seems that this source of leaks may be better than imagined. Of course, this Japanese may also work in Microsoft, or have a partnership with Microsoft, which can be seen that the decoder source code is also impact.

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

New Post(0)