





v0.2 Stable Release - 28/8/2011 No bugs fixed from BETA version v0.2 BETA - 28/8/2011 No bugs found v0.2 ALPHA - 27/8/2011 Custom Image feature with some minor UI updates v0.1 Stable Release - 19/8/2011 Stable version released, 1 bug fixed from 0.1 BETA v0.1 BETA - 19/8/2011 - Added image support for sizes larger than 45x45, Image preview on Position selector v0.1 ALPHA - 17/8/2011 - basic release version
Summary Status Importance Last Updated
#1 None of the upload method works if the page is "still loading" Confirmed High 17/09/2011
#2 Some .PNG images do not convert - instead return "undefiled" Confirmed Critical 30/09/2011



<script type="text/javascript">
window.onerror = function(msg, err_url, line)
{
alert('an error occured on line: ' + line);
};
window.addEvent('load', function() {
var canvas = document.getElementById("canvas");
var file = document.getElementById("file");
file.onchange = function() {
var reader = new FileReader();
reader.onload = function(e) {
img = new Image();
img.onload = function()
{
if (image_uploaded_drag === false)
{
image_uploaded = true;
image_uploade_browse = true;
canvas.width = img.width;
canvas.height = img.height;
context = canvas.getContext("2d");
context.drawImage(img, 0, 0);
context1.drawImage(img, pos_x, pos_y);
}
else
{
alert("You already uploaded a image with \"Drag and drop method\", please refresh the page if you want to use \"Browse file method\"");
}
};
img.src = e.target.result;
};
reader.readAsDataURL(file.files[0]);
};
});
window.onload = function() {
image_uploaded = false;
image_uploaded_browse = false;
image_uploaded_drag = false;
pos_x = 0;
pos_y = 0;
canvas1 = document.getElementById("canvas1");
context1 = canvas1.getContext("2d");
document.getElementById("refresh_image").style.visibility = "hidden";
}
function Create2DArray(rows) {
var arr = [];
for (var i = 0; i < rows; i++) {
arr[i] = [];
}
return arr;
}
function change_pic()
{
custom_url = prompt("Enter URL of your custom Image","http://");
document.getElementById("canvas1").style.backgroundImage="url(" + custom_url + ")";
document.getElementById("refresh_image").style.visibility = "visible";
}
function refresh_click()
{
document.getElementById("canvas1").style.backgroundImage="url(screen.png)";
document.getElementById("refresh_image").style.visibility = "hidden";
}
function point_it(event) {
if (image_uploaded === true) {
pos_x = event.offsetX ? (event.offsetX) : event.pageX - document.getElementById("canvas1").offsetLeft;
pos_y = event.offsetY ? (event.offsetY) : event.pageY - document.getElementById("canvas1").offsetTop;
context1.clearRect(0, 0, canvas1.width, canvas1.height);
context1.drawImage(img, pos_x, pos_y);
document.getElementById("form_x").value = pos_x;
document.getElementById("form_y").value = pos_y;
}
else {
alert("Upload a image first");
}
}
function convert() {
if (image_uploaded === true) {
richtextbox3 = document.getElementById("samp_main");
//get image properties | Image size limit : 45x45 pixels
height = img.height;
width = img.width;
var imgDat;
textdraw_name = "null";
final_color = new Array(height * width);
x_axis_final = new Array(height * width);
y_axis_final = new Array(height * width);
status_used = new Array(height * width);
img_width = width + 1;
pre_text = "\n//Converted using BSN Image2Textdraw Converter Online \n#include<a_samp>\n#define USED_DRAWS " + height * width + "\nenum textdraw\n{\n\tText:id,\n\tused\n}\nnew TextDrawInfo[USED_DRAWS][textdraw];\npublic OnFilterScriptInit()\n{\n";
pixels = 0;
for (i = 0; i <= height; i++) //i = constant for first loop j is changing therefore j = horizontal scanning i = vertical scanning
{
for (j = 0; j <= width; j++) {
imgDat = context.getImageData(j, i, 1, 1); // now j=x axis i=y axis
final_color[j * img_width + i] = "0x" + dec2hex(imgDat.data[0]) + dec2hex(imgDat.data[1]) + dec2hex(imgDat.data[2]) + "ff";
if (imgDat.data[3] === 0) {
status_used[j * img_width + i] = "0";
}
else {
status_used[j * img_width + i] = "1";
pixels = pixels + 1;
}
x_axis_final[j * img_width + i] = pos_x + j;
y_axis_final[j * img_width + i] = pos_y + i;
}
}
if (pixels <= 2048)
{
string = new Array(width * height);
for (k = 0; k < height * width; k++) {
string[k] = "\tTextDrawInfo[" + k + "][id] = TextDrawCreate(" + x_axis_final[k] + "," + y_axis_final[k] + ",\".\");TextDrawTextSize(TextDrawInfo[" + k + "][id],1,1);TextDrawSetShadow(TextDrawInfo[" + k + "][id],0);TextDrawFont(TextDrawInfo[" + k + "][id],2);TextDrawColor(TextDrawInfo[" + k + "][id]," + final_color[k] + ");TextDrawInfo[" + k + "][used] = " + status_used[k] + ";";
}
post_text = "\n\n\treturn 1;\n}\npublic OnPlayerConnect(playerid)\n{\n\tfor(new i = 0;i<USED_DRAWS;i++)\n\t{\n\t\tif(TextDrawInfo[i][used] == 1){TextDrawShowForPlayer(playerid,TextDrawInfo[i][id]);}\n\t}\n\treturn 1;\n}\n\npublic OnFilterScriptExit()\n{\n\tfor(new i = 0;i<USED_DRAWS;i++)\n\t{\n\t\tif(TextDrawInfo[i][used] == 1){TextDrawDestroy(TextDrawInfo[i][id]);}\n\t}\n\treturn 1;\n}";
richtextbox3.innerHTML = pre_text + string.join("\n") + post_text;
}
else
{
alert("Your selected image had " + pixels + " non-transparent pixels, but SA:MP allows 2048 pixels. Try uploading a image with less number of non-transparent pixels");
}
}
else {
alert("Upload a image first");
}
}
dec2hex = function(d) {
var s = "00" + Number(d).toString(16);
return s.substring(s.length - 2);
};
</script>
|
Keep getting errors @ lines 119 and 262...Lol... I tried like 10 icons that are smaller than 45x45 o_O
|



|
Its because the SA-MP textdraws are scaled on 640x480 resolution, bigger resolutions will "stretch" the textdraws. It looks so stretched because he's probally using a widescreen and the 640x480 scale is a "squar".
|
|
"Inspired from the gamerX's image2textdraw converter"
Uchum... 1. My name is Gamer931215, not GamerX... 2. Next time please ask for permision to use my idea/script 3. "but it has nothing to do with the code which gamerX used nor the logic" - It still uses the same enum/textdraw names and method and idea... 3. Please add a link to the original ![]() |
that was your idea and I will add a link in credits.|
Its a pretty nice script though and faster as c#'s bitmaps
![]() Good job on that! Btw since its posted on the "release" section of sa-mp i think you must include the source as well according to the rules... |
Source Code? Its a online JavaScript application, you just have to right click on my webpage and click "View source" that would show u everything I did..|
Tip/Question: Does it remove transparency as well? Also if it does don't limit the image size to 45x45! Because some larger images COULD contain a lot transparency.
|
|
But still... if you want to reduce the ammount of textdraws, want to adjust the transparency or want to select the location more accurate i still recommend using my standalone app
![]() |
|
Everyone has it's own ways gamer, stop pushing people to your application, even if it's better, let em choose.
|
i was just eehm... promoting myself a bit :$ sorry
il inspect the source a bit
|
Anyway im wondering how you got the colors/stuff in javascript
il inspect the source a bit ![]() |
|
0.1 Stable version released, added new features like image preview on position selector and removal of 45x45 size limit.
|


|
Nice updates, i like the image preview on position
![]() I might see more in an online version then my c# app since javascript seems to be A LOT faster. |

|
Edit: the link in the menu on your website fails, it goes to "http://bsndesign.wesb.com/image2textdraw.htm" instead of "http://bsndesign.webs.com/image2textdraw.htm".
|
looks crazy nice, i'm going test