Embedded images?

  • Thread starter Thread starter elziko
  • Start date Start date
E

elziko

I'm trying to use an embedded image(bitmap) using the following code:

imgDrag = New
System.Drawing.Bitmap(GetType(QueryResultGrid).Assembly.GetManifestResourceS
tream("Comp.Tech.QueryResultGrid.ResultsGridDrag.bmp"))

Where QueryResultGrid is the class thats going to use the image,
Comp.Tech.QueryResultGrid is the assembly name and ResultsGridDrag.bmp is
the file name of the embedded resource. However, on runing this line I get:

An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Additional information: 'null' is not a valid value for 'stream'.

Any ideas why? I think that maybe I should be using something other than
"Comp.Tech.QueryResultGrid.ResultsGridDrag.bmp"?
 
Hi,

Here is an example. I added the water lilies.jpg to my app get its
build action to embedded resource.
Dim bm As Bitmap

Dim myAsm As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()

bm = New Bitmap(myAsm.GetManifestResourceStream(Me.GetType, "Water
lilies.jpg"))



Ken
 
* "elziko said:
I'm trying to use an embedded image(bitmap) using the following code:

imgDrag = New
System.Drawing.Bitmap(GetType(QueryResultGrid).Assembly.GetManifestResourceS
tream("Comp.Tech.QueryResultGrid.ResultsGridDrag.bmp"))

Where QueryResultGrid is the class thats going to use the image,
Comp.Tech.QueryResultGrid is the assembly name and ResultsGridDrag.bmp is
the file name of the embedded resource. However, on runing this line I get:

An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Additional information: 'null' is not a valid value for 'stream'.

Any ideas why? I think that maybe I should be using something other than
"Comp.Tech.QueryResultGrid.ResultsGridDrag.bmp"?

Does it work it you use something like that?

Add the image, set its 'Build Action' to 'Embedded Resource', then you
can use this code to load the bitmap:

\\\
Me.picMyPicture.Image = _
New Bitmap( _
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _
"<Root namespace>.<File name>" _
) _
)
///
 
Back
Top