Of course the image exists in the js file, so I opened flashblocker. js, browsed it, and found the following sentence:
Var flash = 'data: image/png; base64, iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAA ......'
() <SPAN style = "FONT-SIZE: small"> This is the first time I realized that base64 is useful. Remember that when I saved a webpage, I always used to save it. mht format, because this will save the images in the web page, but it has been wondering why only one </SPAN>
View sourceprint? <SPAN style = "FONT-SIZE: small">. the mht file is opened, but there are images. Now, when we know that the image is saved in the mht format, we convert all the images in the webpage into base64 strings. </SPAN>
View sourceprint? <SPAN style = "FONT-SIZE: small"> </SPAN> <SPAN style = "FONT-SIZE: small"> Implementation: </SPAN>
View sourceprint? <SPAN style = "FONT-SIZE: small"> </SPAN>
In fact, it is very simple. to Convert an image file to Base64String, you only need a ToBase64String method in the Convert class.
Copy codeThe Code is as follows:
Image fromImage = Image. FromFile (txtImg. Text );
MemoryStream stream = new MemoryStream ();
FromImage. Save (stream, imgFormat [extension]);
TxtString. Text = Convert. ToBase64String (stream. GetBuffer ());
It seems that the icon file cannot be converted (the result of your own test). If you need to convert the icon, you have to change it. The curve saves the country ~
To extract an image from Base64String, the Convert. FromBase64String () method is required,
Copy codeThe Code is as follows:
MemoryStream stream = new MemoryStream (Convert. FromBase64String (txtString. Text ));
Bitmap img = new Bitmap (stream );
Img. Save (txtImg. Text );
MessageBox. Show ("Completed! ");
It seems that some comrades encountered problems when switching back, and they thought it was a problem when defining stream. When new, they directly gave the converted byte [] to it, there should be no "beyond the expected range" error. Conversion Problems should be caused by the fact that the source image is generated in Java or other languages. Because base64 encoding is the same.
Author: Mr. Yi Xiu
Source: http://1971ruru.cnblogs.com