本文整理汇总了VB.NET中System.Drawing.Image.FromFile方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Image.FromFile方法的具体用法?VB.NET Image.FromFile怎么用?VB.NET Image.FromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Image
的用法示例。
在下文中一共展示了Image.FromFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: DemonstratePropertyItem
Private Sub DemonstratePropertyItem(ByVal e As PaintEventArgs)
' Create two images.
Dim image1 As Image = Image.FromFile("c:\FakePhoto1.jpg")
Dim image2 As Image = Image.FromFile("c:\FakePhoto2.jpg")
' Get a PropertyItem from image1.
Dim propItem As PropertyItem = image1.GetPropertyItem(20624)
' Change the ID of the PropertyItem.
propItem.Id = 20625
' Set the PropertyItem for image2.
image2.SetPropertyItem(propItem)
' Draw the image.
e.Graphics.DrawImage(image2, 20.0F, 20.0F)
End Sub
示例2: CType
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim image1 As Bitmap = _
CType(Image.FromFile("C:\Documents and Settings\" _
& "All Users\Documents\My Music\music.bmp", True), Bitmap)
Dim texture As New TextureBrush(image1)
texture.WrapMode = Drawing2D.WrapMode.Tile
Dim formGraphics As Graphics = Me.CreateGraphics()
formGraphics.FillEllipse(texture, _
New RectangleF(90.0F, 110.0F, 100, 100))
formGraphics.Dispose()
Catch ex As System.IO.FileNotFoundException
MessageBox.Show("There was an error opening the bitmap." _
& "Please check the path.")
End Try
End Sub
示例3: TransparentColor
' 导入命名空间
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class TransparentColor
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
public class Form1
Inherits System.Windows.Forms.Form
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Dim g As Graphics = e.Graphics
Dim curImage As Image = Image.FromFile("yourfile.jpg")
g.DrawImage(curImage, 0, 0, curImage.Width, curImage.Height)
Dim opqPen As New Pen(Color.FromArgb(255, 0, 255, 0), 10)
Dim transPen As New Pen(Color.FromArgb(128, 0, 255, 0), 10)
Dim totTransPen As New Pen(Color.FromArgb(40, 0, 255, 0), 10)
g.DrawLine(opqPen, 10, 10, 200, 10)
g.DrawLine(transPen, 10, 30, 200, 30)
g.DrawLine(totTransPen, 10, 50, 200, 50)
Dim semiTransBrush As New SolidBrush(Color.FromArgb(60, 0, 255, 0))
g.FillRectangle(semiTransBrush, 20, 100, 200, 100)
End Sub
Public Sub New()
MyBase.New()
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
End Sub
End Class