easy include bitmap question

i have an included bitmap in my solution explorer, where do i find it if i want to show it in my project?

thanks,

~b
LVL 8
bramsquadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ignacio Soler GarciaSolution Architech & Technical LeadCommented:
You have to do like this:

a) See the properties of the image and set the Generatio Action to "Embedded resource".
b) Use this code to acces it:

Public Function CreateImage(vName As String) As Bitmap
        Dim executingAssembly As System.Reflection.Assembly = Me.GetType.Assembly.GetAssembly(Me.GetType)
        Dim myNamespace As String = executingAssembly.GetName().Name.ToString()

        return New Bitmap(Me.GetType.Assembly.GetAssembly(Me.GetType).GetManifestResourceStream("vName"))
End Function

c) Use the name of the image with the name of the name space. Ex: NameSpace.Image.bmp . Take in mind that capitalization does matter!

SoMoS

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bramsquadAuthor Commented:
im not quite sure i understand your code, plus its giving me an error.  please explain.

this is my code...

    Public Function CreateImage(ByVal vName As String) As Bitmap
        Dim executingAssembly As System.Reflection.Assembly = Me.GetType.Assembly.GetAssembly(Me.GetType)
        Dim myNamespace As String = executingAssembly.GetName().Name.ToString()

        Return New Bitmap(Me.GetType.Assembly.GetAssembly(Me.GetType).GetManifestResourceStream(vName)) '<--ERROR HERE
    End Function

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.PictureBox11.Image = CreateImage("optical_illusion_1.jpg")
    End Sub

and this is the error message that im getting...

Additional information: 'null' is not a valid value for 'stream'.

thanks for your help

`~b

0
Ignacio Soler GarciaSolution Architech & Technical LeadCommented:
Check this:

a) Have you setted the property of the image Generation Action to "Embedded resource"?
b) Have you passed the full name of the image (including capitalization). For example, a image called pPp.bmp into a folder called FOLDER inside a Project called CycleLog must be called "CycleLog.FOLDER.pPp.bmp?

Askme more if you need it

SoMoS
 
0
bramsquadAuthor Commented:
thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.