Loading...

DisplayFromByteArray from C#

Support for GdViewer OCX and GdViewer Pro ActiveX/SDK.

DisplayFromByteArray from C#

Postby Iunknown » Sun Nov 18, 2007 5:53 am

Hello,

What's the magic to get the DisplayFromByteArray call to take a Byte[]?

I've loaded my data into a byte array and would like to get the view to show it. I figured that DisplayFromByteArray would be the way to go. I also tried the DisplayFromStream, but I guess it's wants a COM stream not a .net stream.

Before I go wandering down some ugly translation between COM and .NET is there any easier way without using a "real" file?

Also...I never got my trial key...don't know why...

and one more thing...the Doc isn't really working for me..it's just showing one page (install instructions and the boxes on the left have X's in them)

thanks,

Gene
Iunknown
 
Posts: 10
Joined: Sun Nov 18, 2007 5:47 am

Postby zyg » Sun Nov 18, 2007 10:07 am

Don't know if this is good practice or not but I use something like this:

Array databytes;
databytes = new byte[fileSize];

.. reding from filestream, casting the array to Byte[]
fs.Read((Byte[])databytes, offset, remain);


and finally displaying the picture
DisplayFromByteArray(ref databytes);
zyg
 
Posts: 4
Joined: Sun Oct 28, 2007 10:15 pm

didn't work for me

Postby Iunknown » Mon Nov 19, 2007 4:39 am

Thanks Zyg but it didn't work for me...not really sure why.

here is the code that DIDN'T work. (got a IndexOutOfRange Exception)

Byte[] bytes = LoadPDFFileIntoMemory("c:\\sample.pdf");
Array databytes = bytes;
axGdViewer1.DisplayFromByteArray(ref databytes);

This code DID work
Byte[] bytes = LoadPDFFileIntoMemory("c:\\sample.pdf");
FileStream ts = new FileStream(@"C:\a.pdf", FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(ts);
bw.Write(bytes);
bw.Close();
ts.Close();
axGdViewer1.DisplayFromFile(@"C:\a.pdf");

Since the second set worked, I'm pretty sure that my file is loaded correctly and that my Array isn't setup right.

Any ideas?

Gene
Iunknown
 
Posts: 10
Joined: Sun Nov 18, 2007 5:47 am

Postby zyg » Mon Nov 19, 2007 8:04 am

Ok, again not really sure but have you tested the same code with regular images not pdf files?

This is the only thing I can think of and since it is not documented that well I couldn't really check it.

Hopefully Loïc will give you some better support.
zyg
 
Posts: 4
Joined: Sun Oct 28, 2007 10:15 pm


Return to GdViewer [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest