locked
How to store thumbnail (BitmapSource) in database? RRS feed

  • Question

  • Hi y'all!

    I'd like to store some of my photos' metadata in an sqlite database, especially the photos thumbnails, which I have as BitmapSource objects. What is the most appropriate, easiest and fastest way of doing so? Ì read somewhere that encoding a new BitmapFrame from the BitmapSource might do the trick, but then I would have to decode it back to a BitmapSource object, once I load it, right? If so, is there any alternative and faster way of doing this? My loadFromSQL function may get called pretty often and I'd like to minimize the load.

    Regards
    Wednesday, June 11, 2008 10:27 PM

Answers

  • You can get Bitmap pixels, by calling CopyPixels method and save pixels byte[] in database. This is not the fastest method, but it works and bullet proof.
    Tamir http://blogs.microsoft.co.il/blogs/tamir
    If your question was answered, please mark it.
    • Marked as answer by Marco Zhou Wednesday, June 18, 2008 10:26 AM
    Thursday, June 12, 2008 5:47 AM

All replies

  • You can get Bitmap pixels, by calling CopyPixels method and save pixels byte[] in database. This is not the fastest method, but it works and bullet proof.
    Tamir http://blogs.microsoft.co.il/blogs/tamir
    If your question was answered, please mark it.
    • Marked as answer by Marco Zhou Wednesday, June 18, 2008 10:26 AM
    Thursday, June 12, 2008 5:47 AM
  • Hey Tamir,

    thanks for your answer.
    The thing about the CopyPixels method is that I would also have to save the thumbnail's width, height and bits per pixel values to the database, in order to be able to reconstruct the thumbnail once I load it, right?
    Thursday, June 12, 2008 9:01 AM
  • No, it will save only original pixels of your image
    Tamir http://blogs.microsoft.co.il/blogs/tamir
    If your question was answered, please mark it.
    Thursday, June 12, 2008 9:17 AM