Solved

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

Posted on 2006-11-16
5
3,165 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 86

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 86

Expert Comment

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

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

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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