Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 20th, 2005, 03:36 AM
Scott Meddows
Guest
 
Posts: n/a
Default BMP file included as a resource

I've added a BMP file to my project file in Visual Studio and told the
compiler to embed the file into the binary. How do I now read this file
back into a filestream?

Thanks


  #2  
Old November 20th, 2005, 03:36 AM
Justin Weinberg
Guest
 
Posts: n/a
Default Re: BMP file included as a resource

Created with my new tool. Look at the ImageFromEmbedded method below.

'GDIPlus Architect Component Class Output
Public Class Untitled1
Inherits System.ComponentModel.Component

Private Image1Rectangle As System.Drawing.RectangleF = New
System.Drawing.RectangleF(41, 84, 338, 410)

Protected Image1 As System.Drawing.Bitmap

Public Sub New()
MyBase.New
Me.InitializeGraphics
End Sub

Private Sub InitializeGraphics()
Me.Image1 = Me.ImageFromEmbedded("MynameSpace.akeef.jpg")
End Sub

Public Overridable Sub RenderGraphics(ByVal g As
System.Drawing.Graphics)
g.DrawImage(Me.Image1, Me.Image1Rectangle)
End Sub

'Required to dispose of created resources
Private Sub DisposeGraphics()
Me.Image1.Dispose
End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
Me.DisposeGraphics
End If
End Sub

Private Function ImageFromEmbedded(ByVal embeddedPath As String) As
System.Drawing.Bitmap
Dim imageStream As System.IO.Stream =
System.Reflection.Assembly.GetExecutingAssembly.Ge tManifestResourceStream(em
beddedPath)
Dim img As System.Drawing.Bitmap = New
System.Drawing.Bitmap(imageStream)
Return img
End Function
End Class


"Scott Meddows" <scott_meddows_no_spm@tsged.com> wrote in message
news:eSKnGhCjDHA.3204@tk2msftngp13.phx.gbl...[color=blue]
> I've added a BMP file to my project file in Visual Studio and told the
> compiler to embed the file into the binary. How do I now read this file
> back into a filestream?
>
> Thanks
>
>[/color]


  #3  
Old November 20th, 2005, 03:36 AM
Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
Default Re: BMP file included as a resource

"Scott Meddows" <scott_meddows_no_spm@tsged.com> scripsit:[color=blue]
> I've added a BMP file to my project file in Visual Studio and told the
> compiler to embed the file into the binary. How do I now read this file
> back into a filestream?[/color]

<http://www.google.de/groups?selm=uhBexmVhDHA.2516%40TK2MSFTNGP09.phx.gb l>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
  #4  
Old November 20th, 2005, 03:37 AM
Tom Spink
Guest
 
Posts: n/a
Default Re: BMP file included as a resource

Hi Scott,

Imports System.IO
Imports System.Reflection
..
..
..
Dim strmImage As Stream =
[Assembly].GetExecutingAssembly.GetManifestResourceStream("R ootNamespace.Fil
e.bmp")

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations


"Scott Meddows" <scott_meddows_no_spm@tsged.com> wrote in message
news:eSKnGhCjDHA.3204@tk2msftngp13.phx.gbl...[color=blue]
> I've added a BMP file to my project file in Visual Studio and told the
> compiler to embed the file into the binary. How do I now read this file
> back into a filestream?
>
> Thanks
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.