473,405 Members | 2,444 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,405 software developers and data experts.

Background image from embedded resource

Hi,

I have a bitmap as an embedded resource. Now I want to use that bitmap for a
background image of a button. But if I do the following it doesn't work.

<snap start>
Dim s As System.IO.Stream =
Me.GetType().Assembly.GetManifestResourceStream("W indowsApplication1.Bitmap1
..bmp")
Dim bmp as bitmap = New Bitmap(s)
s.Close()
Dim img As Image = bmp
Button1.BackgroundImage = bmp
<snap end>

What am I doing wrong?

TIA

Peter
Nov 22 '05 #1
4 2766
that what wizard does:
this.button1.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("butto n1.BackgroundImage")));

try to do something like this

Nov 22 '05 #2
that what wizard does:
this.button1.BackgroundImage =
((System.Drawing.Image)(resources.GetObject("butto n1.BackgroundImage")));

try to do something like this

Nov 22 '05 #3
I found the error: I must not close the stream and I have to do the
following:

Dim s as System.IO.Stream =
Me.GetType().Assembly.GetManifestResourceStream("W indowsApplication1.Bitmap1
..bmp")
Button1.BackgroundImage = new Bitmap(s)

That's all.

:)

Peter
"Peter Zentner" <peter@_REM_zentner-online.de> schrieb im Newsbeitrag
news:uo*************@tk2msftngp13.phx.gbl...
Hi,

I have a bitmap as an embedded resource. Now I want to use that bitmap for a background image of a button. But if I do the following it doesn't work.

<snap start>
Dim s As System.IO.Stream =
Me.GetType().Assembly.GetManifestResourceStream("W indowsApplication1.Bitmap1 .bmp")
Dim bmp as bitmap = New Bitmap(s)
s.Close()
Dim img As Image = bmp
Button1.BackgroundImage = bmp
<snap end>

What am I doing wrong?

TIA

Peter

Nov 22 '05 #4
I found the error: I must not close the stream and I have to do the
following:

Dim s as System.IO.Stream =
Me.GetType().Assembly.GetManifestResourceStream("W indowsApplication1.Bitmap1
..bmp")
Button1.BackgroundImage = new Bitmap(s)

That's all.

:)

Peter
"Peter Zentner" <peter@_REM_zentner-online.de> schrieb im Newsbeitrag
news:uo*************@tk2msftngp13.phx.gbl...
Hi,

I have a bitmap as an embedded resource. Now I want to use that bitmap for a background image of a button. But if I do the following it doesn't work.

<snap start>
Dim s As System.IO.Stream =
Me.GetType().Assembly.GetManifestResourceStream("W indowsApplication1.Bitmap1 .bmp")
Dim bmp as bitmap = New Bitmap(s)
s.Close()
Dim img As Image = bmp
Button1.BackgroundImage = bmp
<snap end>

What am I doing wrong?

TIA

Peter

Nov 22 '05 #5

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

Similar topics

2
by: Peter Zentner | last post by:
Hi, I have a bitmap as an embedded resource. Now I want to use that bitmap for a background image of a button. But if I do the following it doesn't work. <snap start> Dim s As...
3
by: Shailaja Kulkarni | last post by:
hi All, This problem is for C# windows application. I have a user control whcih contains one picture box along with other controls. Depending on certain conditions I want to change images on the...
4
by: Matthew Wieder | last post by:
I have a form which contains a picturebox control which displays a gif image. By default, the image that was selected when I designed the dialog gets stored in the resx file and gets compiled and...
1
by: D. Yates | last post by:
Hi, I am looking for an example of how to extract bitmap images from an embedded resource file (a file with *.res extension, which can be viewed inside of the ide and can hold bitmaps, icons,...
10
by: Richard Steele | last post by:
Can anyone help me I am developing an application runs on a PC (client) only. For graphical reasons it was decided that the content would be displayed in a Browser that is embedded in a Windows...
6
by: Saya | last post by:
Hello, This is a repost 'cause I haven't solve the problem: I can't use the System.Drawing class 'Image.FromStream' in the CompactFramework environment. What I've done with respect to Brendan's...
2
by: Don Tucker | last post by:
Hello, I have a Windows Application that needs to load multiple image files in response to users clicking buttons. Currently, I just have these images as .jpg files on disk, but I don't want to...
5
by: aiki727 via DotNetMonster.com | last post by:
Hello everyone, Where do I store a bitmap or jpeg that I am using for a forms background image when I deploy the application? Or do I link these files to the app during the deployment? Thanks...
3
by: UJ | last post by:
I've got an image I want to embed in a dll to use on a screen later. I've got it in a resource file, got it to compile in to the dll. The problem is getting it back out. It seems like my problem is...
1
by: Littlefire | last post by:
Hi all I wrote a proxy script that fetches images out of a database and sends the data to the browser, using the Content-type header. For instance, if I'm loading a jpg image from the database,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.