Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm working on a windows8 machine, using IIS 8 and .NET 4.5.

I've created a WCF restful service that returns a BLOB as a JSON string byte[]. On my client side i get the images and i try to read them in the following manner:

getTileUrl: function (tilePoint, zoom, tile) {
    var z = this._getOffsetZoom(zoom);
    var x = tilePoint.x;
    var y = tilePoint.y;
    var base64Prefix = 'data:image/gif;base64,';
this.mbTilesDB.transaction(function(tx) {
        console.log("executing SQL!!!!");
        tx.executeSql("SELECT tile_data FROM images INNER JOIN map ON images.tile_id = map.tile_id WHERE zoom_level = ? AND tile_column = ? AND tile_row = ?", [z, x, y],function(tx,result){
            tile.src = base64Prefix + result.rows.item(0).tile_data; //.rows.item(0).tile_data;
        }, function (er) {
            console.log('error with executeSql', er);
        });
  }); 
},

I get the error message:

Failed to load resource data:image/gif;base64,137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,1,0…,237,255,1,100,245,49,110,153,90,168,241,0,0,0,0,73,69,78,68,174,66,96,130

I'm pretty sure that the item is stored in the wrong format. Ive been looking around but i can't find a clear example on how to parse a byte[] to a blob file. I'm developing on my desktop using Google chrome, but eventualy it will need to work in Phonegap.

So my question: How to i convert the byte[] to the correct BLOB format?

Thank you very much for your help

share|improve this question
 
Ok I Solved it. I'm returning a base64 string instead of a byte[]. tile_data = Convert.ToBase64String((byte[])r["tile_data"]), –  programmingheadaches Nov 13 at 9:29
 
If you want to use JS to solve the problem, maybe this article can help you: developer.mozilla.org/en-US/docs/Web/JavaScript/… –  LightStyle Nov 13 at 9:32
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.