本文整理匯總了VB.NET中System.Drawing.Bitmap.Bitmap構造函數的典型用法代碼示例。如果您正苦於以下問題:VB.NET Bitmap構造函數的具體用法?VB.NET Bitmap怎麽用?VB.NET Bitmap使用的例子?那麽, 這裏精選的構造函數代碼示例或許可以為您提供幫助。您也可以進一步了解該構造函數所在類System.Drawing.Bitmap
的用法示例。
在下文中一共展示了Bitmap構造函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: InitializeStreamBitmap
Private Sub InitializeStreamBitmap()
Try
Dim request As System.Net.WebRequest = _
System.Net.WebRequest.Create( _
"http://www.microsoft.com//h/en-us/r/ms_masthead_ltr.gif")
Dim response As System.Net.WebResponse = request.GetResponse()
Dim responseStream As System.IO.Stream = response.GetResponseStream()
Dim bitmap2 As New Bitmap(responseStream)
PictureBox1.Image = bitmap2
Catch ex As System.Net.WebException
MessageBox.Show("There was an error opening the image file. Check the URL")
End Try
End Sub
示例2: Bitmap
Dim image1 As Bitmap
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Try
' Retrieve the image.
image1 = New Bitmap( _
"C:\Documents and Settings\All Users\Documents\My Music\music.bmp", _
True)
Dim x, y As Integer
' Loop through the images pixels to reset color.
For x = 0 To image1.Width - 1
For y = 0 To image1.Height - 1
Dim pixelColor As Color = image1.GetPixel(x, y)
Dim newColor As Color = _
Color.FromArgb(pixelColor.R, 0, 0)
image1.SetPixel(x, y, newColor)
Next
Next
' Set the PictureBox to display the image.
PictureBox1.Image = image1
' Display the pixel format in Label1.
Label1.Text = "Pixel format: " + image1.PixelFormat.ToString()
Catch ex As ArgumentException
MessageBox.Show("There was an error." _
& "Check the path to the image file.")
End Try
End Sub
示例3: ConstructFromResourceSaveAsGif
Private Sub ConstructFromResourceSaveAsGif(ByVal e As PaintEventArgs)
' Construct a bitmap from the button image resource.
Dim bmp1 As New Bitmap(GetType(Button), "Button.bmp")
' Save the image as a GIF.
bmp1.Save("c:\button.gif", System.Drawing.Imaging.ImageFormat.Gif)
' Construct a new image from the GIF file.
Dim bmp2 As New Bitmap("c:\button.gif")
' Draw the two images.
e.Graphics.DrawImage(bmp1, New Point(10, 10))
e.Graphics.DrawImage(bmp2, New Point(10, 40))
' Dispose of the image files.
bmp1.Dispose()
bmp2.Dispose()
End Sub
示例4: BitmapConstructorEx
Private Sub BitmapConstructorEx(ByVal e As PaintEventArgs)
' Create a bitmap.
Dim bmp As New Bitmap("c:\fakePhoto.jpg")
' Retrieve the bitmap data from the bitmap.
Dim bmpData As System.Drawing.Imaging.BitmapData = bmp.LockBits(New Rectangle(0, 0, bmp.Width, bmp.Height), _
ImageLockMode.ReadOnly, bmp.PixelFormat)
'Create a new bitmap.
Dim newBitmap As New Bitmap(200, 200, bmpData.Stride, bmp.PixelFormat, bmpData.Scan0)
bmp.UnlockBits(bmpData)
' Draw the new bitmap.
e.Graphics.DrawImage(newBitmap, 10, 10)
End Sub