public static Image GenerateGifByDegree(Double degree) { string strDegree = Convert.ToInt32((degree % 360 + 360) % 360).ToString(); if (!Directory.Exists(GifPath)) { Directory.CreateDirectory(GifPath); } String outputFilePath = GifPath + "ArrowBack" + strDegree + ".gif"; if (!File.Exists(outputFilePath)) { String[] imageFilePaths = new String[] { JpgPath + "ArrowBack0.JPG", JpgPath + "ArrowBack1.JPG", JpgPath + "ArrowBack2.JPG", JpgPath + "ArrowBack3.JPG" }; AnimatedGifEncoder gifEncoder = new AnimatedGifEncoder(); gifEncoder.Start(outputFilePath); gifEncoder.SetDelay(GifInterval); //-1:no repeat,0:always repeat gifEncoder.SetRepeat(0); for (int i = 0, count = imageFilePaths.Length; i < count; i++) { gifEncoder.AddFrame(DrawUtility.Rotate(Image.FromFile(imageFilePaths[i]), degree)); } gifEncoder.Finish(); } return(Image.FromFile(outputFilePath)); }