Click here to Skip to main content
15,891,764 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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 = 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;
            }
        }

but when pass just one arrgument like this :
C#
ExifOrientation orientation = ExifReader.ReadJpeg(
        myStream).Orientation;


cannot convert from 'System.IO.Stream' to 'System.IO.FileInfo'
how i can solution this problem
Posted
Updated 25-Sep-12 4:55am
v2
Comments
Sergey Alexandrovich Kryukov 25-Sep-12 15:21pm    
Why on Earth would you assume one could convert into another? :-)
--SA

Since you're using MemoryStream, there is no file from which you can get FileInfo.
You'll need to make an overload of ReadJpeg method that will take
Stream or MemoryStream as parameter.

C#
public static JpegInfo ReadJpeg(Stream stream)
{
    DateTime then = DateTime.Now;

    ExifReader reader = new ExifReader(stream);
    reader.info.FileSize = stream.Length;
    reader.info.LoadTime = (DateTime.Now - then);
    return reader.info;
}
 
Share this answer
 
It simply states that there is no overload of ReadJpeg that takes 'System.IO.Stream' as one of the arguments.

Either one paramter or multiple, ReadJpeg expects 'System.IO.FileInfo' as a parameter.

You need to pass FileInfo and not Stream to the method.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Sep-12 15:21pm    
Apparently, a 5.
--SA

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