|
-
Feb 1st, 2008, 06:28 AM
#1
Thread Starter
Lively Member
[RESOLVED] (VB6)How to Read Values under Character Codes?
Hi All my friends,
This is the Characters from an Tiff Image File I Want to read :
II* þ @ Þ @ Þ Î Ö ( ) – – Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ
Þ‚
Þ Þ‚ Þ Þ‚ Þ
Þ‚
Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ Þ Þ‚ € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € € œºœº ¹ ¹œº˜¹˜¹'¹ä¹Ù¸¹3¸3¸‡¸¡¹Ý¹ºº¶¹‡¹¹¹@¹º¸ºNº?ºí¹ò¹š¹’� �²¹†¹‡¹b¹¹…¹¿¹«¹]¹¹,¹_¹x¹h¹¼¹o¹K¹B¹i¹Ë¹ª¹°¹“¹Ê¹Ä¹ º¥¹|¹8¹e¹í¹ƒº¿ºÒºß¹Í¹g¹¨¹I¹x¹y¹*¹Ò¹d¹!¹6¹]¹›¹n¹K¹2¹Y¹ž¹³¹¹c¹’¹¹¹x¹ ¹ë¸$¹1¹a¹p¹Z¹b¹–¹î¹Ð¹¹¹3¹è¹ºÐ¹‹¹4¹¹¸¹G¹,¹ð¸W¹k¹ƒ¹-¹
¹æ¸L¹+¹M¹l¹F¹–¹“¹œ¹‡¹l¹¹ ¹õ¸¹9¹¹¹¹E¹6¹¹¹Ñ¸ê¸S¸
Could some one tell me how to recognise the data hidden under these characters,
this line is the header information from TIFF image file, as it consists of Tags and Values for that tags. Is there any method without using APIs to convert these values to its original ones.
In VB though after reading this file in binary mode, the original values cant get visible.
Or I am missing something.
My Code :
Const Buffer=2
Dim strData As String
Open txtPath.Text For Binary Access Read As nHandle
lSize = LOF(nHandle)
If nHandle = 0 Then
Close nHandle
End If
ReDim Chunk(lSize - 1)
Get nHandle, , Chunk
For i = 1 To UBound(Chunk)
' Need to Print the Original Value
' either it may be String or a Numeric Value
' As XResolution: 1024
strData = Chr(Chunk(i))
Debug.Print strData
Next
Close nHandle
As Converting to Chr() again prints its Character Code ; I got really confounded to get exact results.
Looking for quick help....
Thanks in advance
-
Feb 1st, 2008, 06:37 AM
#2
Lively Member
Re: (VB6)How to Read Values under Character Codes?
Since this is a header of an image file, try searching the format description.
Reading is as binary won't do it. It just seems to get some meaningless data.
What you are trying is to open a binary file stored with some user defined type,
and reading it byte by byte to decode.
You may try creating a binary file of your own and reading it the same way you try to read the .Tiff image header(assume you don't know what is in the file) . The result will be almost the same.
Last edited by tatkosmurff; Feb 1st, 2008 at 06:42 AM.
-
Feb 1st, 2008, 08:16 AM
#3
Re: (VB6)How to Read Values under Character Codes?
If you want to read a *.tif then you have to know how its structured. Your first stop should be a *.tif developer reference like the one at adobe.
This might help to get you started....
Code:
Option Explicit
Const TIF_LITTLE_ENDIAN = &H4949
Const TIF_BIG_ENDIAN = &H4D4D
Private Type tTiffFileHeader
ByteOrder As Integer
Is42 As Integer
IFDOffset As Long
End Type
Private Type tTiffDirectoryEntry
Tag As Integer
Type As Integer
Count As Long
ValueOffset As Long
End Type
Private Type tTiffImageFileDirectory
Count As Integer
Entrys() As tTiffDirectoryEntry
IFDOffset As Long
End Type
Private Sub Command1_Click()
Dim TifIDF() As tTiffImageFileDirectory, i As Long, ii As Long
TifIDF = TiffInfo(App.Path & "/test.tif")
For i = 0 To UBound(TifIDF)
With TifIDF(i)
Debug.Print "Image " & i,
Debug.Print .Count & " entrys"
Debug.Print "No", "tag", "type", "count", "value / offset"
For ii = 0 To .Count - 1
With .Entrys(ii)
Debug.Print ii + 1, .Tag, .Type, .Count, .ValueOffset
End With
Next ii
End With
Next i
End Sub
Private Function TiffInfo(filename As String) As tTiffImageFileDirectory()
Dim FF As Integer
Dim H As tTiffFileHeader
Dim IDF() As tTiffImageFileDirectory
Dim IDFub As Long
Dim NextOffset As Long
Dim i As Long
IDFub = -1
If LenB(Dir(filename)) Then
'On Error GoTo eh:
FF = FreeFile
Open filename For Binary As #FF
Get #FF, , H
If H.ByteOrder = TIF_LITTLE_ENDIAN Then
If H.Is42 = 42 Then
NextOffset = H.IFDOffset + 1
Do While NextOffset
IDFub = IDFub + 1
ReDim Preserve IDF(IDFub)
With IDF(IDFub)
Get #FF, NextOffset, .Count
If .Count > 0 Then
ReDim .Entrys(.Count - 1)
Get #FF, , .Entrys
Get #FF, , .IFDOffset
NextOffset = .IFDOffset + 1
End If
End With
Loop
End If
End If
Close #FF
End If
eh:
If IDFub < 0 Then
ReDim TiffInfo(-1 To -1) 'to show a fail
Else
TiffInfo = IDF()
End If
End Function
-
Feb 11th, 2009, 05:03 AM
#4
Thread Starter
Lively Member
Re: (VB6)How to Read Values under Character Codes?
Hello Milk ,,
and very sorry to post feedback after long time .....
Thanks for u r Code which lead me towards initial steps of reading a Tiff format file .... I go through the Tiff file format specification and though was successful in reading a tiff file for my application purpose.
Thanks again to both of u ...
Regds,,
-
Feb 11th, 2009, 09:00 AM
#5
Re: [RESOLVED] (VB6)How to Read Values under Character Codes?
I thought I might have scared you off 
I ended up writing a small class that enumerates and navigates tags, it might be useful to you....
http://www.vbforums.com/showthread.p...29#post3322529
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|