Solved

EDSDKLib : JPG to pictureBox1.Image dont work !

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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

840 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