Solved

HowTo: Reference Bitmap in project (EASY 500 pts)

Posted on 2004-08-20
5
219 Views
Last Modified: 2010-04-23
Ok.. I am stumped by this one.

I have a project that has 2 bitmap file as part of the project.  In code I need to load these bitmaps into memory so I can display them.   So how can I reference these files without an explicit file path in the bitmap's constructor?

Dim bmp As New Bitmap("Mybitmap.bmp")   <<< this fails at runtime.  Says it can't find the file...
0
Comment
Question by:ptakja
[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 10

Expert Comment

by:eternal_21
ID: 11852650
Make sure that the bitmap file is actually in the output folder (i.e. bin\Debug, or bin\Release), if so, your code should run fine.
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 11852699
Dim bmp As New Bitmap( server.mappath("./Mybitmap.bmp"))
0
 
LVL 14

Author Comment

by:ptakja
ID: 11853793
This is for a WinForms app.

eternal_21, what if all I want to deploy is a dll.  In other words, I don't want to deply the bmp as a separate file.  I want it all rolled into the dll.

Do you know how to embed an image as a resource?
0
 
LVL 7

Accepted Solution

by:
ramesh12 earned 500 total points
ID: 11853920
i think we can embed in the following way

if you see image properties :

buildaction : chnage this to embedded resource


and you can reference it in your app something like this

Dim bmp As New Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("<namespace>.<imagename>"));
0
 
LVL 14

Author Comment

by:ptakja
ID: 11854156
ramesh12...that worked great.  Learned something new today!  WOOHOO!
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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