本文整理匯總了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