How does GdViewer reference image via ImageID?

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
RNeall
Posts: 12
Joined: Sun Jun 06, 2010 10:17 pm

How does GdViewer reference image via ImageID?

Post by RNeall » Sun Jun 06, 2010 10:54 pm

As a potential customer, I am currently evaluating your TWAIN/Imaging product, in particular, your TWAIN C# sample code, in an attempt to see how it all works and how the underlying architecture holds together.

In this sample you have a class-level GdPictureImaging object and a form on which you have a GdViewer control. When the GdPictureImaging object acquires an image, it is thereafter referenced by its imageID, which is understood by the GdPictureImaging object, which, presumably, maintains an internal list of images (hash table?) referenced by their IDs. I don't see how this imageID could also be meaningful to the viewer control, which appears to know nothing about the GdPictureImaging object, the presumed sole repository of the images and image pointer list.

I'm sure it works (my TWAIN devices are on order so I have not tried it yet), but for the life of me I don't understand why. The answer is probably obvious, but I'm not seeing it.

Am I correct about some sort of image list inside GdPictureImaging, and, if I am, do these accumulate on a multi-page scan, thus building up in memory? Or are they disposed as they are processed? If only one is ever alive at one time, one wonders why an ImageID would be needed as a reference.

Thanks,

Randy Neall

User avatar
Loïc
Site Admin
Posts: 5698
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: How does GdViewer reference image via ImageID?

Post by Loïc » Mon Jun 07, 2010 9:45 am

Hi,

Here an overview of how image are handled in GdPicture.NET:

GdPicture.NET handles a kind of stack which handle 0 to N images. This stack is private in GdPicture.NET, this means that final user can't access it. Each image in the stack is identified bu an ID called (ImageID).
All GdViewer & GdPictureImaging objects created have access to this stack. This mean you will be able to access synchronously the same image by X objects (can be GdPictureImaging and/or GdViewer).

By the way, each GdPictureImaging will be able to handle X different images. To release a particulat image to the stack, just use the ReleaseGdPictureImage method.

Hope this bring you some lights...

With best regards,

Loïc

RNeall
Posts: 12
Joined: Sun Jun 06, 2010 10:17 pm

Re: How does GdViewer reference image via ImageID?

Post by RNeall » Mon Jun 07, 2010 2:57 pm

>All GdViewer & GdPictureImaging objects created have access to this stack.

It is clear that this must be the case. But how? I don't see where GdViewer is given a reference to GdPictureImaging.

>To release a particulat image to the stack, just use the ReleaseGdPictureImage method.

Would you ever recommend not doing this one-at-a-time as images are acquired? In other words, would there ever be a reason to acquire all images in a multi-page scan, and then process and release them at the end, after all are scanned and acquired?

Thanks for your help.

Randy Neall

mp285
Posts: 5
Joined: Fri Jul 03, 2009 4:26 pm

Re: How does GdViewer reference image via ImageID?

Post by mp285 » Tue Jun 08, 2010 4:19 pm

I've been experimenting with the components (i had similar queries), and i've posted my observations below. Hopefully they'll be of some use.

Each imageId generated will be unique for each image - if you import the same image twice you get two different imageIds.

These imageIds can be referenced by any GdPictureImaging or GdViewer object. If I load the image with one GdPictureImaging, I can process it with another. I'm presuming the 'stack' is just a static reference from within the appropriate dlls, and is created when its first accessed.

The imageIds doesn't change on editing (I think - feel free to correct me if I'm wrong!), so you can draw on the image, rotate or resize it and the id stays the same.

Releasing the imageId releases it from the stack - the GdViewer /GdPictureImaging components won't be able to access it.

I've had no problems storing multiple imageIds. In fact my entire system is based off scanning the images using one GdPictureImaging object , processing them with another, storing them in an array for user validation using the Viewer, then finally saving and releasing them in one go.

Mark

User avatar
Loïc
Site Admin
Posts: 5698
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: How does GdViewer reference image via ImageID?

Post by Loïc » Tue Jun 08, 2010 6:41 pm

Hi there,

Mark you are absolutely right.

Just note that an image ID can be "recycled".

IE, if you create 4 consecutive GdPicture Image ID should be 1, 2, 3, 4. If you remove latest created image then you create a new one, its ID will be 4 !

We have implemented a kind of GdPicture image garbage collector :)

Kind regards,

Loïc

RNeall
Posts: 12
Joined: Sun Jun 06, 2010 10:17 pm

Re: How does GdViewer reference image via ImageID?

Post by RNeall » Wed Jun 09, 2010 4:50 am

Thanks, guys. All questions answered.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest