19,473
社区成员




void CXXXXXView::OnLayersExport()
{
int iCount = m_ctrlMapX.GetLayers().GetCount();
int i;
for(i=2;i<=iCount;i++)
{
m_ctrlMapX.GetLayers().Item(i).SetVisible(FALSE);
}
double dWidth;
double dHeight;
CRect rect;
m_ctrlMapX.GetClientRect(&rect);
dWidth = rect.Width()/96;
dHeight = rect.Height()/96;
m_ctrlMapX.ExportMap(_T("C:\\abc.png"),miFormatPNG,dWidth,dHeight); //默认路径1
CImage tempCImage;
tempCImage.Create(rect.Width(),rect.Height(),32);
tempCImage.SetHasAlphaChannel(TRUE);
tempCImage.Save(_T("C:\\abcd.png")); //保存路径1
Image img(L"C:\\abcd.png");//保存路径1
Image iSourceImage(L"C:\\abc.png");//默认路径1
Graphics graphics(&img);
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);
ImageAttributes imageAttr;
imageAttr.SetColorKey(Gdiplus::Color(255,255,255),Gdiplus::Color(255,255,255),Gdiplus::ColorAdjustTypeDefault);//透明像素开始-结束
graphics.DrawImage(&iSourceImage,Gdiplus::Rect(8,0,rect.Width(),rect.Height()),0,0,rect.Width(),rect.Height(),UnitPixel,&imageAttr);
CLSID pngClsid;
GetEncoderClsidOwn(L"image/png",&pngClsid);
img.Save(L"C:\\1111.png",&pngClsid,NULL);
}