AngeloF
asked on
VB & TIFF file.
I need to read a tiff file image into memory. This image would be in 'Bitmap' format. What I'm trying to acomplish is write a program to read a TIFF file and crop any white space .. can anyone help?
Is it - open "file.tif" for ? as #1 ???
thanx for your time....
Is it - open "file.tif" for ? as #1 ???
thanx for your time....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For this, we use the Kofax OCX. You could use also Wang OCX.
ASKER
hi mark, i realy apreciate your prompt response(about 2 hrs.) the image i'm trying to read doesn't have to be Tiff format, i can convert it to BMP format. Could you provide me with an example of how i could get this file's data into memory? would i use the conventional 'Open "file.bmp for input as #1' ???
please help
thanx, Angelo
please help
thanx, Angelo
Nah, just load the image into a picturebox control. VB will handle the reading of disk and converting from .JPG/.BMP for you. Make sure the picturebox's .AutoSize property is TRUE before you load. When you're done loading the image the .Height and .Width properties will give you the dimensions for the image and hence the index's for your row and column loops.
Picture1.Picture = LoadPicture(Filename)
Graphics formats recognized by Visual Basic include bitmap (.bmp) files, icon (.ico) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF files, and JPEG (.jpg) files.
(The above straight from the LoadPicture help)
Anyway, having read the image into the container, you can use the Following to scan the entire image:
for rows = 1 to Picture1.Height
for cols = 1 to Picture1.Width
pel = Picture1.Point(cols, rows)
B = (pel And &HFF0000) / 65536
g = (pel And &HFF00) / 256 Mod 256
r = pel And &HFF
color = "WHITE"
dark = True
If (r > g) And (r > B) Then color = "RED"
If (B > g) And (B > r) Then color = "BLUE"
If (g > r) And (g > B) Then color = "GREEN"
If (r > 128) Or (g > 128) Or (B > 128) Then dark = False
' ... ok, you've got the RGB value's for a single point
next cols
next rows
M
Picture1.Picture = LoadPicture(Filename)
Graphics formats recognized by Visual Basic include bitmap (.bmp) files, icon (.ico) files, run-length encoded (.rle) files, metafile (.wmf) files, enhanced metafiles (.emf), GIF files, and JPEG (.jpg) files.
(The above straight from the LoadPicture help)
Anyway, having read the image into the container, you can use the Following to scan the entire image:
for rows = 1 to Picture1.Height
for cols = 1 to Picture1.Width
pel = Picture1.Point(cols, rows)
B = (pel And &HFF0000) / 65536
g = (pel And &HFF00) / 256 Mod 256
r = pel And &HFF
color = "WHITE"
dark = True
If (r > g) And (r > B) Then color = "RED"
If (B > g) And (B > r) Then color = "BLUE"
If (g > r) And (g > B) Then color = "GREEN"
If (r > 128) Or (g > 128) Or (B > 128) Then dark = False
' ... ok, you've got the RGB value's for a single point
next cols
next rows
M
ASKER