You can use the sample that is in my blog article, the only change you would need to make would be to save the file(s) from the database to the image cache first. Then you can open them as the article describes.
David Cilley
My AJAX Imaging BlogAtalasoft Development Team