[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

HowTo: Reference Bitmap in project (EASY 500 pts)

Posted on 2004-08-20
5
Medium Priority
?
224 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

650 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