Is it possible to display an encrypted base64 image in a JTextPane?
Here is my code
JTextPane jTextPane = new JTextPane(); javax.swing.text.html.HTMLEditorKit eKit = new javax.swing.text.html.HTMLEditorKit(); jTextPane.setEditorKit(eKit); jTextPane.setContentType("text/html"); // my base64 image, used then in the img tag in the html... String img64="data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7"; jTextPane.setText(html);
What you need to do is parse the Base64 encoded image into an array of bytes, and then load the image using ByteArrayIn, putStream using this byte array.
As an example, to decode Base64 you can use javax.xml.bind.DatatypeConverter # parseBase64Binary
I found out!
HTMLEditorKit getViewFactory javax.swing.text.html.HTMLEditorKit ImageViewclass.java loadImage base64!
, , "loadimage". [src= "foo" ] , . , "JTextPane.setEditorKit( MyExtendedHtmlEditorKit());".
. "ImageViewer.class create() [HtmlFactory.class( ) [HtmlEditorKit.class]] > void loadImage() [ImageViewer.class]" , . , , , . Java VM, . , , , !
Source: https://habr.com/ru/post/1743311/More articles:Reading the correct (alpha) number fields in R - rWhat is 1 dollar in Perl? - regexHow to use nose covering with -timid flag - pythonHow to access a memory cell in Java? - javaApp release. Designed on one account, releasing / approving another. - iphoneWCF ChannelFactory vs. SOA Principles? - soaHow to transfer SQLite db to a web server on an Android phone - androidStarting activity from a remote service - androidHow can I extract a DNA sequence using a Perl script from UCSC if I have their coordinates? - perlHow to get app engine debugging? - pythonAll Articles