locked
Error CS1061 Image<Bgr,byte> RRS feed

  • Question

  •  private void exitToolStripMenuItem_Click(object sender, EventArgs e)
            {
                try
                {
                    OpenFileDialog dialog = new OpenFileDialog();
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        var img = new Image<Bgr, byte>(dialog.FileName);
                        AddImage(img, "Input");
                        pictureBox1.Image = img.AsBitmap();

    Error CS1061 'Image<Bgr, byte>' does not contain a definition for 'AsBitmap' and no accessible extension method 'AsBitmap' accepting a first argument of type 'Image<Bgr, byte>' could be found (are you missing a using directive or an assembly reference?) EmguCvDemo C:\Users\Zaim\source\repos\EmguCvDemo\EmguCvDemo\Form1.cs 38 Active

    I already installed Emgu.CV.runtime.windows

    Saturday, November 28, 2020 9:28 PM

Answers

  • Hi zack79,

    Thank you for posting here.

    I did a simple test and found that they deleted both AsBitmap and ToBitmap in the latest version of the package.

    You can switch the package to the previous version, or use the following code instead:

                        var img = new Image<Bgr, byte>(dialog.FileName);
                        
                        byte[] bytes = img.ToJpegData();
                        Image x = (Bitmap)((new ImageConverter()).ConvertFrom(bytes));
                        pictureBox1.Image = x;

    Best Regards,

    Timon


    "Visual C#" forum will be migrating to a new home on Microsoft Q&A ! We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A ! For more information, please refer to the sticky post.

    • Marked as answer by zack79 Thursday, December 3, 2020 6:54 PM
    Monday, November 30, 2020 2:02 AM

All replies

  • The method you want is ToBitmap, not AsBitmap.

    Tim Roberts | Driver MVP Emeritus | Providenza &amp; Boekelheide, Inc.

    Sunday, November 29, 2020 7:20 AM
  • Hi zack79,

    Thank you for posting here.

    I did a simple test and found that they deleted both AsBitmap and ToBitmap in the latest version of the package.

    You can switch the package to the previous version, or use the following code instead:

                        var img = new Image<Bgr, byte>(dialog.FileName);
                        
                        byte[] bytes = img.ToJpegData();
                        Image x = (Bitmap)((new ImageConverter()).ConvertFrom(bytes));
                        pictureBox1.Image = x;

    Best Regards,

    Timon


    "Visual C#" forum will be migrating to a new home on Microsoft Q&A ! We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A ! For more information, please refer to the sticky post.

    • Marked as answer by zack79 Thursday, December 3, 2020 6:54 PM
    Monday, November 30, 2020 2:02 AM
  • Hi,

    Has your issue been resolved?

    If so, please click on the "Mark as answer" option of the reply that solved your question, so that it will help other members to find the solution quickly if they face a similar issue. If you still have questions, please feel free to ask.

    Best Regards,

    Timon


    "Visual C#" forum will be migrating to a new home on Microsoft Q&A ! We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A ! For more information, please refer to the sticky post.

    Thursday, December 3, 2020 7:43 AM