为什么gdi+处理过的原图片删不掉?

那朵花 发布于 2013/03/26 10:18
阅读 92
收藏 0
BOOL BMP2JEPG(LPCTSTR srcFileName,LPCTSTR pFileName)
{
	EncoderParameters encoderParameters;
	GdiplusStartupInput gdiplusStartupInput;
	ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

	Image *pImage=new Image(srcFileName);
	
	CLSID jpgClsid;
	GetEncoderClsid(L"image/jpeg", &jpgClsid);
	encoderParameters.Count = 1;
    encoderParameters.Parameter[0].Guid = EncoderQuality;
    encoderParameters.Parameter[0].Type = EncoderParameterValueTypeLong;
    encoderParameters.Parameter[0].NumberOfValues = 1;

	ULONG    quality;
    quality = 75;
    encoderParameters.Parameter[0].Value = &quality;
    Status status = pImage->Save(pFileName, &jpgClsid, &encoderParameters);
	if(status==FALSE)return FALSE;
	GdiplusShutdown(gdiplusToken);
	free(&encoderParameters);
	free(&gdiplusStartupInput);
	free(&gdiplusToken);
	free(&jpgClsid);
	delete [] pImage;
	return TRUE;
 
}
//GDI+实现BMP想jpg的转化
int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)   
{   
    UINT num = 0;                     // number of image encoders   
    UINT size = 0;                   // size of the image encoder array in bytes   
    ImageCodecInfo* pImageCodecInfo = NULL;   
    GetImageEncodersSize(&num, &size);   
    if(size == 0)   
        return -1;     //   Failure   
    
    pImageCodecInfo =  (ImageCodecInfo*)(malloc(size));   
    if(pImageCodecInfo == NULL)   
        return -1;     //   Failure   
    
    GetImageEncoders(num, size, pImageCodecInfo);   
    for(UINT j = 0; j < num; ++j)   
    {   
        if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )   
        {   
            *pClsid = pImageCodecInfo[j].Clsid;   
            free(pImageCodecInfo);   
            return j;     //   Success   
        }           
    }   
    free(pImageCodecInfo);
	free(pClsid);
    return -1;     //   Failure   
}
我想把srcFileName删除却删不掉,求解惑。

以下是问题补充:

@那朵花:删除代码在外部。 (2013/03/26 10:19)
加载中
返回顶部
顶部