1个回答
展开全部
mgdecmp库是WINCE 系统提供一个解码BMP,GIF,PNG,JPG的文件的库,这个库的缺陷是不能解出MASK 图片.具体用法如下:
1.把imgdecmp.h加入工程,imgdecmp.h文件内容如下:
/*---------------------------------------------------------------------------*/
*
* (c) Copyright Microsoft Corp. 1997-98 All Rights Reserved
*
* module: imgdecmp.h
* date:
* author: jaym
*
* purpose:
*
/*---------------------------------------------------------------------------*/
#ifndef __IMGDECMP_H__
#define __IMGDECMP_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "imgrendr.h"
typedef void (CALLBACK *PROGRESSFUNC)(IImageRender *pRender, BOOL bComplete, LPARAM lParam);
typedef DWORD (CALLBACK *GETDATAFUNC)(LPSTR szBuffer, DWORD dwBufferMax, LPARAM lParam);
typedef struct tagDecompressImageInfo {
DWORD dwSize; // Size of this structure
LPBYTE pbBuffer; // Pointer to the buffer to use for data
DWORD dwBufferMax; // Size of the buffer
DWORD dwBufferCurrent; // The amount of data which is current in the buffer
HBITMAP * phBM; // Pointer to the bitmap returned (can be NULL)
IImageRender ** ppImageRender; // Pointer to an IImageRender object (can be NULL)
int iBitDepth; // Bit depth of the output image
LPARAM lParam; // User parameter for callback functions
HDC hdc; // HDC to use for retrieving palettes
int iScale; // Scale factor (1 - 100)
int iMaxWidth; // Maximum width of the output image
int iMaxHeight; // Maxumum height of the output image
GETDATAFUNC pfnGetData; // Callback function to get more data
PROGRESSFUNC pfnImageProgress; // Callback function to notify caller of progress decoding the image
COLORREF crTransparentOverride; // If this color is not (UINT)-1, it will override the
// transparent color in the image with this color. (GIF ONLY)
} DecompressImageInfo;
#define IMGDECOMP_E_NOIMAGE 0x800b0100
COLORREF *
GetHalftonePalette();
COLORREF *
Get332Palette();
HRESULT
DecompressImageIndirect(DecompressImageInfo *pParams);
#ifdef __cplusplus
};
#endif // __cplusplus
#endif // !__IMGDECMP_H__
2.按照下面的方法使用.
HDC hdc = CreateCompatibleDC(NULL);
DecompressImageInfo dii;
BYTE szBuffer[1024] = {0};
HANDLE hFile = INVALID_HANDLE_VALUE;
// Fill in the 'DecompressImageInfo' structure
dii.dwSize = sizeof( DecompressImageInfo ); // Size of this structure
dii.pbBuffer = szBuffer; // Pointer to the buffer to use for data
dii.dwBufferMax = 1024; // Size of the buffer
dii.dwBufferCurrent = 0; // The amount of data which is current in the buffer
dii.phBM = &hBitmap; // Pointer to the bitmap returned (can be NULL)
dii.ppImageRender = NULL; // Pointer to an IImageRender object (can be NULL)
dii.iBitDepth = GetDeviceCaps(hdc,BITSPIXEL); // Bit depth of the output image
dii.lParam = ( LPARAM ) &iCeBMPFile;//hFile; // User parameter for callback functions
dii.hdc = hdc; // HDC to use for retrieving palettes
dii.iScale = 100; // Scale factor (1 - 100)
dii.iMaxWidth = 10000; // Maximum width of the output image
dii.iMaxHeight = 10000; // Maxumum height of the output image
dii.pfnGetData = GetImageData; // Callback function to get image data
dii.pfnImageProgress = ImageProgress; // Callback function to notify caller of progress decoding the image
dii.crTransparentOverride = ( UINT ) -1; // If this color is not (UINT)-1, it will override the
// transparent color in the image with this color. (GIF ONLY)
// Process and decompress the image data
typedef HRESULT (CALLBACK* ULPRET)( DecompressImageInfo* pParams );
HINSTANCE hLib;
ULPRET lpfnDLLProc;
hLib = LoadLibrary ( L"Imgdecmp.dll" );
if ( hLib )
{
lpfnDLLProc = (ULPRET) GetProcAddress ( hLib, L"DecompressImageIndirect" );
hr = (*lpfnDLLProc) ( &dii );
FreeLibrary ( hLib );
}
// Clean up
DeleteDC( hdc );
1.把imgdecmp.h加入工程,imgdecmp.h文件内容如下:
/*---------------------------------------------------------------------------*/
*
* (c) Copyright Microsoft Corp. 1997-98 All Rights Reserved
*
* module: imgdecmp.h
* date:
* author: jaym
*
* purpose:
*
/*---------------------------------------------------------------------------*/
#ifndef __IMGDECMP_H__
#define __IMGDECMP_H__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include "imgrendr.h"
typedef void (CALLBACK *PROGRESSFUNC)(IImageRender *pRender, BOOL bComplete, LPARAM lParam);
typedef DWORD (CALLBACK *GETDATAFUNC)(LPSTR szBuffer, DWORD dwBufferMax, LPARAM lParam);
typedef struct tagDecompressImageInfo {
DWORD dwSize; // Size of this structure
LPBYTE pbBuffer; // Pointer to the buffer to use for data
DWORD dwBufferMax; // Size of the buffer
DWORD dwBufferCurrent; // The amount of data which is current in the buffer
HBITMAP * phBM; // Pointer to the bitmap returned (can be NULL)
IImageRender ** ppImageRender; // Pointer to an IImageRender object (can be NULL)
int iBitDepth; // Bit depth of the output image
LPARAM lParam; // User parameter for callback functions
HDC hdc; // HDC to use for retrieving palettes
int iScale; // Scale factor (1 - 100)
int iMaxWidth; // Maximum width of the output image
int iMaxHeight; // Maxumum height of the output image
GETDATAFUNC pfnGetData; // Callback function to get more data
PROGRESSFUNC pfnImageProgress; // Callback function to notify caller of progress decoding the image
COLORREF crTransparentOverride; // If this color is not (UINT)-1, it will override the
// transparent color in the image with this color. (GIF ONLY)
} DecompressImageInfo;
#define IMGDECOMP_E_NOIMAGE 0x800b0100
COLORREF *
GetHalftonePalette();
COLORREF *
Get332Palette();
HRESULT
DecompressImageIndirect(DecompressImageInfo *pParams);
#ifdef __cplusplus
};
#endif // __cplusplus
#endif // !__IMGDECMP_H__
2.按照下面的方法使用.
HDC hdc = CreateCompatibleDC(NULL);
DecompressImageInfo dii;
BYTE szBuffer[1024] = {0};
HANDLE hFile = INVALID_HANDLE_VALUE;
// Fill in the 'DecompressImageInfo' structure
dii.dwSize = sizeof( DecompressImageInfo ); // Size of this structure
dii.pbBuffer = szBuffer; // Pointer to the buffer to use for data
dii.dwBufferMax = 1024; // Size of the buffer
dii.dwBufferCurrent = 0; // The amount of data which is current in the buffer
dii.phBM = &hBitmap; // Pointer to the bitmap returned (can be NULL)
dii.ppImageRender = NULL; // Pointer to an IImageRender object (can be NULL)
dii.iBitDepth = GetDeviceCaps(hdc,BITSPIXEL); // Bit depth of the output image
dii.lParam = ( LPARAM ) &iCeBMPFile;//hFile; // User parameter for callback functions
dii.hdc = hdc; // HDC to use for retrieving palettes
dii.iScale = 100; // Scale factor (1 - 100)
dii.iMaxWidth = 10000; // Maximum width of the output image
dii.iMaxHeight = 10000; // Maxumum height of the output image
dii.pfnGetData = GetImageData; // Callback function to get image data
dii.pfnImageProgress = ImageProgress; // Callback function to notify caller of progress decoding the image
dii.crTransparentOverride = ( UINT ) -1; // If this color is not (UINT)-1, it will override the
// transparent color in the image with this color. (GIF ONLY)
// Process and decompress the image data
typedef HRESULT (CALLBACK* ULPRET)( DecompressImageInfo* pParams );
HINSTANCE hLib;
ULPRET lpfnDLLProc;
hLib = LoadLibrary ( L"Imgdecmp.dll" );
if ( hLib )
{
lpfnDLLProc = (ULPRET) GetProcAddress ( hLib, L"DecompressImageIndirect" );
hr = (*lpfnDLLProc) ( &dii );
FreeLibrary ( hLib );
}
// Clean up
DeleteDC( hdc );
追问
具体如何使用,在程序中将那段代码加入在哪里?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询