473,378 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Question on how to access bitmap: Public Function getBitmap() As Bitmap

At the risk of being publically humiliated, might I ask the following
simple question.

I have a solution with one project. This project, WindowsApplication1,
has one "form" and one "bitmap" (the bitmap created by right clicking
on the project, selecting add new item, then add bitmap file). The
project explorer says my bitmap is called "Bitmap1.bmp".

If I have a function in my project declared as

Public Function getBitmap() As Bitmap

How do I return this bitmap using this function?

I have looked at the the contructor for "Bitmap" and it has 12
versions, one of which is to pass the filename. I don't want to do
this because then it says my bitmap has to be in a certain location on
the disk - I just want to reference the bitmap already in the project
but can't see how to do it without needing to know the filename
(either directly or through a stream or input reader).
So am I missing something and it isn't easy?
Thank you
Michael
Nov 20 '05 #1
2 2625
Dim objBitmap as bitmap

objBitmap = New Bitmap
(System.Reflection.Assembly.GetExecutingAssembly.G etManife
stResourceStream("WindowsApplication1.Bitmap1.bmp" ))

'what the code does is the following
'opens the application
'creates a stream to read the resource
'reads the resource belonging to
namespace 'WindowsApplication1' named 'Bitmap1.bmp'

Ensure that the resources is not simply added to the
project, but an EMBEDDED RESOURCE (right click on the bmp
file in solution explorer, properties, and ensure it's
embedded).

Regards
Nov 20 '05 #2
Thanks a lot. This worked fine. But ... and there's always a but, it
means I have to include a string literal
"WindowsApplication1.Bitmap1.bmp" to reference the bitmap. I would
rather refer to it by a name, so that if the name changed in one place
and not another, the /*compiler/* would not let the program compile.
The way it is coded here means that if I changed my window application
name, or changed the bitmap name from say "Bitmap1.bmp" to
"SendButton.bmp", it mightn't work anymore (unless me, or everyone
else modifying my program, also remembered to change it everywhere
carefully). Can you reference the bitmap resource by a name?
Thank you
Michael

"anonymous" <an*******@anonymous.com> wrote in message news:<02****************************@phx.gbl>...
Dim objBitmap as bitmap

objBitmap = New Bitmap
(System.Reflection.Assembly.GetExecutingAssembly.G etManife
stResourceStream("WindowsApplication1.Bitmap1.bmp" ))

'what the code does is the following
'opens the application
'creates a stream to read the resource
'reads the resource belonging to
namespace 'WindowsApplication1' named 'Bitmap1.bmp'

Ensure that the resources is not simply added to the
project, but an EMBEDDED RESOURCE (right click on the bmp
file in solution explorer, properties, and ensure it's
embedded).

Regards

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: LG | last post by:
Just have a question with regards to the clipboard, and how to read what other applications (Adobe InDesignCS) place in the clipboard. I am currently in the process of creating a booklet from a...
1
by: Brian Keating EI9FXB | last post by:
Hello there, Does anyone know how to to Bitmap masking in .NET, In c++ i used, CreateCompatibleDC GetBitmap Then on the bitmap and the bitmap mask i called. {SelectBitmap StretchBlt}
30
by: VB Programmer | last post by:
Briefly, how do you save the current form to a jpeg or gif? Details: I have a form with a speedometer control on it. It continually loops through a table in a db that has different current...
7
by: VB Programmer | last post by:
I am using the BitBlt operation to capture various controls into jpegs. It's almost like a screen capture, but of just the control. (This is a VB.NET application.) Because of BitBlt limitations...
6
by: Lespaul36 | last post by:
From what I have read, there isn't really a converter to icon format..it becomes a png file. I tried: 1: Dim bmp As Bitmap = CType(Bitmap.FromFile("C:\myfolder\file.bmp"), Bitmap) 2: ...
7
by: hamil | last post by:
The following code will display a tif file on a form. When another form is moved over the tif image, the tif image is erased where the form was moved. A paint event occurs when this happens. My...
4
by: Yoavo | last post by:
Hi, I am writing a COM class in c# which needs to implement an interface which one of its methods declared in the following way: public stdole.IPicture GetBitmap() { } I have a bitmap...
2
by: =?Utf-8?B?UHJ6ZW1v?= | last post by:
Hi, I would like to have a web service method sending a bitmap image. But code like do not work: <WebMethod()_ Public Function GetBitmap() As Drawing.Bitmap Dim a As New...
7
by: Markus Svilans | last post by:
Hello, My question involves virtual functions and inheritance. Suppose we have a class structure, that consists of "data" classes, and "processor" classes. The data classes are derived from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.