Igor,
haha i JUST changed this before i checked your email
to:
while ((status = sqlite3_step(statement)) ==
SQLITE_ROW)
{
std::cout << "status is: " << status <<
std::endl;
i++;
if(i == 1)
std::cout << "first row" << std::endl;
else
std::cout << "another row" << std::endl;
num_bytes = sqlite3_column_bytes(statement,
1);
num_bytes = num_bytes / sizeof(unsigned
short);
image = new unsigned short[num_bytes];
image = (const unsigned
short*)sqlite3_column_blob(statement, 1);
for(int j = 0; j < num_bytes; j++)
std::cout << "image " << j << ": " << image[j]
<< std::endl;
**************************************************
so i get the output correct back out now:
Output --
first row
image 0: 0
image 1: 3
image 2: 6
image 3: 9
image 4: 12
image 5: 15
image 6: 18
image 7: 21
image 8: 24
image 9: 27
another row
image 0: 0
image 1: 1
image 2: 2
image 3: 3
image 4: 4
image 5: 5
image 6: 6
image 7: 7
image 8: 8
image 9: 9
another row
image 0: 0
image 1: 1
image 2: 2
image 3: 3
image 4: 4
image 5: 5
image 6: 6
image 7: 7
image 8: 8
image 9: 9
***************************
-so it seems that despite my byte order being wrong?,
i get the output back out exactly how i stored it in
the original array. is there a problem here i should
be concerned about in the long run or why i should
change the order?
would like your response -- thanks!
oh yeah -
i am running on a Linux Ubuntu machine. the only big
endian machines now a days that i can think of are old
SGI's(didnt they switch to intel) and old mac's(which
now use intel(little endian)).
*****************************************************
--- Igor Tandetnik <[EMAIL PROTECTED]> wrote:
> C S <[EMAIL PROTECTED]> wrote:
> > thanks for all your help too man. here is what is
> in
> > the table images so far when i do a select. its 3
> > blobs:
> >
> > sqlite> select imageID, hex(imageData) from
> Images;
> > 1|00 0003 0006 0009 000C 000F 0012 0015 0018 001B
> 00
> > 2|00 0001 0002 0003 0004 0005 0006 0007 0008 0009
> 00
> > 3|00 0001 0002 0003 0004 0005 0006 0007 0008 0009
> 00
> >
>
*****************************************************
>
> I bet you are running on a little-endian machine. On
> such a machine, the
> low-order byte comes first. So the correct breakdown
> is
>
> 1|0000 0300 0600 0900 0C00 0F00 1200 1500 1800 1B00
>
> For example, two bytes 0300 represent a two-byte
> integer 3 in
> little-endian (least-significant byte first,
> most-significant last).
>
> > while ((status = sqlite3_step(statement)) ==
> > SQLITE_ROW)
> > {
> > i++
> >
> > num_bytes = sqlite3_column_bytes(statement, i);
>
> 'i' refers to the row index, and is incremented with
> each step. The last
> parameter to sqlite3_column_bytes is a _column_
> index: it doesn't change
> as you scan through rows. You always pass 0 to
> retrieve the first column
> (from the current row, whatever it happens to be), 1
> to retrieve the
> second column and so on.
>
> Your code just accidentally happens to pass a
> correct column index for
> the first row, but wrong index for all subsequent
> rows.
>
> Igor Tandetnik
>
>
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
>
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
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users