ImageGear Professional for Windows ActiveX
Controlling Format Detection

When IGFormatsCtl Control processes a LoadPage Method, LoadPageFromFile Method, LoadDocument Method or LoadDocumentFromFile Method call, it uses automatic format detection to determine the type of image file. Normally, on a Windows computer, an application can only use the "filename extension" (letters following the last period in the filename) to determine the file type. For example, programs normally must assume that a file named "myfile.jpg" contains a JPEG file.

With ImageGear, your application has the advantage of automatic format detection: when your application calls the LoadPageFromFile Method (or any of the other 3 file I/O mechanisms), IGFormatsCtl Control actually reads in the first few bytes in the file and then asks each active format filter: "is this one of yours?" Therefore, if the file were named "myfile.jpg", but in fact contained a GIF file, the IGFormatsCtl Control processing would be able to load it successfully.

Your application can control automatic format detection. This is done by using the DetectionEnabled and DetectionPriority properties of the various IGFormatParams Object. To disable the automatic detection of some formats (and thus speed up Loadxxx processing), set some of the DetectionEnabled properties to False.

If you turn off automatic detection of a particular format, then any attempt to load a file of that format will generate an "unknown format" error.

Your application can also give preference to particular formats. Thus, if it's very likely that users of your application will be working with FlashPix files, then your application can execute the following statements to have IGFormatsCtl Control check every file for FlashPix first:

 
Copy Code
Dim flashpix as IGFormatParams
Dim temp as IGFormatParams
Dim i As Integer
For i = 0 To IGFormatsCtl1.Settings.FormatCount - 1
Set temp = IGFormatsCtl1.Settings.Format(i)
If temp.ID = IG_FORMAT_FPX Then
Set flashpix = temp
flashpix.DetectionPriority = 255
Break
End If
Next i

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback