473,569 Members | 2,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Showing a Picture

I am trying to show a picture in a form but using visual studios C# I am getting a error everytime I want to deploy my program. I cannot find the reason

Assembly assembly = Assembly.GetExe cutingAssembly( )
Image image = Image.FromStrea m(assembly.GetM anifestResource Stream("picture .jpg"))

the debugger holds on the second line and tells me that he has no valid value for the stream. So my understanding is that he cannot find the file picture.jpg.
I have been trying all kinds of different things to get the file picture.jpg embedded in the programma but I have no luck.
Can someone be so kind to help me out with this

Thanks Bardo
Nov 16 '05 #1
2 1275
If you are using VS then the picture.jpg needs to be part of the project. It
should appear in the project as an embedded resource. If it is in a
sub-directory, then sub-directories act as namespaces for embedded resources and
so your stream might be named incorrectly in the assembly manifest. A quick
ILDasm of your assembly and looking at the manifest portion will show all of
your embedded resources.

If you are trying to include the item in a normal csc command line compilation
then look at the /resource: option.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Bardo" <an*******@disc ussions.microso ft.com> wrote in message
news:74******** *************** ***********@mic rosoft.com...
I am trying to show a picture in a form but using visual studios C# I am getting a error everytime I want to deploy my program. I cannot find the reason.
Assembly assembly = Assembly.GetExe cutingAssembly( );
Image image = Image.FromStrea m(assembly.GetM anifestResource Stream("picture .jpg"));
the debugger holds on the second line and tells me that he has no valid value for the stream. So my understanding is that he cannot find the file picture.jpg. I have been trying all kinds of different things to get the file picture.jpg embedded in the programma but I have no luck. Can someone be so kind to help me out with this ?

Thanks Bardo

Nov 16 '05 #2
Hi Justin

I am new to C# and I am still trying to learn the language. So I am sorry to say I am not able to follow you fully (yet
I listed my program below so you can see what I am missing. I have tried different approaches. 1) I added a jpg image thru right click on my project and then add existing item. No luck. I made a resource file using the resource file maker (the one that is in the samples directory in the Framework SDK, also no luck. The debugger keeps stopping at the line I marked with ==>. No matter what I try it just doesnt seem to work. Very frustrating

I hope you can help me out here

Bard
using System
using System.Drawing
using System.Collecti ons
using System.Componen tModel
using System.Windows. Forms
using System.Data
using System.Reflecti on

public class Programma: System.Windows. Forms.Form

private System.Drawing. Image buffer

private System.Drawing. Graphics display

public Programma()
InitializeCompo nent()
private void InitializeCompo nent()
SetStyle(System .Windows.Forms. ControlStyles.U serPaint, true)
SetStyle(System .Windows.Forms. ControlStyles.A llPaintingInWmP aint, true)
SetStyle(System .Windows.Forms. ControlStyles.D oubleBuffer, true)
ClientSize = new Size(392, 60)
buffer = new System.Drawing. Bitmap(392, 60)
display = System.Drawing. Graphics.FromIm age(buffer)
new System.Threadin g.Thread(ne
System.Threadin g.ThreadStart(A nimation_Start) ).Start()
private void Animation_Start ()
Assembly assembly = Assembly.GetExe cutingAssembly( )
==> Image image = Image.FromStrea m(assembly.GetM anifestResource Stream("Picture .gif"))
Bitmap bitmap = new Bitmap(56, 60)
Graphics graphics = Graphics.FromIm age(bitmap)
graphics.DrawIm age(image, -168, 0)
display.DrawIma ge(bitmap, 0, 0)
Refresh()
protected override void OnPaint(System. Windows.Forms.P aintEventArgs e)
System.Drawing. Graphics g = e.Graphics
g.DrawImage(buf fer, 0, 0)
base.OnPaint(e)
public static void Main()
System.Windows. Forms.Applicati on.Run(new Programma())
System.Environm ent.Exit(0)


Nov 16 '05 #3

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

Similar topics

6
1983
by: theo.bruening | last post by:
Hello all. I hope someone can help me here. I need to make a db on many pictures, however, if I OLE them, the access database grows hugely. If I only hyperlink them, I can't view them. is there a way how I can hyperlink the pictures and have something like thumbnails to view them in a form? any comment apprecciated. thanks
2
1719
by: thomaz | last post by:
I would like to know the correct way to save an image showing in a Picture Box???? Thanks....
22
1394
by: Andy Chan | last post by:
I'm trying to dynamically add a picturebox control to a form. I'm following some coding I see in the form designer generated code: ....and so far....nothing. Any help is appreciated. Dim myPicture As New PictureBox() With myPicture myPicture = New System.Windows.Forms.PictureBox()
9
2898
by: frizzle | last post by:
Hi there, I have a site where i display all kinds of thumbnails, (all 100 * 100px), the thumbs are links (surprise! ;) ). They link to a page where someone can order the picture. If ordered, a "selected div" is added (via PHP) before the thumbnail. It has to show a small image above the left corner of the thumbnail. Now it works fine in...
0
7612
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
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7968
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
6283
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...
1
5512
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
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
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.