EDSDKLib : JPG to pictureBox1.Image dont work !

Posted on 2008-10-28
Medium Priority
Last Modified: 2012-06-21
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.

Question by:lgc5800
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

Expert Comment

ID: 22823145
I am not familiar with that library but try this:

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


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

Author Comment

ID: 22826165
mac-will, i have tested but dont work. Thank you

Expert Comment

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)

Accepted Solution

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);

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 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