Ken,

  thanks for your response. for cross platform, both
windows and linux are little endian and Macs now use
intel chips, so that is not an issue. i was just
making sure everyone knew i wasnt just developing for
windows. 

about storing them as shorts -- i was under the
impression(at first) that sqlite wanted then data as
bytes but in my code that i just sent, i changed it
via a suggestion from Fin Springs(thanks again). 

please take a look at my code and tell me what is
wrong. i just got thrown into this sql stuff and
trying to learn it on the fly here. much appreciated. 


--- Ken <[EMAIL PROTECTED]> wrote:

> In addition to what Igor mentions:
> 
> If you want this array to be cross platform portable
> from Big endian to Little endian you either need to
> store some type of endianness flag.
> 
> If you dig into the sqlite source you'll find a
> function like sqlite3_put_varint.
> 
> It will convert 32 bit or 64 bit unsinged integers
> into a portable byte string.
> returning the number of bytes back that the string
> consumes. 
> You could then create a struct/type as follows
> struct {
>     uint8_t  bytes;
>     uint8_t  buf[3];
> }  vint;
> 
> vint.bytes = sqlite3_put_varint (&vint.buf, 
> yourShort );
> 
> then write the entire vint to the BLOB...
> 
> Retrieve the blob as normal. Then unload the shorts
> use the invers function.
> 
> But this seems like a lot of extra work to me.
> 
> Why not create a table that has the integer value
> and insert the data? One row per array element ????
> 
> HTH
> 
> C S <[EMAIL PROTECTED]> wrote: hi all i have a
> question regarding Blobs, that is
> storing images into the database. 
> 
> my image by default is an unsigned short array and
> to
> bind blobs it wants a byte array. i am not sure i am
> doing this right at all. is there a universal cross
> platform way for this easy conversion? 
> 
> so far the code i have is:
> .........
> char *byteArray = (char *) malloc((size * 2) *
> sizeof(char));
> .........
> 
> for(unsigned int i = 0; i < index < size; i++)
> {
>  byteArray[2 * index] = (char)buffer[index];
>  byteArray[(2 * index) + 1] = ( (char) buffer[index]
> >> 1);
> 
> then i prepare the statement which is successful
> then:
> 
> status = sqlite3_bind_blob(statement, 1, byteArray,
> size * 2, free);
> 
> some questions i have: i get an error of '25' back
> from status and looking on the sqlite documention it
> says the 2nd parameter to sql bind was out of range.
> i
> have no idea how the 2nd parameter can be out of
> range. 
> 
> my next question is once you have the blob in the
> database how in the world do you read it back out?
> of
> course when i do read it back out i will need to
> convert it back to a short array to be able to use
> it.
> 
> 
> i am using C++(g++ compiler) on linux. thanks in
> advance! 
> 
> 
>      
>
____________________________________________________________________________________
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
>
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
>
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 



      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to