Solved

EDSDKLib : JPG to pictureBox1.Image dont work !

Posted on 2008-10-28
4
571 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now