⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imgdecompress.cpp

📁 《医学图象的远程传输系统》
💻 CPP
字号:
#include <windows.h>
#include <stdio.h>

#include "ImgDecompress.h"
#include "..\Defines.h"

char g_ErrorMsg[200]="";

BOOL APIENTRY DllMain(HANDLE hModule,DWORD dwReason,LPVOID lpReserved){
	return TRUE;
}

BOOL IDInit(JPEG_CORE_PROPERTIES* pjcprops)
{
	if (ijlInit(pjcprops)!=IJL_OK){
		sprintf(g_ErrorMsg,"ImgDecompress: Init IJL library failed!");
		return FALSE;
	}
	pjcprops->JPGFile=NULL;
	pjcprops->JPGColor=IJL_YCBCR;
	pjcprops->DIBColor=IJL_BGR;
	pjcprops->DIBChannels=3;
	return TRUE;
}

BOOL IDRelease(JPEG_CORE_PROPERTIES* pjcprops)
{
	if (ijlFree(pjcprops)!=IJL_OK){
		sprintf(g_ErrorMsg,"ImgDecompress: Free IJL library failed!");
		return FALSE;
	}
	return TRUE;
}

BOOL IDDecompress(JPEG_CORE_PROPERTIES* pjcprops,BYTE* JpegBuffer,int JpegSize,BYTE** pDib,DWORD* nWidth,DWORD* nHeight)
{
	if (JpegBuffer==NULL || *pDib==NULL){
		sprintf(g_ErrorMsg,"ImgDecompress: Memory myght not allocated!");
		return FALSE;
	}
	pjcprops->JPGBytes=JpegBuffer;
	pjcprops->JPGSizeBytes=JpegSize;
	if (ijlRead(pjcprops,IJL_JBUFF_READPARAMS)!=IJL_OK){
		sprintf(g_ErrorMsg,"ImgDecompress: Error when read compressed image params!");
		return FALSE;
	}
    pjcprops->DIBWidth=pjcprops->JPGWidth;
    pjcprops->DIBHeight=-pjcprops->JPGHeight;
    pjcprops->DIBPadBytes=IJL_DIB_PAD_BYTES(pjcprops->DIBWidth,pjcprops->DIBChannels);
    pjcprops->DIBBytes=*pDib;
    if (ijlRead(pjcprops,IJL_JBUFF_READWHOLEIMAGE)!=IJL_OK){
		sprintf(g_ErrorMsg,"ImgDecompress: Error when read compressed image!");
        return FALSE;
    }
    *nWidth=pjcprops->JPGWidth;
    *nHeight=pjcprops->JPGHeight;
    return TRUE;
}

LPCTSTR IDGetLastError(){
	return g_ErrorMsg;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -