Error when decoding image C# asp

Posted by Wayneio on Stack Overflow See other posts from Stack Overflow or by Wayneio
Published on 2012-10-24T19:39:19Z Indexed on 2012/10/24 23:01 UTC
Read the original article Hit count: 310

Filed under:
|
|

I am trying to use MessagingToolkit to decode an image in C#/ASP. I have managed to encode a qr using this package, but when i try to decode, using the code below it comes up with 2 errors (at the bottom of the page)

I believe this is because I am not getting the image correctly after uploading, but can someone point out exactly where I have gone wrong. Thanks.

    protected void CreateCode_OnClick(object sender, EventArgs e)
    {
        string path = "C:\\Users\\Wayneio\\Documents\\Visual Studio 2012\\Projects\\BAMSystem\\BAMSystem\\";
        if (QRUpload.HasFiles == true)
        {
            FileInfo fi = new FileInfo(QRUpload.FileName);
            string extA = fi.Extension;
            if (extA == ".jpg" || extA == ".png")
            {
               QRCodeDecoder decoder = new QRCodeDecoder();
               QRUpload.SaveAs(path + QRUpload.FileName);

               System.Drawing.Image myImg = System.Drawing.Image.FromFile(path + QRUpload.FileName);
               decoder.Decode(myImg);

            }
            else
            {
                error.Text = "You have uploaded a " + extA + " file. Please upload either a PNG or a JPG";
            }
        }
        else
        {
            error.Text = "You have not uploaded an image.";
        }
    }

Error1:

Error   2   Argument 1: cannot convert from 'System.Drawing.Image' to 'MessagingToolkit.QRCode.Codec.Data.QRCodeImage'  c:\users\wayneio\documents\visual studio 2012\Projects\BAMSystem\BAMSystem\default.aspx.cs  38  35  BAMSystem

Error2:

Error   1   The best overloaded method match for 'MessagingToolkit.QRCode.Codec.QRCodeDecoder.Decode(MessagingToolkit.QRCode.Codec.Data.QRCodeImage)' has some invalid arguments    c:\users\wayneio\documents\visual studio 2012\Projects\BAMSystem\BAMSystem\default.aspx.cs  38  20  BAMSystem

P.S if anyone has documentation on this MessagingToolkit QR package, it would be useful

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET