Grabbing byte array from imageviewer after annotations

Discussions about image processing and document imaging.
Post Reply
Dylan
Posts: 5
Joined: Wed Sep 29, 2021 2:51 am

Grabbing byte array from imageviewer after annotations

Post by Dylan » Tue Oct 05, 2021 11:27 pm

Hey,

So what I'm trying to do is to be able to grab the updated byte array from ImageViewer after annotations are made to the image, so that I am able to do things with the byte array that has the annotations in them. Is this possible?

I couldn't find any methods that let me access the byte array to a document that's already loaded into imageviewer.


Thanks again!

User avatar
Fabio
Posts: 173
Joined: Thu Aug 27, 2020 9:57 am

Re: Grabbing byte array from imageviewer after annotations

Post by Fabio » Wed Oct 06, 2021 11:04 am

Hello Dylan,

Here is a code snippet to get the image as a byteArray and the annotations in two different streams:

Code: Select all

using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    MemoryStream streamImg = new MemoryStream();
    MemoryStream streamAnnt = new MemoryStream();

    e.docuVieware.SaveAnnotations(streamAnnt, true);

    e.docuVieware.GetDocumentData(out streamImg);
    int size = (int)streamImg.Seek(0, SeekOrigin.End);
    byte[] buffer = new byte[size];
    streamImg.Seek(0, SeekOrigin.Begin);
    streamImg.Read(buffer, 0, size);

    int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(buffer);
                    
    //At this point, streamImg is your image and streamAnnot is the annotations.
    //You can load back the annotation using the e.docuVieware.LoadAnnotation() method

    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
The GetDocumentData method gets the loaded file in a stream, but at its opening state. That's why I loaded the annotations in another stream.

With best,
Fabio

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest