Solved

EDSDKLib : JPG to pictureBox1.Image dont work !

Posted on 2008-10-28
4
581 Views
Last Modified: 2012-06-21
Hi,
For my first use of EDSDK lib, i want to load a JPG file with this library on a C# pictureBox.
This dont work, at the line : pictureBox1.Image = Image.FromStream(readStream);  i have error message  (parameter is not valid).

I have try UNSAFE, METAFILE ... but nothing work.
See attache code file here.

Thanks in advance.

test.txt
0
Comment
Question by:lgc5800
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:mac-will
ID: 22823145
I am not familiar with that library but try this:

UnmanagedMemoryStream readStream = new UnmanagedMemoryStream((byte*)(void*)fs.ToPointer(), streamLength, streamLength, FileAccess.Read);

TO

UnmanagedMemoryStream readStream = new UnmanagedMemoryStream((byte*)fs, streamLength, streamLength, FileAccess.Read);
0
 

Author Comment

by:lgc5800
ID: 22826165
mac-will, i have tested but dont work. Thank you
0
 
LVL 8

Expert Comment

by:mac-will
ID: 22830491
Just to make sure it is a valid JPEG why don't you try copying the unmanaged stream to the managed heap. (Marshal.Copy)
0
 

Accepted Solution

by:
lgc5800 earned 0 total points
ID: 22848524
I have found, and this work fine .
I use stream to take the JPG from Camera and save it to folder on my PC and then
assign it to the picturebox.

Thanks everyone

EDSDK.EdsCreateFileStream(System.IO.Path.Combine(Application.StartupPath, ObjectInfo.szFileName), FileDisp, FileAccess, out StreamRef);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question