473,386 Members | 1,812 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,386 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 2762
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
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...
0
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,...
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...

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.