I have recently been playing around with googles API for generating QR codes and have thought, hey why not make one in graal.
So I went on my merry way to script it and this is what I have so far, but theres one huge problem... It doesnt display the image, instead it displays some sort of Binary Dump, any suggestions are appriciated.
In case you do not know what a QR code is
click here and it will explain it in greater depth, its a 2D image that stores Binary and can be read extremly fast, it was designed for car parts originally but when they realised how powerful it was they then went on to use it for alot more.
Im not even sure if this task can be achieved in the boundaries of GS2 but hey, its worth a shot.
My Script..
PHP Code:
//#CLIENTSIDE
function onCreated() {
Generate_Window.destroy();
Generated_Window.destroy();
}
function onPlayerChats() {
if (player.chat == "/generate") {
if (Generate_Window.visible == "1") {
Generate_Window.destroy();
return;
}
CreateGenGUI();
}
}
function CreateGeneratedGUI() {
new GuiWindowCtrl("Generated_Window") {
profile = GuiBlueWindowProfile;
clientrelative = true;
clientextent = "300, 250";
canclose = true;
canmaximize = false;
canminimize = false;
canmove = false;
canresize = false;
closequery = false;
destroyonhide = false;
isexternal = false;
text = "Generated QR Code";
x = screenwidth / 2 - width / 2;
y = screenheight / 2 - height / 2;
alpha = 1;
new GuiScrollCtrl("Generated_MultiLine_Scroll") {
profile = GuiBlueScrollProfile;
height = 249;
hscrollbar = "dynamic";
vscrollbar = "dynamic";
width = 300;
x = 0;
y = 0;
new GuiMLTextCtrl("Generated_MultiLine") {
profile = GuiBlueMLTextProfile;
height = 231;
horizsizing = "width";
text = "<center><br><br><br><br><br>Generating QR Code.<br>Please wait.";
width = 296;
}
}
}
}
function CreateGenGUI() {
new GuiWindowCtrl("Generate_Window") {
profile = GuiBlueWindowProfile;
clientrelative = true;
clientextent = "150,82";
canclose = false;
canmaximize = false;
canminimize = false;
canmove = true;
canresize = true;
closequery = false;
destroyonhide = false;
text = " QR Code Generator";
x = screenwidth / 2 - width / 2;
y = screenheight / 2 - height / 2;
new GuiTextEditCtrl("Generate_Encode") {
profile = GuiBlueTextEditProfile;
height = 20;
width = 137;
x = 7;
y = 23;
}
new GuiTextCtrl("Generate_Text") {
profile = GuiBlueTextProfile;
height = 20;
text = "Enter the text to encode!";
width = 139;
x = 6;
}
new GuiButtonCtrl("Generate_Generate") {
profile = GuiBlueButtonProfile;
text = "Generate";
width = 137;
x = 7;
y = 48;
}
}
}
function Generate_Generate.onAction() {
if (Generate_Encode.text != null) {
Generated_Window.destroy();
Generate_Window.destroy();
CreateGeneratedGUI();
Generated_MultiLine.text = "<center><br><br><br><br><br>Generating QR Code.<br>Please wait.";
temp.req = requesturl("http://chart.apis.google.com/chart?chs=150x150&cht=qr&chld=L|0&chl=" @ Generate_Encode.text @ "");
this.catchevent(temp.req, "onReceiveData", "onSiteDownloaded");
}
}
function onSiteDownloaded(obj) {
Generated_MultiLine.text = "<img src=" @ obj.fulldata @ ">";
}