Syntrax# Posted April 14, 2022 Share Posted April 14, 2022 Hello community, So i'm working on a user interface and have come up with a problem. I wanted to use profile images without having to download it. I've managed to get it by converting the image on https://www.base64-image.de/ . Now was the question if it is possible without having to use the website so the player can just insert a .png file texture = dxCreateTexture(pixels) encoded = base64Encode(texture) executeBrowserJavascript(webBrowser, "document.getElementById('orghomelogo').src='"..encoded.."';document.getElementById('homename').innerHTML = '" .. gangname .. "'") return Link to comment
Addlibs Posted April 14, 2022 Share Posted April 14, 2022 (edited) You need to base64Encode the output of dxGetTexturePixels(texture) not just texture itself, and you need to prepend "data:image/png;base64," to the encoded base64 if you want it to be interpreted as raw data rather than a URL. Edited April 14, 2022 by Addlibs 1 Link to comment
Syntrax# Posted April 14, 2022 Author Share Posted April 14, 2022 (edited) 21 minutes ago, Addlibs said: You need to base64Encode the output of dxGetTexturePixels(texture) not just texture itself, and you need to prepend "data:image/png;base64," to the encoded base64 if you want it to be interpreted as raw data rather than a URL. texture = dxCreateTexture(pixels) newpixels = dxGetTexturePixels(texture) encoded = "data:image/png;base64,"..base64Encode(newpixels).."" executeBrowserJavascript(webBrowser, "document.getElementById('orghomelogo').src='"..encoded.."';document.getElementById('homename').innerHTML = '" .. gangname .. "'") return Still nothing, it does not create the image ingame. Also not getting any error messages Edited April 14, 2022 by Syntrax# Link to comment
Addlibs Posted April 14, 2022 Share Posted April 14, 2022 Have you checked using toggleBrowserDevTools DOM inspector whether the JS executes correctly and updates the DOM, that is, whether the element #orghomelogo's src parameter is indeed what you expect it to be? 1 Link to comment
Syntrax# Posted April 14, 2022 Author Share Posted April 14, 2022 (edited) 14 minutes ago, Addlibs said: Have you checked using toggleBrowserDevTools DOM inspector whether the JS executes correctly and updates the DOM, that is, whether the element #orghomelogo's src parameter is indeed what you expect it to be? Nvm fixed it, thank you for the help. didn't need to get texture pixels as it already was like that. Topic can be closed Edited April 14, 2022 by Syntrax# Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now