请问那里有用vb.net写的图象处理程序代码的例子。

laviewpbt 2005-11-24 01:35:01
找到一些,怎么都是用setpixel之类的方法做的,效率也太低下了吧,6.0里可以用DIB,.net里该怎么用呢?
...全文
298 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
slhuang 2005-12-09
  • 打赏
  • 举报
回复
个人认为,图象处理不是VB。NET的优势。
有志于图象开发的话,还是用VC好用一点。
laviewpbt 2005-11-27
  • 打赏
  • 举报
回复
我试了下,好像GDI+的速度也并不是很慢阿,还有用colormatrix与Marshal.Copy两者的处理速度也差不到那里去的 .
laidon 2005-11-27
  • 打赏
  • 举报
回复
偶买了本<<VB.net图形图像处理技术>>的书,光盘中有很多实例,但我觉得用.net还是msdn更详细,有原理。要实例和我联系吧,QQ71451437
AprilSong 2005-11-26
  • 打赏
  • 举报
回复
用Marshal.Copy先转成数组要快得多~

Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
Dim bmp As New Bitmap("1.jpg")

Dim t As Single

t = Microsoft.VisualBasic.DateAndTime.Timer
If e.Button = MouseButtons.Left Then
PictureBox1.Image = InvertBitmap(bmp)
Else
PictureBox1.Image = InvertBitmap2(bmp)
End If
t = Microsoft.VisualBasic.DateAndTime.Timer - t

Me.Text = "耗时:" & t
End Sub

Private Function InvertBitmap(ByVal pBitmap As Bitmap) As Bitmap
Dim width As Integer = pBitmap.Width
Dim height As Integer = pBitmap.Height
Dim rect As Rectangle = New Rectangle(0, 0, width, height)
Dim bitmapData As BitmapData = pBitmap.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb)
Dim stride As Integer = bitmapData.Stride
Dim RawData As IntPtr = bitmapData.Scan0

Dim i As Integer
Dim l As Integer = height * stride - 1
Dim b As Byte
Dim m As Byte = 255

For i = 0 To l
b = Marshal.ReadByte(RawData, i)
Marshal.WriteByte(RawData, i, m - b)
Next

pBitmap.UnlockBits(bitmapData)

Return pBitmap
End Function

Private Function InvertBitmap2(ByVal pBitmap As Bitmap) As Bitmap
Dim width As Integer = pBitmap.Width
Dim height As Integer = pBitmap.Height
Dim rect As Rectangle = New Rectangle(0, 0, width, height)
Dim bitmapData As BitmapData = pBitmap.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb)
Dim stride As Integer = bitmapData.Stride
Dim RawData As IntPtr = bitmapData.Scan0

Dim i As Integer
Dim l As Integer = height * stride - 1
Dim b(l) As Byte
Dim m As Byte = 255

Marshal.Copy(RawData, b, 0, l)
For i = 0 To l
b(i) = m - b(i)
Next
Marshal.Copy(b, 0, RawData, l)

pBitmap.UnlockBits(bitmapData)

Return pBitmap
End Function
chenlin2000 2005-11-26
  • 打赏
  • 举报
回复
把ptr中内容填充到一个数组中如何
laviewpbt 2005-11-26
  • 打赏
  • 举报
回复
多谢AprilSong(X)
laviewpbt 2005-11-25
  • 打赏
  • 举报
回复
谢谢楼上,这个我知道,不过我想了解有没有快点的方法从bitmapData 中读取数据。在循环内频繁地调用marshal.readint32似乎不是个好注意。
AprilSong 2005-11-25
  • 打赏
  • 举报
回复
只要反色的话,这样快得多~

Dim bmp As New Drawing.Bitmap("1.jpg")

Dim cm As New Drawing.Imaging.ColorMatrix
Dim ia As New Drawing.Imaging.ImageAttributes

cm.Matrix00 = -1
cm.Matrix11 = -1
cm.Matrix22 = -1

ia.SetColorMatrix(cm, Imaging.ColorMatrixFlag.Default, Imaging.ColorAdjustType.Bitmap)

Dim g As Graphics = Drawing.Graphics.FromImage(bmp)
g.DrawImage(bmp, New Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, ia)

PictureBox1.Image = bmp
chenlin2000 2005-11-25
  • 打赏
  • 举报
回复
用marshal.readint32读取每一个像素值
laviewpbt 2005-11-25
  • 打赏
  • 举报
回复
比如我要反色,则下面的两个循环之间该怎么写?

Private Function InvertBitmap(ByVal pBitmap As Bitmap) As Boolean
Dim width As Integer = pBitmap.Width
Dim height As Integer = pBitmap.Height
Dim rect As Rectangle = New Rectangle(0, 0, width, height)
Dim bitmapData As BitmapData = pBitmap.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb)
Dim stride As Integer = bitmapData.Stride
Dim RawData As IntPtr = bitmapData.Scan0
Dim x, y As Integer
For y = 0 To height
For x = 0 To width

Next
Next
pBitmap.UnlockBits(bitmapData)
Return True
End Function
xiaoguanguan 2005-11-24
  • 打赏
  • 举报
回复
看msdn吧.比较详细呢.
AprilSong 2005-11-24
  • 打赏
  • 举报
回复
上面是基本的颜色矩阵操作
更复杂的就转成字节数组来做,和dib的图象处理是类似的
http://community.csdn.net/Expert/topic/4411/4411199.xml?temp=.1745722
AprilSong 2005-11-24
  • 打赏
  • 举报
回复
用GDI+……

http://community.csdn.net/Expert/TopicView.asp?id=4369343

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧