VB中如何显示灰度图?

YFY 2003-04-08 10:24:35
在VB中显示灰度图怎样实现,
使用 BITMAPINFO 结构时,写不了调色板,
郁闷啊,请大家帮忙看看,路过的请顶一下啊。
...全文
101 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
用户 昵称 2003-04-09
  • 打赏
  • 举报
回复
Public Function ConvertToGrayscale(ByVal source As Bitmap) as Bitmap

Dim bm as new Bitmap(source.Width,source.Height)

Dim x

Dim y

For y=0 To bm.Height

For x=0 To bm.Width

Dim c as Color = source.GetPixel(x,y)

Dim luma as Integer = CInt(c.R*0.3 + c.G*0.59 + c.B*0.11)

bm.SetPixel(x,y,Color.FromArgb(luma,luma,luma)

Next

Next

Return bm

End Function

Sean918 2003-04-09
  • 打赏
  • 举报
回复
简单的理解看这个:

http://vbboshi.myrice.com/vbtech/image/page_2/file58.htm
Sean918 2003-04-09
  • 打赏
  • 举报
回复
现成的 VB 代码:

http://www.vbprobe.com/source/showdoc.asp?detail_id=2849

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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