I am reading a gray scale TIFF, i.e. an image where each pixel value just appears once and all pixels should be interpreted as R=G=B.
I am using 16-bit GflSDK from VB with this code to read it:
Code: Select all
Dim GflParams As GFL_LOAD_PARAMS
Dim PtrBitmap As Long
Dim GflInfo As GFL_FILE_INFORMATION
Dim Error As Integer
gflLibraryInit
gflGetDefaultLoadParams GflParams
With GflParams
.Flags = GFL_LOAD_ORIGINAL_DEPTH
.Origin = GFL_BOTTOM_LEFT 'Origin is top left
.ColorModel = GFL_BGR 'Component order like DIB
.LinePadding = 4 'Line padding on 4 bytes (32bits)
End With
Error = gflLoadBitmap("c:\foto.tif", PtrBitmap, GflParams, GflInfo)
If Error = GFL_NO_ERROR Then
extGetGflBitmapFromPtr PtrBitmap, GflBitmap
Else
Exit Sub
End If
1. How should I open it and know it is not a RGB but gray scale picture?
2. I have managed to access all the data correctly through Color.Red like this (get the "photo.tiff" image from: foto.tif):
Code: Select all
gflGetColorAt GflBitmap, 0, 0, Color ' Get colour at pixel (0,0)
Color.Green -> 906
Color.Blue -> 564
Code: Select all
gflGetColorAt GflBitmap, 1, 0, Color ' Get colour at pixel (1,0)
Color.Green -> 564
Color.Blue -> 900
Code: Select all
gflGetColorAt GflBitmap, 2, 0, Color ' Get colour at pixel (2,0)
Color.Green -> 900
Color.Blue -> 564
Code: Select all
gflGetColorAt GflBitmap, 3, 0, Color ' Get colour at pixel (3,0)
Color.Green -> 564
Color.Blue -> 910
...
The values obtained from Color.Red, Color.Green and Color.Blue are not the same, they are cyclic. Just by reading Color.Red I can obtain the entire image data set, but there must be some other way to properly access this kind of images; I guess there must be some LOAD or READ PARAMETER that forces the library to interpret the image as grey scale but I cannot fin which one.
Could you please help?
Thank you very much.