Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Structure _bitmap
- Public _Width As System.Reflection.MethodInfo
- Public _Height As System.Reflection.MethodInfo
- Public _GetPixel As System.Reflection.MethodInfo
- Public _ctor As Reflection.ConstructorInfo
- End Structure
- Private _reflected As _bitmap = Nothing
- Sub New()
- 'met toujours sa avent tout
- Dim asm As Reflection.AssemblyName() = System.Reflection.Assembly.GetExecutingAssembly().GetReferencedAssemblies()
- For Each n As Reflection.AssemblyName In asm
- If (n.Name.ToLower() = "system.drawing") Then
- Dim BitmapAssembly As Reflection.Assembly = Reflection.Assembly.Load(n)
- 'test with the bitmap type
- Dim tbmp As Type = BitmapAssembly.GetType("System.Drawing.Bitmap")
- Dim ctor As Reflection.ConstructorInfo = tbmp.GetConstructor(New Type() {tbmp})
- 'BackgroundImage = ctor.Invoke(New Object() {bmp})
- _reflected = New _bitmap()
- _reflected._Height = tbmp.GetMethod("Height")
- _reflected._Width = tbmp.GetMethod("Width")
- _reflected._GetPixel = tbmp.GetMethod("GetPixel")
- _reflected._ctor = ctor
- Exit For
- End If
- Next
- End Sub
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- 'lets pretend this was loaded from resources , do not cast this to bitmap
- Dim bmp As Object = Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\1.bmp")
- BackgroundImage = _reflected._ctor.Invoke(New Object() {bmp})
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment