Solved

EDSDKLib : JPG to pictureBox1.Image dont work !

Posted on 2008-10-28
4
583 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

732 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