public void Rotate(List <ImageItem> list, RotateDegree degree) { RotateFlipType type; switch (degree) { case RotateDegree.D90: type = RotateFlipType.Rotate90FlipNone; break; case RotateDegree.D180: type = RotateFlipType.Rotate180FlipNone; break; case RotateDegree.D270: type = RotateFlipType.Rotate270FlipNone; break; default: type = RotateFlipType.Rotate90FlipNone; break; } foreach (var item in list) { var image = new Bitmap(item.Name); image.RotateFlip(type); image.Save(item.NewName, image.RawFormat); } }
public void Shift(float n, int ymax, int xmax, int BGx, int BGy, RotateDegree btnsrotate, bool btnsflip) { tembox = (Int32[])box.Clone(); if (btnsflip) { tembox[0] = xmax - box[2]; tembox[2] = xmax - box[0]; } switch ((Int32)btnsrotate) { case 0: break; case 1: tembox[0] = box[1]; tembox[1] = ymax - box[2]; tembox[2] = box[3]; tembox[3] = ymax - box[0]; break; case 2: tembox[0] = xmax - box[2]; tembox[1] = ymax - box[3]; tembox[2] = xmax - box[0]; tembox[3] = ymax - box[1]; break; case 3: tembox[0] = xmax - box[3]; tembox[1] = box[0]; tembox[2] = xmax - box[1]; tembox[3] = box[2]; break; } Location = new System.Drawing.Point((int)Math.Ceiling(tembox[0] * n + BGx), (int)Math.Ceiling((ymax - tembox[3]) * n) + BGy);//BGxy为使btns在BG上定位,因为BG不是父对象 //Location = new System.Drawing.Point((int)(box[0] * n+BGx), (int)(ymax - box[3] * n)+BGy); //Console.WriteLine("X坐标为:"+Location.X + "---Y坐标为:" + Location.Y); Size = new System.Drawing.Size( (int)Math.Ceiling((tembox[2] - tembox[0]) * n), (int)Math.Ceiling((tembox[3] - tembox[1]) * n)); //location和size都向上取整防止产生空隙 }