RobotStudio event

Images in FP application

Hello,

I'm trying to get some images into my TPSview application, but I can't get it to work. Can anyone help me?

If I follow the Visual Studio way,


Dim myImage As System.Drawing.Image = Image.FromFile("Image.bmp")

I get the error: fromfile not a member of system.drawing.image

In the FP SDK manuals, I can't find a way to add images to my button.

 

:) Regards,
Jan-Jaap

Comments

  • Hi
    Here is an example how to do it in C# should be easy to convert that
    into VB.

    private ABB.Robotics.Tps.Resources.TpsResourceManager res=
    new ABB.Robotics.Tps.Resources.TpsResourceManager();

    System.Windows.Forms.PictureBox target=new System.Windows.Forms.PictureBox();


    target.Image=res.GetImage("myImage.bmp");


    Per Svensson
    Company Specialist
    ABB Automation Technology Products
  • Jan-Jaap,

    if you include the bitmap as an embedded resource in the assembly by adding it in the project and then set the Build Action property for the file to "Embedded Resource" you can use the following code to get the image:


    myImage.Image = New
    Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("TpsViewXXXXXX.Image.bmp"))

    Observe that the complete namespace is necessary to get the resource.

    Regards,

    Urban Vikblom
    CONTAB
  • Hello,

    Is the embedded resource option to prefer due to performance?

    I get an error on "assembly" , even though I have:


    Imports
    System.Reflection

    Something else I'm missing?

    jan-jaap38761,4772685185
    :) Regards,
    Jan-Jaap
  • No, I have't checked if the performance improves. It just makes it simpler to handle the image file. Otherwise you must make sure that the file is available and where it is. If you move the assembly the image follows the assembly if it is embedded. It is also a way of making sure that the customer doesn't change the image. Also if you do a localized application the image could be placed in a sattelite assembly and loaded in a similar way.

    What is the error and how does your source code look like? References OK?

    Urban Vikblom
    CONTAB
  • I added system.refelction before assembly, and now it works OK.

    Thanks for the info. image

    :) Regards,
    Jan-Jaap