Solved

VB.Net How do i get an image out of my Resource file ??

Posted on 2006-11-16
5
3,158 Views
Last Modified: 2012-05-05
VB.Net How do i get an image out of my Resource file at runtime??


0
Comment
Question by:ExtremeFitness
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 500 total points
ID: 17960428
My.Resources.MyImageResourceName
0
 
LVL 10

Expert Comment

by:tpwells
ID: 17960532
if the image is an embedded resource you can use this function:

    Public Function RetrieveEmbeddedImage(ByVal ImageFileName As String) As Image
        ImageName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name & "." & ImageFileName
        Dim img As Image
        Dim strm As Stream = _
        System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(ImageFileName)
        If Not strm Is Nothing Then
            img = Image.FromStream(strm)
        End If
        strm.Close()
        Return img
    End Function
0
 
LVL 10

Expert Comment

by:tpwells
ID: 17960545
sorry hit submit to quickly...

ImageFileName = the name of the embedded file.

Also this works best if there are no spaces in your solution and project names.
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 17961084
For embedded resources you can use this instead:

        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.Image = new Bitmap(this.GetType(), "myImage.jpg");
        }
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 17961094
VB.Net would be:

    PictureBox1.Image = New Bitmap(Me.GetType(), "myImage.jpg")

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now