Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Loading an image into the WebThumbnailViewer using the Open method

Last post 12 Oct 2007, 9:50 AM by garym. 7 replies.
Sort Posts: Previous Next
  •  09 Oct 2007, 4:16 PM 12639

    Loading an image into the WebThumbnailViewer using the Open method

    Hi All,

      I have downloaded, and am using, the evaluation version of DotImage 5.0d SDK w/OCR.

    The web application that I am writing has some design constraints that I am trying to overcome.  I want the application to look and act like the demo application found here: http://www.atalasoft.com/ajaxviewer/  The thumbnails should be displayed along the left margin and the full image of the selected thumbnail should be displayed in the image control.  In the design of the application we can not have the images cached on the server ( So OpenUrl is not an option ).

     My web application has to be designed in such a way that we are retrieving images to a front end application via asynchronous methods for performance reasons.  So, when the Page_Load method is executed I don't have any images to load into the WebThumbnailViewer control.  The page is supposed to be rendered and the images should be loaded during a callback.

    I have this working to some degree...

    I have written a method (in C# - executed on the server) that is invoked by JavaScript in the web page via the [RemoteInvoke] hook in the WebImageViewer control.  The method gets the image and loads it into the WebImageViewer control by assigning a AtalaImage to the WebImageViewer.Image.  This part works fine.

    The problem that I am having involves adding that image to the WebThumbnailViewer.  When I add the line

    WebThumbnailViewer1.Open(ms); // ms is the memory stream which has the tiff image

    The image is not added to the Thumbnail viewer control.  I have not found any effective way of adding the image to the thumbnail viewer control at this point.

    I wonder - if there was a way to "RemoteInvoke" a method on the WebThumbnailViewer control would that solve my problem?

    Is there another way of doing this or perhaps someone has come across a solution to this problem?

    Thanks in advance!

  •  10 Oct 2007, 9:40 AM 12644 in reply to 12639

    Re: Loading an image into the WebThumbnailViewer using the Open method

    Unfortunately there is no inherant way to do this using the WebThumbnailViewer.  The WebThumbnailViewer requires either a URL or directory of images, and opening of streams is only supported in Page_Load.

    The RemoteInvoke method is also only intended to work with the WebImageViewer object it's called from, so any changes made to any other objects will not persist, unless they are saved to disk and re-opened from the client JavaScript API.

    An optional method of doing this is to create a dummy tiff (locally accessible) on the server side which you pre-open on Page_Load, and use the WebImageViewer's RemoteInvoke modify/append pages to this dummy tiff as you asynchronously get the images.  Once this RemoteInvoke returns, you could send an Update() to the WebThumbnailViewer, and it will reload the image you modified.


    David Cilley
    My AJAX Imaging Blog
    Atalasoft Development Team
  •  10 Oct 2007, 10:55 AM 12648 in reply to 12644

    Re: Loading an image into the WebThumbnailViewer using the Open method

    Thank you for taking the time to provide such an excellent and prompt reply.  I will try do exactly what you suggest.

     Thanks again!

  •  10 Oct 2007, 3:56 PM 12653 in reply to 12644

    Re: Loading an image into the WebThumbnailViewer using the Open method

    David,

      I am trying to do as you suggest, however it is not working.  When I run these lines twice in Page_Load only one image appears in the WebThumbnailViewer. 

    FileStream fs = new FileStream(Page.MapPath(@"Resources\loading_" + thumbNum.ToString() + @".tif"), FileMode.Open);

    WebThumbnailViewer1.Open(fs);

    fs.Close();

    thumbNum++;

    Do you know why that would be?  At the end WebThumbnailViewer1.Count is 1.  I would need for it to be two.  Is there some thing that I am doing wrong?

  •  11 Oct 2007, 12:17 AM 12655 in reply to 12653

    Re: Loading an image into the WebThumbnailViewer using the Open method

    I think either I misunderstood what you wanted or you misunderstood I was suggesting, the code you've shown above will only load one of the images... it does not automatically append for you.

    here is a basic run down of what I thought you were asking for:

    Page_Load (you don't have access to tiff images yet):

    1. Create a blank tiff file using the TiffFile class
    2. Save this TiffFile to disk in a local relative path
    3. Use OpenUrl on this relative path

    Render occurs, use JavaScript to callback

    1. Use atalaInitClientScript to initiate a JavaScript function on load
    2. Attach an event handler function that calls WebThumbnailViewer.Update() to WebImageViewer.RemoteInvoked
    3. Call a RemoteInvokable function from JavaScript that appends the image you can access asynchronously to the TiffFile we created earlier
    4. Once the RemoteInvoke comes back from the server, it will call the event we attached

    I don't really understand why you would need to do it this way, this will make it load extremely slow, as it will circumvent all of the optimizations made for the WebThumbnailViewer.

    If you are merely trying to create a multipage tiff file on the fly on Page_Load (which looks like it would work with your code), try using the TiffFile class.


    David Cilley
    My AJAX Imaging Blog
    Atalasoft Development Team
  •  11 Oct 2007, 9:04 AM 12656 in reply to 12655

    Re: Loading an image into the WebThumbnailViewer using the Open method

    David,

      Thanks for the very informative reply.  Again it is a first class reply.

    Now, our use of the WebThumbnailViewer/WebImageViewer has to involve doing call backs to get the images.


    1-because we are getting them from a server farm that can handle many requests at one time... so we can get ten images at once instead of just stringing the requests together synchronously, you see.  Does that make sense.  I could still make the requests for Page_Load and wait until all the images arrive but then 2) is not possible.

    2-because while the server is still getting images 20-50 the person that requested the page can be viewing images 1-19.  I can not make the user wait while all 1-50 images are available before rendering the page.

    I like your solution and I am sure it would work for me to append to or modify images on the server and have them update and available via OpenUrl.  But, it will not work in my case.  The documents that I am presenting to the user are classified as sensitive... therefore, I can not have the images available to anyone, for any reason, as a URL (they have to be held in memory or not at all).  We can not provide security around an image that is available as a http request.

    We are looking at the DotImage solution because we need the ability to stream the images to the client and not have them cached.  I would love to figure out how to do that with your product.

    Do you think there is a way?

  •  11 Oct 2007, 12:46 PM 12661 in reply to 12656

    Re: Loading an image into the WebThumbnailViewer using the Open method

    I do understand that you are asking for now, you want to basically throttle the loading of images so that the page loads fast at the beginning, and gets the images as it needs it.  Our WebThumbnailViewer doesn't support this kind of behavior, and it would be "easier" to write your own thumbnail solution than to modify the WebThumbnailViewer to do what you want.

    Our AJAX enabled components automatically cache the image files to a locally accessable directory when you load them using streams, or from the file system.  You can add security options to the Cache folder, as only the ASPNET user account needs modify permissions on the folder (either that or the impersonated account you are using).

    Based on your requirement, I'm not so sure that you will be able to use any AJAX enabled control for what you need.  Even if you were to make your own thumbnailer, it will still need to use URL's to grab the thumbnails.

    All images that are requested by any of our components, and probably all others, get the images from a url with a querystring of some sort.  There is no way (that I know of) to keep the image in "memory" and dump it directly to the memory of the client pc, without the use of a URL.


    David Cilley
    My AJAX Imaging Blog
    Atalasoft Development Team
  •  12 Oct 2007, 9:50 AM 12669 in reply to 12661

    Re: Loading an image into the WebThumbnailViewer using the Open method

    Thanks David!  I may have to go back and see if adding security like you mention to the Cache folder is an acceptable risk.  Thanks again.
View as RSS news feed in XML