public static Image Summary2Image(Image big, Image small, iconAlign ImageAligment) { Image ret=(Image)big.Clone(); Graphics g=Graphics.FromImage(ret); //делаем копию в четверть !! int srcX=0,srcY=0; Image small2=null; //если они равны - создаем X/2 и Y/2 if (big.Size==small.Size) small2=CreateThumbnail(big.Width/2,big.Height/2,small); else //иначе - эта картинка уже маленька¤ !! (например ShortCut) small2=small; Size sz=small2.Size; Rectangle rect=new Rectangle(new Point(0,0),sz); switch(ImageAligment) { case iconAlign.Center: srcX=small2.Width/2; srcY=srcX; break; case iconAlign.leftTop: srcX=0; srcY=0; break; case iconAlign.leftButtom: srcX=0; srcY=small2.Width/2; break; case iconAlign.RightTop: srcX=0; srcY=small2.Width; break; case iconAlign.RightButtom: srcX=small2.Width; srcY=small2.Width; break; } rect.Location=new Point(srcX,srcX); g.DrawImage(small2,rect); g.Dispose(); return ret; }
//static public Image Summary2Image(Image big, Image small, iconAlign ImageAligment) //{ // return Summary2Image(big, small, ImageAligment, 2/3, 2/3); //} //static public Image Summary2Image(Image big, Image small, iconAlign ImageAligment, float aW, float aH) public static Image Summary2Image(Image big, Image small, iconAlign ImageAligment) { Image ret=big.Clone() as Image; Graphics g=Graphics.FromImage(ret); /* делаем абалденное качество ! */ g.CompositingQuality=CompositingQuality.HighQuality; g.InterpolationMode=InterpolationMode.HighQualityBilinear; g.SmoothingMode=SmoothingMode.AntiAlias; //делаем копию в четверть !! int srcX=0,srcY=0; Image small2=null; //если они равны - создаем X/2 и Y/2 if (big.Size==small.Size) //small2=CreateThumbnail((int)(big.Width*aW),(int)(big.Height*aH),small); small2=CreateThumbnail(big.Width*3/4,big.Height*3/4,small); else //иначе - эта картинка уже маленькая !! (например ShortCut) small2=small; Size sz=small2.Size; Rectangle rect=new Rectangle(new Point(0,0),sz); switch(ImageAligment) { case iconAlign.Center: srcX=ret.Width/2 - small2.Width/2; srcY=srcX; break; case iconAlign.leftTop: srcX=0; srcY=0; break; case iconAlign.leftButtom: srcX=0; srcY=ret.Height - small2.Height; break; case iconAlign.RightTop: srcX=ret.Width- small2.Width; srcY=0; break; case iconAlign.RightButtom: srcX=ret.Width - small2.Width; srcY=srcX; break; } rect.Location=new Point(srcX,srcY); g.DrawImage(small2,rect); g.Dispose(); return ret; }