Jump to content

Base64 image encoder


Syntrax#

Recommended Posts

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

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 by Addlibs
  • Like 1
Link to comment
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 by Syntrax#
Link to comment
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 by Syntrax#
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...