473,563 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, WindowsApplicat ion1,
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.bm p".

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 2631
Dim objBitmap as bitmap

objBitmap = New Bitmap
(System.Reflect ion.Assembly.Ge tExecutingAssem bly.GetManife
stResourceStrea m("WindowsAppli cation1.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 'WindowsApplica tion1' 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
"WindowsApplica tion1.Bitmap1.b mp" 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.bm p" 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*******@anon ymous.com> wrote in message news:<02******* *************** ******@phx.gbl> ...
Dim objBitmap as bitmap

objBitmap = New Bitmap
(System.Reflect ion.Assembly.Ge tExecutingAssem bly.GetManife
stResourceStrea m("WindowsAppli cation1.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 'WindowsApplica tion1' 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
11456
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 database, and I need the data to be laid out in a tabular format, and set out in a specific way. At the current point in time, I am copy/pasting the...
1
5225
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
3094
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 "speeds". I want to "set" the speedometer to the current speed, then save the form as a picture, then go to the next one, etc... The end result would...
7
2425
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 I know that the application has to always be on top. The problem: I am running this application on a Windows Server 2003 PC. The server is in...
6
3741
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: Dim ico As Icon = Icon.FromHandle(bmp.GetHicon()) 3: Dim file As FileStream = New FileStream("C:\myfolder\file.ico",FileMode.OpenOrCreate) 4: ...
7
1820
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 question is..how would I save the tif images as soon as it is initially painted, and then restore the image in a paint event. It seems to me that there...
4
8074
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 (MyBitmap.bmp) in my c# application and I want to load it, and return it as a return value of the method GetBitmap. I created a System.Drawing.Bitmap...
2
2347
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 Drawing.Bitmap("1.bmp", False) Return a End Function
7
2104
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 BufferBase, and customized in order to be able to a type of data (of any kind, such as chunks of audio samples from a sound card). The processor...
0
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.