Provides additional options for the LEAD Jbig2 Bitmap Encoder.
LEAD Jbig2 Encoder Options
Property Name VARTYPE Default Value Applicable LEAD Encoders Description Jb2_ImageFlags VT_UI4 WICLeadJb2ImageFlagsNone Jbig2 See WICLeadJb2ImageFlags Jb2_ImageTemplateType VT_UI1 3 Jbig2 Value that indicates which template-based arithmetic encoder to use when encoding a non-text area. Possible values are:
0: Three lines with a 16-pixel template.
1: Three lines with a 13-pixel template.
2: Three lines with a 10-pixel template.
3: Two lines with a 10-pixel template.Jb2_ImageGBATX1 VT_I1 -1 Jbig2 The X location of the adaptive template pixel A1 for a non-text area encoding. Possible values range from -128 to 127 except when the value of the member Jb2_ImageGBATY1 is zero, in which case it ranges from -128 to -1
Jb2_ImageGBATY1 VT_I1 -3 Jbig2 The Y location of the adaptive template pixel A1 for a non-text area encoding. Possible values range from -128 to 0.
Jb2_ImageGBATX2 VT_I1 -1 Jbig2 The X location of the adaptive template pixel A2 for a non-text area encoding. Possible values range from -128 to 127, except when the value of the member Jb2_ImageGBATY2 is zero, in which case it ranges from -128 to -1.
Jb2_ImageGBATY2 VT_I1 0 Jbig2 The Y location of the adaptive template pixel A2 for a non-text area encoding. Possible values range from -128 to 0.
Jb2_ImageGBATX3 VT_I1 -2 Jbig2 The X location of the adaptive template pixel A3 for a non-text area encoding. Possible values range from -128 to 127, except when the values of the member Jb2_ImageGBATY3 is zero, in which case it ranges from -128 to -1.
Jb2_ImageGBATY3 VT_I1 -2 Jbig2 The Y location of the adaptive template pixel A3 for a non-text area encoding. Possible values range from -128 to 0.
Jb2_ImageGBATX4 VT_I1 -2 Jbig2 The X location of the adaptive template pixel A4 for a non-text area encoding. Possible values range from -128 to 127, except when the value of the member Jb2_ImageGBATY4 is zero, in which case it ranges from -128 to -1.
Jb2_ImageGBATY4 VT_I1 0 Jbig2 The Y location of the adaptive template pixel A4 for a non-text area encoding. Possible values range from -128 to 0.
Jb2_ImageQFactor VT_UI4 0 Jbig2 Value that represents the degree of loss in the compression process for a non-text area. The value of 0 means lossless while any other value means lossy. 0 is the default value. Valid values range from 0 - 50.
Jb2_TextFlags VT_UI4 WICLeadJb2TextFlagKeepAllSymbols Jbig2 See WICLeadJb2TextFlags Jb2_TextTemplateType VT_UI1 0 Jbig2 Value that indicates which template-based arithmetic encoder to use when encoding a text area. Possible values are:
0: Three lines with a 16-pixel template.
1: Three lines with a 13-pixel template.
2: Three lines with a 10-pixel template.
3: Two lines with a 10-pixel template.Jb2_TextGBATX1 VT_I1 3 Jbig2 The X location of the adaptive template pixel A1 for a text area encoding. Possible values range from -128 to 127 except when the value of the member TextGBATY1 is zero, in which case it ranges from 128 to 1
Jb2_TextGBATY1 VT_I1 -1 Jbig2 The Y location of the adaptive template pixel A1 for a text area encoding. Possible values range from -128 to 0.
Jb2_TextGBATX2 VT_I1 -3 Jbig2 The X location of the adaptive template pixel A2 for a text area encoding. Possible values range from -128 to 127, except when the value of the member TextGBATY2 is zero, in which case it ranges from 128 to 1.
Jb2_TextGBATY2 VT_I1 -1 Jbig2 The Y location of the adaptive template pixel A2 for a text area encoding. Possible values range from -128 to 0.
Jb2_TextGBATX3 VT_I1 2 Jbig2 The X location of the adaptive template pixel A3 for a text area encoding. Possible values range from -128 to 127 except when the value of the member TextGBATY3 is zero, in which case it ranges from 128 to -1.
Jb2_TextGBATY3 VT_I1 -2 Jbig2 The Y location of the adaptive template pixel A3 for a text area encoding. Possible values range from -128 to 0.
Jb2_TextGBATX4 VT_I1 -2 Jbig2 The X location of the adaptive template pixel A4 for a text area encoding. Possible values range from -128 to 127 except when the value of the member TextGBATY4 is zero, in which case it ranges from 128 to -1.
Jb2_TextGBATY4 VT_I1 -2 Jbig2 The Y location of the adaptive template pixel A4 for a text area encoding. Possible values range from -128 to 0.
Jb2_TextMinSymArea VT_UI4 50 Jbig2 Minimum text symbol area, in pixels. Jb2_TextMinSymWidth VT_UI4 1 Jbig2 Minimum text symbol width, in pixels. Jb2_TextMinSymHeight VT_UI4 1 Jbig2 Minimum text symbol height, in pixels. Jb2_TextMaxSymArea VT_UI4 2000 Jbig2 Maximum text symbol area, in pixels. Jb2_TextMaxSymWidth VT_UI4 200 Jbig2 Maximum text symbol width, in pixels. Jb2_TextMaxSymHeight VT_UI4 200 Jbig2 Maximum text symbol height, in pixels. Jb2_TextDifThreshold VT_UI4 30 Jbig2 Maximum difference allowed mapping a text symbol to a dictionary symbol, in percent. Jb2_TextQFactor VT_UI4 0 Jbig2 Degree of the loss in the compression process for a text area. The value of 0 means lossless while any other value means lossy. 0 is the default value. Valid values range from 0 - 50. Jb2_XResolution VT_UI4 150 Jbig2 Horizontal resolution to be used, in dots per inch. Jb2_YResolution VT_UI4 150 Jbig2 Vertical resolution to be used, in dots per inch. Jb2_Flags VT_UI4 WICLeadJb2FlagEnableDictionary Jbig2 See WICLeadJb2Flags
Reference
LEAD WIC-Enabled Codecs Overview
Registering a LEAD WIC-Enabled Codec
LEAD Bitmap Encoder Property Bag
LEAD Bitmap Encoder Property Bag: Jpeg2000 Specific Options
LEAD Bitmap Encoder Property Bag: XPS Specific Options
// This example shows how to save a JBIG2 file with options using the property bag // Then the file is saved with the following options: // * Jb2_ImageFlags: WICLeadJb2ImageFlagsUseTypicalPrediction // * Jb2_TextFlags: WICLeadJb2TextFlagRemoveUnrepeatedSymbols // * Jb2_Flags: WICLeadJb2FlagRemoveMarker // Refer to the Example Requirements for help in running this sample HRESULT IWICLeadBitmapEncoder_PropertyBag_Jb2(HWND hWnd, WCHAR *pszOut) { HRESULT hr = S_OK; IWICImagingFactory *piImagingFactory = NULL; IWICBitmapEncoder *piBitmapEncoder = NULL; IWICBitmapFrameEncode *piBitmapFrameEncode = NULL; IWICStream *piStream = NULL; IPropertyBag2 *piPropertyBag = NULL; CString csExampleName; GUID guidContainerFormat = GUID_ContainerFormatLeadJbig2; WICPixelFormatGUID guidPixelFormat = GUID_WICPixelFormat24bppBGR; csExampleName.Format(L"IWICLeadBitmapEncoder_PropertyBag_Jb2\nThis example creates a Jpeg2000 file (%s) with Jb2_ImageFlags: WICLeadJb2ImageFlagsUseTypicalPrediction, Jb2_TextFlags: WICLeadJb2TextFlagRemoveUnrepeatedSymbols, Jb2_Flags: WICLeadJb2FlagRemoveMarker", pszOut); // Create a LEAD Jpeg Bitmap Encoder IFS(CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*) &piImagingFactory)); IFS(piImagingFactory->CreateStream(&piStream)); IFS(piStream->InitializeFromFilename(pszOut, GENERIC_WRITE)); IFS(piImagingFactory->CreateEncoder(guidContainerFormat, NULL, &piBitmapEncoder)); IFS(piBitmapEncoder->Initialize(piStream, WICBitmapEncoderNoCache)); IFS(piBitmapEncoder->CreateNewFrame(&piBitmapFrameEncode, &piPropertyBag)); // This is how you customize the a LEAD WIC Encoder property bag. if(SUCCEEDED(hr)) { ULONG uCount = 0; hr = piPropertyBag->CountProperties(&uCount); PROPBAG2 *pBag = new PROPBAG2[uCount]; ZeroMemory(pBag, sizeof(*pBag)); VARIANT *pValue = new VARIANT[uCount]; ZeroMemory(pValue, sizeof(*pValue)); HRESULT *pErrors = new HRESULT[uCount]; ZeroMemory(pErrors, sizeof(*pErrors)); IFS(piPropertyBag->GetPropertyInfo(0, uCount, pBag, &uCount)); IFS(piPropertyBag->Read(uCount, pBag, NULL, pValue, pErrors)); if (SUCCEEDED(hr)) { for (ULONG u = 0; u < uCount; u++) { if (wcscmp(pBag[u].pstrName, L"Jb2_ImageFlags")== 0) { pValue[u].uintVal = WICLeadJb2ImageFlagsUseTypicalPrediction; piPropertyBag->Write(1, pBag+u, pValue+u); } else if (wcscmp(pBag[u].pstrName, L"Jb2_TextFlags")== 0) { pValue[u].uintVal = WICLeadJb2TextFlagRemoveUnrepeatedSymbols; piPropertyBag->Write(1, pBag+u, pValue+u); } else if (wcscmp(pBag[u].pstrName, L"Jb2_Flags")== 0) { pValue[u].uintVal = WICLeadJb2FlagRemoveMarker; piPropertyBag->Write(1, pBag+u, pValue+u); } } } //Cleanup DELETE_POINTER(pBag); DELETE_POINTER(pValue); DELETE_POINTER(pErrors); IFS(piBitmapFrameEncode->Initialize(piPropertyBag)); } // Now create the image data that we will write UINT uiWidth = 256; UINT uiHeight = 256; IFS(piBitmapFrameEncode->SetSize(uiWidth, uiHeight)); WICPixelFormatGUID formatGUID = GUID_WICPixelFormatBlackWhite; IFS(piBitmapFrameEncode->SetPixelFormat(&formatGUID)); if (SUCCEEDED(hr)) { // We're expecting to write out 1-bit data. Fail if the encoder cannot do it. hr = IsEqualGUID(formatGUID, GUID_WICPixelFormatBlackWhite) ? S_OK : E_FAIL; } if (SUCCEEDED(hr)) { UINT cbStride = (uiWidth * 1 + 7)/8; UINT cbBufferSize = uiHeight * cbStride; BYTE *pbBuffer = new BYTE[cbBufferSize]; if (pbBuffer != NULL) { for (UINT i = 0; i < cbBufferSize; i++) { pbBuffer[i] = static_cast<BYTE>(rand()); } hr = piBitmapFrameEncode->WritePixels(uiHeight, cbStride, cbBufferSize, pbBuffer); delete[] pbBuffer; } else { hr = E_OUTOFMEMORY; } } // Commit the changes to the stream IFS(piBitmapFrameEncode->Commit()); IFS(piBitmapEncoder->Commit()); RELEASE_INTERFACE(piBitmapFrameEncode); RELEASE_INTERFACE(piBitmapEncoder); RELEASE_INTERFACE(piImagingFactory); RELEASE_INTERFACE(piPropertyBag); RELEASE_INTERFACE(piStream); MessageBox(hWnd, csExampleName, csExampleName, MB_OK); return hr; }
The Jb2_ImageTemplateType is a value that indicates which template-based arithmetic encoder to use when encoding a non-text area. Possible values are:
0
Three lines with a 16-pixel template.
1
Three lines with a 13-pixel template.
2
Three lines with a 10-pixel template.
3
Two lines with a 10-pixel template.
The Jb2_TextTemplateType is a Value that indicates which template-based arithmetic encoder to use when encoding a text area. Possible values are:
0
Three lines with a 16-pixel template.
1
Three lines with a 13-pixel template.
2
Three lines with a 10-pixel template.
3
Two lines with a 10-pixel template.