Reputation: 4031
I get my value like this
var dataView= new DataView(imgData.array.buffer);
var st = dataView.getUint8(1).toString(10);
Which gives me the value 216 decimal. How can I transform varibale st to (hex 0xD8).
When i have to 0xD8 how can I transform it to short and long!
Upvotes: 0
Views: 2528
Reputation: 145458
I guess this is the way to go:
var st = "0x" + dataView.getUint8(1).toString(16).toUpperCase();
Upvotes: 3
Reputation: 3020
I think you should use 16 instead of 10 as arguement to toString()
http://www.w3schools.com/jsref/jsref_tostring_number.asp, see radix
parameter
Upvotes: 0
Reputation: 16571
Use a different base in the toString call:
var dataView= new DataView(imgData.array.buffer);
var st = dataView.getUint8(1).toString(16);
Upvotes: 3