推荐于2016-11-02
展开全部
Image* FixedSize(Image *imgSrc, int Width, int Height)
{
int w,h;
w = imgSrc->GetWidth ();
h = imgSrc->GetHeight ();
if (w<h) //图片是竖着的 交换Width和Height
{
Width = Width + Height;
Height = Width - Height;
Width = Width - Height;
}
Bitmap *bmPhoto = new Bitmap(Width, Height);
bmPhoto->SetResolution(imgSrc->GetHorizontalResolution(),imgSrc->GetVerticalResolution());
Graphics grPhoto(bmPhoto);
grPhoto.Clear((ARGB)Color::White);
grPhoto.SetInterpolationMode(InterpolationModeHighQualityBicubic);
grPhoto.DrawImage(imgSrc,0,0,Width,Height);
return bmPhoto;
}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);
return -1; // Failure
}
{
int w,h;
w = imgSrc->GetWidth ();
h = imgSrc->GetHeight ();
if (w<h) //图片是竖着的 交换Width和Height
{
Width = Width + Height;
Height = Width - Height;
Width = Width - Height;
}
Bitmap *bmPhoto = new Bitmap(Width, Height);
bmPhoto->SetResolution(imgSrc->GetHorizontalResolution(),imgSrc->GetVerticalResolution());
Graphics grPhoto(bmPhoto);
grPhoto.Clear((ARGB)Color::White);
grPhoto.SetInterpolationMode(InterpolationModeHighQualityBicubic);
grPhoto.DrawImage(imgSrc,0,0,Width,Height);
return bmPhoto;
}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);
return -1; // Failure
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-05-14
展开全部
VC6可以使用GDI+的,但是要用VC6自己的GDI+ 的头和库而且第一句还需要
#include <windows.h> 因为GDI实际上用到了大量的Windows的API的图像函数
#include <windows.h> 因为GDI实际上用到了大量的Windows的API的图像函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询