Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this error is appear :
No overload for method 'ReadJpeg' takes 2 arguments

i'm convert WriteableBitmap to Stream like this :
C#
WriteableBitmap    wb = new WriteableBitmap((int)Camera.PreviewResolution.Width,(int)Camera.PreviewResolution.Height);
                Camera.GetPreviewBufferArgb32(pixels);
                pixels.CopyTo(wb.Pixels, 0);
                var imageStream = new MemoryStream();
                Stream myStream = imageStream;
                wb.SaveJpeg(myStream , wb.PixelWidth, wb.PixelHeight, 0, 100);
//then I'm write this code to retun angle

int GetAngleFromExif(Stream myStream)
    {
      var position = myStream.Position;
      myStream.Position = 0;
      ExifOrientation orientation = <b>ExifReader.ReadJpeg(
        myStream, String.Empty).Orientation;
       myStream.Position = position;

             switch (orientation)
                    {
                        case ExifOrientation.TopRight:
                            return 90;
                        case ExifOrientation.BottomRight:
                            return 180;
                        case ExifOrientation.BottomLeft:
                            return 270;
                        case ExifOrientation.TopLeft:
                        case ExifOrientation.Undefined:
                        default:
                            return 0;
                    }
                }

//and tis is the ReadJpeg
public static JpegInfo ReadJpeg(FileInfo fi)
        {
            DateTime then = DateTime.Now;
            using (FileStream fs = fi.OpenRead())
            {
                ExifReader reader = new ExifReader(fs);
                reader.info.FileSize = (int)fi.Length;
                reader.info.FileName = fi.Name;
                reader.info.LoadTime = (DateTime.Now - then);
                return reader.info;
            }
        }
Posted
Updated 25-Sep-12 1:52am
v3

1 solution

Your error message allready says whats wrong.

You call the function with two arguments:
C#
ReadJpeg(myStream, String.Empty).


But according to your function definition it expects only 1 argument:
C#
public static JpegInfo ReadJpeg(FileInfo fi)

In fact it expects totally different variable types your trying to call it with ... did you really write this yourself?

There also is no overloaded version of the function which fits the argument list you called the function with.
 
Share this answer
 
v2
Comments
Hala1990 25-Sep-12 8:00am    
Thank alot .
but when pass just one arrgument like this :
ExifOrientation orientation = ExifReader.ReadJpeg(
myStream).Orientation;

cannot convert from 'System.IO.Stream' to 'System.IO.FileInfo'
how i can solution this problem
Legor 25-Sep-12 8:04am    
Thats also something i wrote in my answer. The function expects a variable of Type FileInfo but you are passing a variable of type Stream to it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900