can any one tell me how to open image of .CAL extension or .TIFF extension in vb6

srikanth48 0 Tallied Votes 339 Views Share

Type BITMAPFILEHEADER
bfType As Integer
bfsize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfoffbits As Long
End Type


Type BMPInfoHeader
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

i need to get the size , height , width , color depth , dots per inch of particular image file with .CAL extension or TIFF extension usng visual basic6.
LIKe bmpfileheader.do u have any  variable names for those extensions?i need to get those height n width etc using binary file handling function .
you can see below an example of other format.

Dani AI

Generated

Short summary and practical next steps (for , , )

TIFF and CAL are not like BMP: BMP has a fixed, simple header you can map to a VB Type. CAL (usually the CALS raster used for technical documents) is typically a 1‑bit bi‑level format (often uncompressed or CCITT Group‑4 compressed) and uses its own file layout; the .CAL extension is overloaded so always confirm the file signature first. TIFF is far more flexible: it stores an 8‑byte file header that points to one or more Image File Directories (IFDs) and then uses tag records (ImageWidth, ImageLength, BitsPerSample, XResolution/YResolution, ResolutionUnit, etc.) rather than one fixed header block. (en.wikipedia.org)

Why you probably should not try to reimplement TIFF parsing from scratch in VB6
TIFF uses endianness flags (“II”/“MM”), offsets to IFDs, variable tag data types (SHORT, LONG, RATIONAL, arrays), multi‑strip/tile layouts and many compression schemes. Correctly extracting DPI requires reading RATIONAL tags (numerator/denominator) and checking ResolutionUnit. Handling multipage TIFFs adds another IFD loop. Doing all of this reliably is fiddly and error‑prone compared with using an existing library. (fileformat.info)

Concrete options you can use from VB6 (ordered from easiest to most control)

  • Use the WIA automation layer from VB6 to load images and read common properties (WIA exposes image properties and works on modern Windows). This is the simplest VB6-native route. (learn.microsoft.com)
  • Use a tested imaging library (FreeImage has VB/.dll wrappers and ActiveX samples; it supports TIFF and common conversions), or libtiff for low‑level TIFF work. These save you from implementing tag parsing, compression, and edge cases. (freeimage.sourceforge.io)
  • If you must parse raw: read first 8 bytes, detect byte order and the IFD offset, then walk the IFD entries looking for tags 256/257/258/282/283/296 and follow any offsets those tags point to. Expect to implement RATIONAL parsing and support multiple strips/pages.

Tiny VB6 starting snippet to detect a TIFF header (adapt and expand for full parsing):

Dim h As Integer, hdr As String * 8
Open filePath For Binary As #1
Get #1, , hdr
Close #1

If Left$(hdr,2) = "II" Or Left$(hdr,2) = "MM" Then
  ' good candidate for TIFF: next bytes contain 42 and offset to first IFD
End If

Troubleshooting tips
Always verify the file signature (not the extension). If you only need width/height/DPI for many files, converting uncommon CAL variants to TIFF/PNG with a batch tool or using FreeImage to read metadata is usually faster and safer than rolling your own parser. (freeimage.sourceforge.io)

vb5prgrmr 169 Posting Virtuoso

On win2k and earlier you can use the Wang/Kodak imaging controls (image edit, image admin, etc), on xp and later you can use WIA (Window Image Acquisition). Search MS for the SDK download...

Good Luck

srikanth48 0 Newbie Poster

how to open .cal or .tiff extension image files from vb6.i dint get solution.
for exaple we can open image binary text from bmp or gif by type declarations lik BMPHEADERINFO and BMPFILEINFO.
Type BITMAPFILEHEADER
bfType As Integer
bfsize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfoffbits As Long
End Type

In this way, can you say me how to read image text like height,width,size,bitcount of .cal and .tiff extension image there is no solution lik above user define type declaration.
then how can i get image header text information of tiff or gif.and i want code????

vb5prgrmr 169 Posting Virtuoso

First, you have created this thread as a code snippet asking how to do something. Second, I gave you the leads you need to solve your problem, and now third you are demanding code??? Well, I don't think so. You want code, see the WIA 2.0 SDK that you can download from MS or use your friends (yahoo, google, ask, answers, bing).

srikanth48 0 Newbie Poster

Thank you vb5progrmr,i dont know how to ask or use this wonderful website.iam new to this form.i need solution urgently.thank you for ur information

vb5prgrmr 169 Posting Virtuoso

Look at this search of MS's web site....

See the second one down? When you click on that go to the bottom and go after v2.0 if you need to. The SDK has examples and if you look further down, you will see a tutorial page for WIA.

Use your friends (yahoo, google, ask, answers, bing) and search the web for vb6 wia sample as I did here...

http://search.yahoo.com/search?p=vb6+wia+sample&toggle=1&cop=mss&ei=UTF-8&fr=yfp-t-701


Good Luck

Jupiter 2 0 Posting Whiz

As for vb5progrmr instructions, i wouldn't waste my time with it either. If he cannot provide you with the code then go to another forum where people are a little bit more forthcoming. I would like to help but as far as I know, you cannot determine an extension that is not part of the VB6 picture extension formats. I think they are - *.bmp, *.gif, *.jpg.

You need to be able to read the properties of the image as you will not be able to load then determine the properties.

You need to be able to access the properties of the file and figure out how to read the dimensions.

vb5prgrmr 169 Posting Virtuoso

J2, read the forum rules...

AND, if the OP would download the WIA SDK they would have all the example code they would need. It is that simple!

By the way, Classic VB or Visual Basic 6.0 has the ability to display BMP, ICO, GIF, JPG, JPEG, EMF, WMF. Then with win95 to win2k the Wang/Kodak controls allowed us to display Tiff files among other formats, and after that, MS invented WIA so various formats could be displayed including Tiff. Then with the use of WIA or GDI+ PNG's can be displayed...

As for giving away code J2, I am not in business or in the habit of doing such a thing as I am paid to create code, so why would I just give it away???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.