"WSQ image library" for Windows 64-bit (version 2.1)
FBI certified WSQ implementation number:
11280 (scanned certificate)


Registered users of version 1.0-2.x please upgrade to version 2.1 free of charge
  

WSQ image library adds the power of WSQ (FBI's Wavelet Scalar Quantization) file format to your software projects using only a few lines of code.
The source code of WSQ image library contains 20,099,433 lines of code and saves you months of tedious work.
The library also supports 21 other graphic file formats and allows conversion between them.

Click here for Free WSQ Viewer which demonstrates capabilities of WSQ image library.


Windows 32-bit version of WSQ image library is available here.
Linux 32-bit version of WSQ image library is available here.
Linux 64-bit version of WSQ image library is available here.
Android version of WSQ image library is available here.
Windows CE/Windows Mobile/Pocket PC version of WSQ image library is available here.
WSQ image library for Texas Instruments family microprocessors (embedded systems) is available here.



Importance of WSQ format

Electronic fingerprints submitted to the FBI either through Integrated Automated Fingerprint Identification System (IAFIS), or Electronic Fingerprint Image Print System (EFIPS) may not be compressed with any technique other than WSQ.


Price of WSQ image library

WSQ image library (for Windows 64-bit) costs 253.00 U.S. dollars for the first license (single developer license) and 19.00 U.S. dollars per every additional license (client computer), which is the lowest price on the market.
WSQ image library (for Windows 64-bit) runtime free / royalty free license costs 3158.00 U.S. dollars.

Linux 32-bit, Linux 64-bit, Windows 32-bit, Windows 64-bit, Windows CE/Windows Mobile/Pocket PC, and Android versions of WSQ Image Library are considered separate products and each has its own pricing.
To order WSQ image library please click here


WSQ image library specifications

Table 1 Format of WSQ image library

Feature Format
Operating system Windows 2003/NT/XP/Vista/7/8/10 (64-bit)
Library format DLL (Dynamic Link Library)
Format of exported functions C language
Calling convention
of exported functions
(default)
__cdecl
Calling conventions
of exported functions
available through additional
wrapper DLL interface
JNIEXPORT
Internal engine C++

Table 2 Supported formats for reading

Format Description
WSQ FBI's Wavelet Scalar Quantization
BMP Windows Bitmap Graphics
TIFF Macintosh Tagged Information File Format images
TIF PC Tagged Information File Format images
JPG, JPEG, JPE, JFI Joint Photographic Experts Group images
JP2, J2K JPEG2000 Part 1 images
JPC JPEG2000 Code Stream images
PNG Portable Network Graphics images
GIF Compuserve Graphic Interchange Format images
TGA Truevision Targa Graphic images
PCX ZSoft Paintbrush images (PC Paintbrush Bitmap Graphic)
PPM Portable Pixel Map Images
PGM Portable Gray Map Images
ICO Windows Icons
WMF, EMF Windows Metafiles
WBM, WBMP Wireless Bitmap File Format
SKA SKA Format images
MNG, JNG Muti-image Network Graphic Animation
PNM, PGM, PPM PBM Portable Any Map Graphic Bitmap
RAS Sun Graphic
RAW, CRW, CR2,
DNG, ARW, ERF,
3FR, DCR, RAW,
X3F, MEF, RAF,
MRW, PEF, SR2,
ORF
RAW Graphic

Table 3 Supported formats for writing

Format Description
WSQ FBI's Wavelet Scalar Quantization
BMP Windows Bitmap Graphics
TIFF Tagged Information File Format (no LZW compression)
PNG Portable Network Graphics
JPEG Joint Photographic Experts Group
TGA Truevision Targa Graphic
JP2 JPEG2000 Part 1
JPC JPEG2000 Code Stream
GIF Compuserve Graphic Interchange Format images
PNM PBM Portable Any Map Graphic Bitmap
RAS Sun Graphic
MNG Muti-image Network Graphic Animation
PCX ZSoft Paintbrush images (PC Paintbrush Bitmap Graphic)

Table 4 Functions available in the library

Function Description
HBITMAP CreateBMPFromFile(const char *filename) Creates an HBITMAP from an image file. The extension of the file name determines the file type. Always returns 24-bit DIB (Device Independent Bitmap) HBITMAP. Returns an HBITMAP if successful, NULL otherwise.
SaveBMPToFile(HBITMAP hBitmap, const char *filename, int filetype) Saves the contents of an HBITMAP to a file. Returns 1 if successful, 0 otherwise.
"filetype" denotes integer with possible values:
1 - WSQ
2 - Windows BMP
3 - TIFF
4 - PNG
5 - JPEG
6 - Targa
7 - not available
8 - JP2
9 - JPC
10 - GIF
11 - PNM
12 - RAS
13 - MNG
14 - PCX
HBITMAP CreateBMPFromWSQByteArray(unsigned char *input_wsq_byte_array, int size_of_input_wsq_byte_array) Creates an HBITMAP from WSQ compressed byte array. Returns an HBITMAP if successfull, NULL otherwise.
int SaveWSQByteArrayToImageFile(unsigned char *input_wsq_byte_array, int size_of_input_wsq_byte_array, const char *filename, int filetype) Saves WSQ compressed byte array to an image file. Returns 1 if successfull, 0 otherwise.
"filetype" denotes integer with possible values:
1 - WSQ
2 - Windows BMP
3 - TIFF
4 - PNG
5 - JPEG
6 - Targa
7 - not available
8 - JP2
9 - JPC
10 - GIF
11 - PNM
12 - RAS
13 - MNG
14 - PCX
void WriteWSQ_bitrate(double bitrate) Sets current WSQ bitrate. For example 0.75, 2.25 (-1.0 if unknown)
double ReadWSQ_bitrate() Reads current WSQ bitrate. For example 0.75, 2.25 (-1.0 if unknown)
void WriteWSQ_ppi(int ppi) Sets current WSQ ppi (pixels per inch). Value "-1" is used for unknown ppi.
int ReadWSQ_ppi() Reads current WSQ ppi (pixels per inch). Value "-1" is used for unknown ppi.
void WriteWSQ_comment(char *comment) Sets current WSQ comment text.
char* ReadWSQ_comment() Reads current WSQ comment text.
void WriteTIFFcompression(int tiff_compression) Empty legacy function. For compatibility with Windows 32-bit version of the WSQ image library.
void WriteTIFFpredictor(int tiff_predictor) Empty legacy function. For compatibility with Windows 32-bit version of the WSQ image library.
void SetShowFilePropertiesDialog(int file_properties_dialog) Empty legacy function. For compatibility with Windows 32-bit version of the WSQ image library.
void ShowFileConverter() Empty legacy function. For compatibility with Windows 32-bit version of the WSQ image library.
int WSQ_decode_stream(unsigned char *input_data_stream, const int input_stream_length, unsigned char **output_data_stream, int *width, int *height, int *ppi, unsigned char **comment_text)Decodes memory stream (memory block) from WSQ format into uncompressed format. Returns 1 if successful, or error code otherwise.
int WSQ_encode_stream(unsigned char *input_data_stream, const int width, const int height, const double bitrate, const int ppi, char *comment_text, unsigned char **output_data_stream, int *output_stream_length)Encodes memory stream (memory block) from uncompressed format into WSQ format. Returns 1 if successful, or error code otherwise.
HBITMAP ConvertHBITMAPtoGrayScale256(HBITMAP hBitmap) Converts any HBITMAP to 8-bit 256 grayscale HBITMAP. Returns an HBITMAP if successful, NULL otherwise.
int SaveHBITMAPtoFileAsGrayScale256BMP(HBITMAP hBitmap, const char *filename) Saves the contents of an HBITMAP to 8-bit 256 grayscale BMP file. Returns 1 if successful, 0 otherwise.
int ReadWSQ_implementation_number()Reads WSQ implementation number.
RegisterWSQ() Registers WSQ image library on the computer. Returns 1 if successful, 0 otherwise.



WSQ format description

In the USA, fingerprints have traditionally been collected on cards, each card containing the inked impressions of all ten fingers. The U.S. Federal Bureau of Investigation's fingerprint database began in 1924 with a cataloged collection of 810,188 cards. By the start of World War II, this collection had grown to over 10 million cards, and by 1946 had reached over 100 million cards.

In 1995 this collection was contained on over 200 million cards stored in filing cabinets occupying one acre of floor space in the J. Edgar Hoover building in Washington D.C. and archive size was increasing at the rate of 30,000 to 50,000 new cards per day. Digitization of fingerprint cards seemed to be the most obvious choice and the project named FBI's Integrated Automated Fingerprint Identification System (IAFIS) was started to cope with the design and implementation of a national standard for collecting, encoding, storing, and retrieving digitized fingerprint images. According to the FBI standard fingerprints are stored as 8-bit grayscale images. Each fingerprint card, when digitized at 500 dpi requires about 10 Mbytes of storage. The FBI's entire collection would therefore consume two petabytes (2,000,000,000 megabytes) of electronic storage space.

The need for an effective compression technique was then very urgent. Unfortunately, neither the well-known lossless methods nor the JPEG methods were found to be satisfactory. Most lossy compression methods, such as JPEG, discard the smallest (highest frequency) details in images, and at higher compression ratios unacceptably distort the image. Contained within fingerprints are tiny details that are considered admissible points of identification in a court of law. To JPEG, these details may be regarded as noise and removed. The JPEG quantization matrix also allows blocking artifacts to occur in the image at compression ratios above about 10:1. Shifting bits to the high frequencies to preserve small details will only make the blocking worse. Lossless compression methods, such as LZW and JBIG, cannot achieve the high compression ratios of WSQ on fingerprint data, with 2:1 typically being the best. A new compression technique (with small acceptable loss), called Wavelet Scalar Quantization (WSQ) was developed and it became the FBI standard for the compression of 500 dpi fingerprint images.

WSQ is a lossy compression method that is well-suited for preserving the very high resolution details of grayscale images while maintaining high compression ratios of typically 12:1 to 15:1 on images that have not undergone "quality enhancements" (such as histogram equalization) to improve the appearance of the image.

Table 5 WSQ file format specifications

Feature Description
Name FBI's Wavelet Scalar Quantization file format.
Also known as: FBI Fingerprint Format or FBI WSQ
Application The standard file format used by the FBI for storage and interchange of grayscale fingerprint images
Originator FBI (U.S. Federal Bureau of Investigation)
Type Bitmap
Colors 8 bit grayscale
Compression Wavelet Scalar Quantization
Maximum image size 64K x 64K
Multiple images per file No



Adding WSQ image library to your software project

Using WSQ image library is very easy. Only 2-3 steps and a few lines of code are needed. Several examples are provided below.

On some older Windows 64-bit operating systems (like for example Windows Server 2003 64-bit) installation of free "C++ 2008 SP1 Redistributable Package" might be needed.
"C++ 2008 SP1 Redistributable Package" is available at the address:
Microsoft Visual C++ 2008 SP1 Redistributable Package (x86)
Microsoft Visual C++
Microsoft Visual C++ .NET
Microsoft Visual C# .NET
Microsoft Visual Basic .NET
Embarcadero C++ Builder
Sun Java
MinGW C/C++
Embarcadero Delphi
Lazarus
PHP


Microsoft Visual C++

Step 1

Load WSQ library and declare its functions. Add following lines to your code:

  
typedef (*SaveBMPToFile)( HBITMAP hBitmap, const char *filename, int filetype);
typedef HBITMAP (*CreateBMPFromFile)( const char *filename);
typedef (*RegisterWSQ)();

SaveBMPToFile  pSaveBMPToFile;
CreateBMPFromFile  pCreateBMPFromFile;
RegisterWSQ pRegisterWSQ;

HINSTANCE hWSQ_library;
hWSQ_library = LoadLibrary("WSQ_library64.dll");

pSaveBMPToFile = (SaveBMPToFile) GetProcAddress(hWSQ_library, "SaveBMPToFile");
pCreateBMPFromFile = (CreateBMPFromFile) GetProcAddress(hWSQ_library, "CreateBMPFromFile");
pRegisterWSQ = (RegisterWSQ) GetProcAddress(hWSQ_library, "RegisterWSQ");

Step 2

Call and use WSQ library functions:

  
hbitmap = (pCreateBMPFromFile)((LPCSTR)dlgFile.GetPathName());
or
(pSaveBMPToFile)(bitmap->GetBitmap(), (LPCSTR)dlgFile.GetPathName(), dlgFile.m_ofn.nFilterIndex);

Step 3

Unload WSQ library. Add following line to your code:

  
bRes = FreeLibrary(hWSQ_library);

To download Microsoft Visual C++ 2008 MFC Application sample project click here



Microsoft Visual C++ .NET

Click here for important notes for .NET developers

Step 1

Load WSQ library and declare its functions. Add following lines to your code:

  
[DllImport("WSQ_library64.dll", EntryPoint = "CreateBMPFromFile", CharSet = Unicode)]
static Int32 CreateBMPFromFile(String* filename);
[DllImport("WSQ_library64.dll", EntryPoint = "SaveBMPToFile", CharSet = Unicode)]
static void SaveBMPToFile(IntPtr hBitmap, String* filename, Int32 filetype);
[DllImport("WSQ_library64.dll", EntryPoint = "RegisterWSQ", CharSet = Unicode)]
static void RegisterWSQ();

Step 2

Call and use WSQ library functions:

  
picture->Image = Image::FromHbitmap(CreateBMPFromFile(ofd->FileName));
or
SaveBMPToFile((new Bitmap(picture->Image))->GetHbitmap(), sfd->FileName, sfd->FilterIndex);

To download Microsoft Visual C++ .NET 2008 Windows Forms Application sample project click here

To download Microsoft Visual C++ .NET 2010 Windows Forms Application sample project click here



Microsoft Visual C# .NET

Click here for important notes for .NET developers

Step 1

Load WSQ library and declare its functions. Add following lines to your code:

  
[DllImport("WSQ_library64.dll")]
public static extern IntPtr CreateBMPFromFile(String lpszFileName);
[DllImport("WSQ_library64.dll")]
public static extern void SaveBMPToFile(IntPtr hBitmap, String filename, Int32 filetype);
[DllImport("WSQ_library64.dll")]
public static extern void RegisterWSQ();

Step 2

Call and use WSQ library functions:

  
bp = CreateBMPFromFile(ofd.FileName);
or
SaveBMPToFile(bp, sfd.FileName, sfd.FilterIndex);

To download Microsoft Visual C# .NET 2008 sample project click here

To download Microsoft Visual C# .NET 2010 Windows Forms App sample project click here

To download Microsoft Visual C# .NET 2013 Windows Forms App sample project click here

To download Microsoft Visual C# .NET 2017 Windows Forms App sample project click here



Microsoft Visual Basic .NET

Click here for important notes for .NET developers

Step 1

Add declarations of WSQ library functions using PInvoke (platform invoke) mechanism :

  
<DllImport("WSQ_library64.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode)> _
Shared Function CreateBMPFromFile(ByVal lpszFileName As String) As IntPtr
End Function
<DllImport("WSQ_library64.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode)> _
Shared Function SaveBMPToFile(ByVal hBitmap As IntPtr, ByVal lpszFileName As String, _
ByVal ifiletype As Short) As Short
End Function
<DllImport("WSQ_library64.dll", CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Unicode)> _
Shared Sub_RegisterWSQ()
End Sub

Step 2

Call and use WSQ library functions:

  
OutputPicture.Image = Bitmap.FromHbitmap(CreateBMPFromFile(OpenFileDialog1.FileName))
or
iResult = SaveBMPToFile((New Bitmap(OutputPicture.Image)).GetHbitmap(), SaveFileDialog1.FileName,
SaveFileDialog1.FilterIndex)

To download Microsoft Visual Basic .NET 2008 sample project click here

To download Microsoft Visual Basic .NET 2010 Windows Forms App sample project click here

To download Microsoft Visual Basic .NET 2013 Windows Forms App sample project click here

To download Microsoft Visual Basic .NET 2017 Windows Forms App sample project click here



Embarcadero C++ Builder

Step 1

Load WSQ library and declare its functions. Add following lines to your code:

  
typedef (*SaveBMPToFile)( HBITMAP hBitmap, const char *filename, int filetype);
typedef HBITMAP (*CreateBMPFromFile)( const char *filename);
typedef (*RegisterWSQ)();

SaveBMPToFile  pSaveBMPToFile;
CreateBMPFromFile  pCreateBMPFromFile;
RegisterWSQ pRegisterWSQ;

HINSTANCE hWSQ_library;
hWSQ_library = LoadLibrary("WSQ_library64.dll");

pSaveBMPToFile = (SaveBMPToFile) GetProcAddress(hWSQ_library, "SaveBMPToFile");
pCreateBMPFromFile = (CreateBMPFromFile) GetProcAddress(hWSQ_library, "CreateBMPFromFile");
pRegisterWSQ = (RegisterWSQ) GetProcAddress(hWSQ_library, "RegisterWSQ");

Step 2

Call and use WSQ library functions:

  
hBitmap = (pCreateBMPFromFile)(AnsiString(open_dialog->FileName).c_str());
or
(pSaveBMPToFile)(OutputImage->Picture->Bitmap->Handle, AnsiString(save_dialog->FileName).c_str(),
save_dialog->FilterIndex);

To download Embarcadero C++ Builder 10 Seattle click here



Sun Java

Click here for important notes for Sun Java developers

Step 1

Add declarations of WSQ library functions using JNIEXPORT wrapper interface:

  
System.loadLibrary("WSQ_library_jniexport");
public static native int[] CreateBMPFromFile(int[] dimension, String fileName);
public static native void SaveBMPToFile(int[] data, int width, int height, String fileName, int type);
public static native void RegisterWSQ();

Step 2

Call and use WSQ library functions:

  
int[] data = WSQ_Demo.CreateBMPFromFile(dimension, fileName)
or
WSQ_Demo.SaveBMPToFile(pixels, width, height, fileName, type)

To download Sun Java (Java SE Development Kit 8u144) sample project click here



MinGW C/C++

Step 1

Load WSQ library and declare its functions. Add following lines to your code:

  
typedef HBITMAP (WINAPI *CreateBMPFromFile)(const char *filename);
typedef void (WINAPI *SaveBMPToFile)(HBITMAP hBitmap, const char *filename, int filetype);
typedef int (WINAPI *RegisterWSQ)();

CreateBMPFromFile CreateBMPFromFile_ptr = 0;
SaveBMPToFile SaveBMPToFile_ptr = 0;
RegisterWSQ RegisterWSQ_ptr = 0;

HINSTANCE g_wsqLibrary = 0;
g_wsqLibrary = LoadLibrary("WSQ_library64.dll");

CreateBMPFromFile_ptr = (CreateBMPFromFile)GetProcAddress(g_wsqLibrary, "CreateBMPFromFile");
SaveBMPToFile_ptr = (SaveBMPToFile)GetProcAddress(g_wsqLibrary, "SaveBMPToFile");
RegisterWSQ_ptr = (RegisterWSQ)GetProcAddress(g_wsqLibrary, "RegisterWSQ");

Step 2

Call and use WSQ library functions:

  
g_hBitmap = CreateBMPFromFile_ptr(szFileName);
or
SaveBMPToFile_ptr(bitmap, szFileName, ofn.nFilterIndex);

Step 3

Unload WSQ library. Add following line to your code:

  
bRes = FreeLibrary(g_wsqLibrary);

To download MinGW C/C++ 4.7.0 sample project click here



Embarcadero Delphi

Step 1

Add declarations of WSQ library functions:

  
function CreateBMPFromFile (const file_name: PCHAR): HBitmap; cdecl; external 'WSQ_library64.dll' 
name 'CreateBMPFromFile';
function SaveBMPToFile( const bitmap : HBITMAP;  const filename : PCHAR; filetype: Integer):Integer;
cdecl; external 'WSQ_library.dll' name 'SaveBMPToFile';
function RegisterWSQ():Integer; cdecl; external 'WSQ_library.dll' name 'RegisterWSQ';

Step 2

Call and use WSQ library functions:

  
OutputImage.Picture.Bitmap.Handle := CreateBMPFromFile( PAnsiChar(AnsiString(open_dialog.FileName)));
or
SaveBMPToFile( OutputImage.Picture.Bitmap.Handle, PAnsiChar(AnsiString(save_dialog.FileName)), 
save_dialog.FilterIndex);

To download Embarcadero Delphi 10 Seattle sample project click here



Lazarus

Step 1

Add declarations of WSQ library functions:

  
function CreateBMPFromFile (const file_name: PCHAR): HBitmap; cdecl; external 'WSQ_library64.dll' 
name 'CreateBMPFromFile';
function SaveBMPToFile( const bitmap : HBITMAP;  const filename : PCHAR; filetype: Integer):Integer;
cdecl; external 'WSQ_library64.dll' name 'SaveBMPToFile';
function RegisterWSQ():Integer; cdecl; external 'WSQ_library64.dll' name 'RegisterWSQ';

Step 2

Call and use WSQ library functions:

  
OutputImage.Picture.Bitmap.Handle := CreateBMPFromFile( PCHAR(open_dialog.FileName));
or
SaveBMPToFile( OutputImage.Picture.Bitmap.Handle, PCHAR(save_dialog.FileName), 
save_dialog.FilterIndex);

To download Lazarus 0.9.30 sample project click here



PHP

Step 1

Click here for important notes for PHP developers

Step 2

Call and use WSQ library functions:

  
//converts image from WSQ format to JPG format
wsq_convert_image("./sample_image.wsq","./output_JPG_image",5);
or
$image1 = wsq_read_image_from_file("./sample_image.wsq");
or
wsq_save_image_to_file($image2, $output_fileName, 5); //save image as JPG

To download PHP 4/5/7 sample project click here



Copyright © 2019 Cognaxon. All rights reserved. Privacy