DecodeABIC example for Visual C++
void CDemo::OnDecodeABIC()
{
int nFileSize, nRet;
CString strFileName;
unsigned char *pData = NULL;
int i;
unsigned char *pBmpData = NULL;
BITMAPINFO *pBmpInfo = NULL;
BITMAPFILEHEADER BmpFileHeader;
memset(&BmpFileHeader, 0, sizeof(BmpFileHeader));
ILEADRasterIO * pRasterIO = NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
ILEADRasterVariant * pInputData = NULL;
CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, IID_ILEADRasterVariant, (void**)&pInputData);
ILEADRasterVariant * pOutputData = NULL;
CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, IID_ILEADRasterVariant, (void**)&pOutputData);
m_RasterView.GetRaster().UnlockSupport(L_SUPPORT_ABIC_READ, L_KEY_ABIC_READ);
pBmpInfo = (BITMAPINFO *)malloc(sizeof(*pBmpInfo) + 16 * sizeof(RGBQUAD));
memset(pBmpInfo, 0, sizeof(*pBmpInfo) + 16 * sizeof(RGBQUAD));
strFileName = "c:\\Image2Raw.ica";
CFile File(strFileName, CFile::modeRead);
nFileSize = File.GetLength();
pData = (unsigned char *)malloc(nFileSize);
File.Read(pData, nFileSize);
File.Close();
pInputData->vType = VALUE_ARRAY_BYTE;
pInputData->ItemCount = nFileSize;
for (i = 0; i< nFileSize; ++i)
{
pInputData->PutShortItemValue(i, pData[i]);
}
nRet = pRasterIO->DecodeABIC(pInputData, &pOutputData, 4, 472, 221, FALSE);
if(nRet == 0)
{
pBmpInfo->bmiHeader.biSize = sizeof(pBmpInfo->bmiHeader);
pBmpInfo->bmiHeader.biWidth = 472;
pBmpInfo->bmiHeader.biHeight = 221;
pBmpInfo->bmiHeader.biBitCount = 4;
BmpFileHeader.bfType = 'B' | ('M' << 8);
BmpFileHeader.bfSize = sizeof(*pBmpInfo) + 16 * sizeof(RGBQUAD) + sizeof(BmpFileHeader) + pOutputData->ItemCount;
BmpFileHeader.bfReserved1 = 0;
BmpFileHeader.bfReserved2 = 0;
BmpFileHeader.bfOffBits = sizeof(*pBmpInfo) + 16 * sizeof(RGBQUAD) + sizeof(BmpFileHeader);
for (i = 0; i < 16; ++i)
{
pBmpInfo->bmiColors[i].rgbBlue = 0x11 * i;
pBmpInfo->bmiColors[i].rgbRed = 0x11 * i;
pBmpInfo->bmiColors[i].rgbGreen = 0x11 * i;
pBmpInfo->bmiColors[i].rgbReserved = 0;
}
CFile OutputFile(TEXT("c:\\Abic.bmp"), CFile::modeWrite | CFile::modeCreate);
OutputFile.Write(&BmpFileHeader, sizeof(BmpFileHeader));
OutputFile.Write(pBmpInfo, sizeof(*pBmpInfo) + 16 * sizeof(RGBQUAD));
for(i = 0; i < pOutputData->ItemCount; ++i)
{
unsigned char Byte = (unsigned char) pOutputData->GetShortItemValue(i);
OutputFile.Write(&Byte, 1);
}
OutputFile.Close();
}
pRasterIO->Release();
pInputData->Release();
pOutputData->Release();
}