Hi,
I'm not too experiences with using VB for image manipulation, so I need some help.
What I need to do is create a routine that reads in a BMP, changes all of the RGB values that are greater then 240 to 255 and then export the image with a new filename.
I took a look at the thread of
but was probably more confused after then before.
In the past I used an expanded version of this code to identify all of the 0 RGB values in a BMP. I was hoping to adapt it to do this routine as well. Any help would be appreciated.
Thanks!
Mike
Private Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Dim bfh As BITMAPFILEHEADER, bih As BITMAPINFOHEADER
Dim FNum As Integer, Bits() As Byte
Dim bmp() As Long
Dim scLine() As Byte
FNum = FreeFile
ReDim bmp(bih.biWidth, bih.biHeight)
ReDim scLine(bih.biWidth * 3)
Open List1.List(i) For Binary As #1
For y = bih.biHeight - 1 To 0 Step -1
Get #1, , scLine
For X = 0 To ((bih.biWidth) * 3) - 1 Step 3
bmp(X / 3, y) = RGB(scLine(X), scLine(X + 1), scLine(X + 2))
If bmp(X / 3, y) = 0 Then
'Increase counter
End If
Next
Next
I'm not too experiences with using VB for image manipulation, so I need some help.
What I need to do is create a routine that reads in a BMP, changes all of the RGB values that are greater then 240 to 255 and then export the image with a new filename.
I took a look at the thread of
but was probably more confused after then before.
In the past I used an expanded version of this code to identify all of the 0 RGB values in a BMP. I was hoping to adapt it to do this routine as well. Any help would be appreciated.
Thanks!
Mike
Private Type BITMAPFILEHEADER
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Dim bfh As BITMAPFILEHEADER, bih As BITMAPINFOHEADER
Dim FNum As Integer, Bits() As Byte
Dim bmp() As Long
Dim scLine() As Byte
FNum = FreeFile
ReDim bmp(bih.biWidth, bih.biHeight)
ReDim scLine(bih.biWidth * 3)
Open List1.List(i) For Binary As #1
For y = bih.biHeight - 1 To 0 Step -1
Get #1, , scLine
For X = 0 To ((bih.biWidth) * 3) - 1 Step 3
bmp(X / 3, y) = RGB(scLine(X), scLine(X + 1), scLine(X + 2))
If bmp(X / 3, y) = 0 Then
'Increase counter
End If
Next
Next