{ //临时图像 Bitmap * lpImage = Bitmap::FromFile(_T("E://work//src//MiniVideo//final//Skin//setting_btn2.png")); Bitmap * lpImage_real = Bitmap::FromFile(_T("E://work//src//MiniVideo//final//Skin//setting_btn.png")); Graphics * lpGraphics = Graphics::FromImage(lpImage); ColorMatrix lColrMatrix = { 1,0,0,0,0, 0,1,0,0,0, 0,0,1,0,0, 0,0,0,1,0, 0,0.6,0,0,1 }; //保存真实图像经过Matrix处理后的图像 ImageAttributes lAttr; lAttr.SetColorMatrix(&lColrMatrix); lpGraphics->DrawImage(lpImage_real, Rect(0, 0, lpImage_real->GetWidth(), lpImage_real->GetHeight()), 0, 0, lpImage_real->GetWidth(), lpImage_real->GetHeight(), UnitPixel, &lAttr); //由于临时 lpImage 对象比较大, 对齐进行裁剪, 裁剪后的对象是 bmPhoto Bitmap * bmPhoto = new Bitmap(lpImage_real->GetWidth(), lpImage_real->GetHeight()); Graphics grPhoto(bmPhoto); grPhoto.Clear(Color(0, 0,0,0)); //用透明色初始化 grPhoto.SetInterpolationMode(InterpolationModeHighQualityBicubic); grPhoto.DrawImage(lpImage, Rect(0,0,bmPhoto->GetWidth(), bmPhoto->GetHeight()), 0,0,bmPhoto->GetWidth(), bmPhoto->GetHeight(), UnitPixel); delete lpImage; //删除无用文件 //测试裁剪后的对象, 输出到屏幕上 CWindowDC ldc(NULL); Graphics lgraphics(ldc); lgraphics.DrawImage(bmPhoto, Rect(0, 0, bmPhoto->GetWidth(), bmPhoto->GetHeight()), 0, 0, bmPhoto->GetWidth(), bmPhoto->GetHeight(), UnitPixel/*, &lAttr*/); delete lpImage_real; delete bmPhoto; }