Node Wish List

 From:  wayne hill (WAYNEHILL5202)
9581.42 
Looking for Javascript help on a new Node. It is a graphical image node. The graphic canvas has to be loaded as a Base64 encoded string.

The attached Node Editor example uses an encoded string to load the graphic of the elephant.



The goal is to use the UI file loader to locate the picture, then convert it to Base64 image code so it can be loaded to the node.

I have learned many ways of doing it wrong....

There are several online sources to do this conversion
Ref: https://www.base64-image.de/

What I am looking for is a method in Javascript for use on the Node Editor.

Here is a test program in HTML that will convert the information to the console.
How can it be converted for the Node Editor?


///////////////////////////////////////////////////
<!DOCTYPE HTML>
<html lang="en">

<head>
<script>
function toDataURL(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
var reader = new FileReader();
reader.onloadend = function() {
callback(reader.result);
}
reader.readAsDataURL(xhr.response);
};
xhr.open('GET', url);
xhr.responseType = 'blob';
xhr.send();
}
toDataURL('nav_logo.png', function(dataUrl) {
console.log('RESULT:', dataUrl)
})

</script>
</head>

</html>
///////////////////////////////////////////////


I have previously written a program in Delphi to do the same height map data collection so it is a matter of learning Javascript.

Thank you for any help.

Wayne

EDITED: 2 Oct 2020 by WAYNEHILL5202