This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
Jake Rizzo  
#1 Posted : Thursday, October 10, 2013 6:07:12 AM(UTC)
Jake Rizzo

Rank: Newbie

Groups: Guest
Joined: 10/10/2013(UTC)
Posts: 4

Thanks: 3 times
Hi,

I have been using this tool in a recent project where is a library containing several themes, and inside themes we've got images. On switching images we want to display a indicator that either is just a gif image showing that the content is being loaded or an actual loading progress bar.

I looked it up and haven't found anything that would point me to the right way. I found however a

ProgressEventHanlder (http://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_ProgressEventHandler.htm)

The version I have been working with is 5.5.

All I'm asking is for some clues and maybe someone could point me out which way to go? All relevant information will be gladly appreciated in advance.

Kind Regards,

Jake R.

Andrew  
#2 Posted : Friday, October 11, 2013 12:23:49 AM(UTC)
Andrew

Rank: Advanced Member

Groups: Guest
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Jake,

Do you mean that you want to have a progress bar while you read a file and create the Bitmap? Check out this article:

http://www.graphicsmill.com/docs/gm5/Multithreading.htm

This article explains how to add a progress to the Blur operation, however the Bitmap class has the similar Progress event, so you will be able to use the same approach for opening a file as well.

However I would recommend to switch to the version 6 as the version 5 has been discontinued. In the version 6, we have removed the Progress event from the Bitmap in sake of the performance, however it is still possilble to display a progress bar. The code for the version 6 will be looking like this:

Code:
using (var reader = ImageReader.Create(@"C:\Temp\TestImages\Huge\uk_map_4000x5082.jpg"))
using (var reporter = new ProgressReporter())
using (var result = new Bitmap())
{
    reporter.Progress += new EventHandler<ProgressEventArgs>(
        delegate(Object sender, ProgressEventArgs e)
        {
            Console.WriteLine(e.Progress);
        }
    );

    Pipeline.Run(reader + reporter + result);
}
thanks 1 user thanked Andrew for this useful post.
Jake Rizzo on 10/25/2013(UTC)
Jake Rizzo  
#3 Posted : Tuesday, October 22, 2013 12:51:36 AM(UTC)
Jake Rizzo

Rank: Newbie

Groups: Guest
Joined: 10/10/2013(UTC)
Posts: 4

Thanks: 3 times
Hi Andrew, thank you for your reply.

Does this works for both web forms and windows forms? The reason for this, is that the application that I've been working on is web forms.

Best Regards.

Jake R.

Andrew  
#4 Posted : Tuesday, October 22, 2013 2:47:25 AM(UTC)
Andrew

Rank: Advanced Member

Groups: Guest
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
I am sorry, I did not realize that you need it for web forms.

It is getting more complicated. When you load the image in web forms (for example, in BitmapViewer control), in fact there are two independent operation are performed:

1. The image is loaded from, say, JPEG on the server.

2. The content of the BitmapViewer control is loaded on the client.

Could you clarify on what stage you want to display the progress bar?

In the former case, the problem is that the code is executing on the server and you want to display the progress bar on the client. Although I think it is possible to implement (e.g. the event handler updates some variable and you grab this value on the client using AJAX), I don't think it is a good idea, unless you are running really heavy operation on the server (which runs, say, several minutes). It will reduce the performance and make things more complicated. I would recommend to display a spinning animated GIF.

Hope this makes sense.

thanks 1 user thanked Andrew for this useful post.
Jake Rizzo on 10/25/2013(UTC)
Jake Rizzo  
#5 Posted : Tuesday, October 22, 2013 7:46:12 AM(UTC)
Jake Rizzo

Rank: Newbie

Groups: Guest
Joined: 10/10/2013(UTC)
Posts: 4

Thanks: 3 times
Thank you for your reply Andrew.

We actually want to display a spinning animated GIF instead of the progress bar.

There is a default "hourglass" icon that is displayed on the image loading. However it seems that it appears only from time to time and doesn't work properly as there is some sort of lag.

We are using an invoke remote method to load the image from the gallery the user just clicked.

Our approach:

1. When the user click on the image, we grab the ID from the image properties and store it.

2. When a different image is clicked, right after the click event we show the animated GIF and we trigger a function that will run every X ms (setInterval) and check if the image ID has changed. We use the "tags" properties to send the image ID from the server to the client side.

This way we know that the image has changed and we can now "hide" the animated GIF. The problem with this, is that some images, their loading time might take longer and when that happens we get the new ID but the image is still loading.

So this is just a work around to alert the user that there is some progress going on. But there is a lag due to the issue mentioned above.

Could you please indicate how can I know that the image is finished loading?

Let me know if I'm not being very clear.

Kind Regards.

Jake R.

Andrew  
#6 Posted : Tuesday, October 22, 2013 8:22:04 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Guest
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
There is a special client-side event - BitmapViewer.statusChanged. You can display the spinning image when it sends the status="busy" and hide it when it is "ready". It will work in both GM5 and GM6.
thanks 1 user thanked Andrew for this useful post.
Jake Rizzo on 10/25/2013(UTC)
Jake Rizzo  
#7 Posted : Friday, October 25, 2013 2:03:59 AM(UTC)
Jake Rizzo

Rank: Newbie

Groups: Guest
Joined: 10/10/2013(UTC)
Posts: 4

Thanks: 3 times
Hi Andrew.

I had a look on that. Correct me if I am wrong, but when checking the status I have noticed that the status changes but the image is still loading.

I mean, so when I first click the image I show the spinning image and get the status = 0 (which is either returning 0 or 2 and not "busy" or "read"). And ms after it changes to status = 2 so here I just hide the spinning image BUT the image is still loading.

Am I being cleared? Maybe I am doing something wrong.

Thanks in advance.

Andrew  
#8 Posted : Saturday, October 26, 2013 12:28:21 AM(UTC)
Andrew

Rank: Advanced Member

Groups: Guest
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Well, for me it starts displaying the image, but some parts of it ("tiles") are being loaded (i.e. the low-res version of a tile is displayed). Are you sure that the spinning icon needs to be displayed while tiles are being loaded? The user can start working with the image, so I think that it is a good time to hide the spinning icon.

Or you want to hide it only when the image is loaded completely? Should it display the spinning icon when the user scrolls or zooms the control?

Andrew  
#9 Posted : Wednesday, November 6, 2013 8:51:40 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Guest
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
BTW, it turns out that you can do it in GM6. The viewer has get_countOfNotLoadedTiles method - when it returns 0, it means that the image is completely loaded.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.