Hi,

Thanks for the response.  I have made progress, but have hit another
roadblock.

var db = google.gears.factory.create('beta.database');
var cv = google.gears.factory.create('beta.canvas');
var bb = google.gears.factory.create('beta.blobbuilder');

var rs = db.execute("SELECT title,height,width,hex(src),alt FROM
attachment WHERE id='"+ objectID +"'");
if (rs.isValidRow()){
        var objTitle = rs.field(0);
        var objHeight = rs.field(1);
        var objWidth = rs.field(2);
        var e16 = rs.field(3);
        var objAlt = rs.field(4);}
rs.close();
var d16 = decodeHex(e16);
var e64 = encodeBase64(d16);

Ok, so my first problem was that I had loaded a picture into an SQLite
database using a Firefox SQLite manager.  My first attempt with code
returned an unsupported data type.  So I had to hex() the actual
(binary? UTF-8?) data to yield a string of uppercase numbers and
letters.  For the most part, they all start with FFD8 FFE0 (a .jpg
file).  So I am able to pull out a hex string, decode it using a hex
decoder ("decodeHex"), which puts it back in its original form; then
we re-encode it to base64.  I was then able to use the "data:image/
jgp;base64," URI scheme and inline the photos right to the HTML.  So
this is what I wanted to originally do:  local database with tables,
maps, text, and images that is accessed by a web page, but the data
doesn't need to be sent over the tubes (map data excepted).

New problem: I want to inline images that are apparently too big (~1.2
mb) to inline.  How to get around this?
Question:  If I have a hex string, "FFD8FFE0...FFD9" that represents a
jpg, do I need to transform this string to be used as a blob to decode
into a canvas object?
examples I have tried:

var newBlob = bb.append(e16);
cv.decode(newBlob);

this works for encoded hex strings (e16) but then cannot decode
newBlob as an image.
and I cannot append a decoded string 'd16' which also throws an
error.

So I don't know if I need to do something with e16 (long hex string
without whitespace straight from database) in order to make it
accessible in a canvas object.  And once we get there, how do I make a
url to that object to set =src in and <img/>?

Many thanks.

On Jan 14, 1:29 am, Brahim M brahim <[email protected]> wrote:
> is the table test exists in your data base? and the field 0 and 1 have
> any data ? the code is clean but the data base i don't know how you
> did it .
>
> On 7 jan, 01:47, rosco <[email protected]> wrote:
>
>
>
> > hello;
>
> > I'm working on a web application that uses a locally stored gears/
> > sqlite database as the input unit.  So people who want to use this
> > site would create a gears/sqlite database created according to a
> > publicly available protocol ("schema"?) and then when they fired up
> > the site and they can use all the doo-dads that we built into the site
> > to analyze their information.  It it important that all of the data be
> > local an none on our server because the nature of the user is that
> > they would not want to share this information.  Anyone who wants to
> > share would simply ship the database to whomever.  Hopefully that is
> > not over-sharing, but may make it clear why I am trying to do what I
> > am trying to do and running into trouble.
>
> > So I used a firefox extension (SQLite Manager) to build a gears-ready
> > database.  one of the tables includes map images (.jpg).  The field in
> > the table that receives the binary data is defined as ablob, so I
> > have to assume that this data is in fact ablob.  Now what I need to
> > do is be able to extract thisblobfrom the gears database and display
> > it in an <img>.  I thought this was pretty simple, but has turned out
> > not to be.
>
> > var db = google.gears.factory.create('beta.database');
> > db.open('test');
> > var rs = db.execute("SELECT * FROM maps");
> > while (rs.isValidRow())
> >         {
> >         var description = rs.field(0);
> >         //we do something here with the description of the map
> > **      var data = rs.field(1);
> >         document.getElementById('mapGoesHere').src = data;
> >         rs.next()
> >         }
> > rs.close();
>
> > So I'm getting an 'unsupported data type' at **, and I have tried most
> > every combination of httprequest to localserver to desktop to canvas
> > method to try and access thisblobdata.  Also, I'm not an engineer by
> > training, so consider me an amateur (while not a novice).  Any
> > guidance or code samples or liquor would be appreciated.

Reply via email to