首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么修改bmp格式图片的rgb各分量?

2012-08-28 
如何修改bmp格式图片的rgb各分量????想将一张24位 bmp图片的 后两个分量对调一下 保存成jpg的(bmp的也行)

如何修改bmp格式图片的rgb各分量????
想将一张24位 bmp图片的 后两个分量对调一下 保存成jpg的(bmp的也行)这个该怎么弄啊??请说得详细一点 或者有例子代码~~~~~~~~~谢谢啊~~~~~~~~

[解决办法]
Option Explicit

Private Type DWORD
Value As Long
End Type

Private Type ARGB
R As Byte
G As Byte
B As Byte
A As Byte
End Type

Private Sub Command1_Click()
Me.ScaleMode = 3
Me.MousePointer = vbHourglass

Dim srcpic As String
Dim dscpic As String

Dim i As Long, j As Long
Dim temp As Byte

Dim pixel As Long

Dim dw As DWORD
Dim color_rgb As ARGB

srcpic = "c:\test.jpg"

With Picture1 ''图片框控件PictureBox

.ScaleMode = 3
'加载图片
.Picture = LoadPicture(srcpic)
.AutoRedraw = True
'从上到下逐行扫描
For i = 0 To .ScaleHeight
For j = 0 To .ScaleWidth
'取一个像素点
pixel = .Point(i, j)
dw.Value = pixel
LSet color_rgb = dw

'将G分量与B分量互换
temp = color_rgb.G
color_rgb.G = color_rgb.B
color_rgb.B = temp
color_rgb.R = 0
LSet dw = color_rgb
'画回去
Picture1.PSet (i, j), dw.Value
Next
DoEvents
Next
.Refresh
End With

dscpic = "c:\xxoo.jpg"
'将处理过的图片保存下来
SavePicture Picture1.Picture, dscpic
Me.MousePointer = vbDefault
End Sub

热点排行