Solved

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

Posted on 2006-11-16
5
3,163 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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