ndfweb.cn

VB.NET BitmapData类代码示例


2021-08-21 22:23:58 (3150)


本文整理汇总了VB.NET中System.Drawing.Imaging.BitmapData类的典型用法代码示例。如果您正苦于以下问题:VB.NET BitmapData类的具体用法?VB.NET BitmapData怎么用?VB.NET BitmapData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

在下文中一共展示了BitmapData类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1: LockUnlockBitsExample

 点赞 13 

Private Sub LockUnlockBitsExample(ByVal e As PaintEventArgs)    ' Create a new bitmap.
    Dim bmp As New Bitmap("c:\fakePhoto.jpg")    ' Lock the bitmap's bits.  
    Dim rect As New Rectangle(0, 0, bmp.Width, bmp.Height)    Dim bmpData As System.Drawing.Imaging.BitmapData = bmp.LockBits(rect, _
        Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat)    ' Get the address of the first line.
    Dim ptr As IntPtr = bmpData.Scan0    ' Declare an array to hold the bytes of the bitmap.
    ' This code is specific to a bitmap with 24 bits per pixels.
    Dim bytes As Integer = Math.Abs(bmpData.Stride) * bmp.Height    Dim rgbValues(bytes - 1) As Byte

    ' Copy the RGB values into the array.
    System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes)    ' Set every third value to 255. A 24bpp image will look red.
    For counter As Integer = 2 To rgbValues.Length - 1 Step 3
        rgbValues(counter) = 255
    Next

    ' Copy the RGB values back to the bitmap
    System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes)    ' Unlock the bits.
    bmp.UnlockBits(bmpData)    ' Draw the modified image.
    e.Graphics.DrawImage(bmp, 0, 150)End Sub


了解更多请访问:http://www.ndfweb.cn/news-899.html
  NDF俱乐部
  国际域名注册
  建站咨询
合作伙伴:万网 | 新网 | 新网互联 NDF网站建设淘宝店 | 实用工具 | 外貿網站建設 | 联系我们
鲁公网安备 37110202000336号 鲁ICP备2021027697号-1 Sitemap - RSSRSS订阅