P Kishor wrote:
On 12/7/07, Igor Tandetnik <[EMAIL PROTECTED]> wrote:
P Kishor <[EMAIL PROTECTED]> wrote:
folks, I have never worked with BLOBs, but am now going to. Feel a
bit nervous.

Here is a question -- what if I have a rather large image and I want
only a certain part of it? Let me give an example -- say, I want to
store an image of the entire US, but when I want to see only Hawaii, I
ask SQLite to fetch the portion of the image with a certain bounding
box, say, the rect of Hawaii.
SQLite of course knows nothing about images. As far as it's concerned,
you are storing an array of bytes - it couldn't care less if it contains
image data or not. So you cannot directly ask it to retrieve a portion
of the image.


well, I used image as an example because I was interested in image. I
guess, the same logic could be applied to any other BLOB.

Recent versions of SQLite allow retrieving contiguous segments of the
BLOB, given an offest and length. If you store your image as an
uncompressed bitmap, then each scanline is stored as a contiguous
segment. Given a rectangle, you can retrieve each scanline of the
portion you are interested in, then compose them in memory into the
final image.

Ahhh.... so this is the path to pursue. Good to know that. Now to find
someone who has actually done that. :-)

Having said that, SQL database is probably a wrong tool for image
manipulation.


You are correct. But I don't want to manipulate the image with SQLite
(or any SQL db). I just want to store and retrieve it efficiently.
Storing images as files certainly precludes being able to find just
*that* particular rect and extract it out of a file. One would have to
experiment with many image tile size, so on, so forth. Thinking of an
image not as an image but as an array of bytes intuitively seems to be
the right direction to be thinking in.

Many thanks,

Puneet.

Look at Google maps for inspiration.

If you did not want to store an images as many tiles you would only have one image and would keep it in one file, not a DB. You could keep spacial refs in your DB and use the parameters to extract fragments from an image stored in a simple x-y format like a BMP.

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to