Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WPF
this error is appear :
No overload for method 'ReadJpeg' takes 2 arguments

i'm convert WriteableBitmap to Stream like this :
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 :
ExifOrientation orientation = ExifReader.ReadJpeg(
        myStream).Orientation;
 
cannot convert from 'System.IO.Stream' to 'System.IO.FileInfo'
how i can solution this problem
Posted 25-Sep-12 5:45am
Edited 25-Sep-12 5:55am
JF201553.4K
v2
Comments
Sergey Alexandrovich Kryukov at 25-Sep-12 15:21pm
   
Why on Earth would you assume one could convert into another? :-)
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 25-Sep-12 15:21pm
   
Apparently, a 5.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
 
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;
}
  Permalink  

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

  Print Answers RSS
0 Zoltán Zörgő 265
1 /\jmot 205
2 CHill60 145
3 Peter Leow 145
4 CPallini 135
0 Sergey Alexandrovich Kryukov 9,363
1 OriginalGriff 6,881
2 Peter Leow 4,577
3 Zoltán Zörgő 4,184
4 CHill60 2,892


Advertise | Privacy | Mobile
Web02 | 2.8.150129.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100