private int Mode; //替换模式 0为替换贴图 1为替换gif 2为替换文件夹 public void Do(params object[] args) { Type = (ColorBits)args[0]; isAdjust = (bool)args[1]; Mode = (int)args[2]; Path = args[3] as string; Album = args[4] as Album; Indices = args[5] as int[]; switch (Mode) { case 0: if (Album.List.Count > 0) { var image = Album[Indices[0]]; oldImages = new Bitmap[] { image.Picture }; types = new ColorBits[] { image.Type }; image.ReplaceImage(Type, isAdjust, Image.FromFile(Path) as Bitmap); } break; case 1: var gifentry = Bitmaps.ReadGif(Path); oldImages = new Bitmap[Indices.Length]; types = new ColorBits[Indices.Length]; for (int i = 0; i < Indices.Length && i < gifentry.Length; i++) { if (Indices[i] > Album.List.Count - 1 && Indices[i] < 0) { continue; } var image = Album[Indices[i]]; oldImages[i] = image.Picture; types[i] = image.Type; image.ReplaceImage(Type, isAdjust, gifentry[i]); } break; case 2: var images = GetImages(Album, Indices.Length); oldImages = new Bitmap[Indices.Length]; types = new ColorBits[Indices.Length]; for (var i = 0; i < Indices.Length && i < images.Length; i++) { if (Indices[i] > Album.List.Count - 1 || Indices[i] < 0) { continue; } var image = Album[Indices[i]]; oldImages[i] = image.Picture; types[i] = image.Type; image.ReplaceImage(Type, isAdjust, images[i]); } break; default: break; } Album.Adjust(); Album.Refresh(); }
public List <Album> Decode(string filename) { var fs = File.Open(filename, FileMode.Open); var array = Bitmaps.ReadGif(fs); fs.Close(); var album = new Album(array); album.Path = filename.GetSuffix(); return(new List <Album> { album }); }
public void Action(Album album, int[] indexes) { var path = Path; switch (Mode) { case 0: if (album.List.Count > 0) { album[indexes[0]].ReplaceImage(Type, IsAdjust, Image.FromFile(path) as Bitmap); } break; case 1: var gifentry = Bitmaps.ReadGif(path); for (var i = 0; i < indexes.Length && i < gifentry.Length; i++) { if (indexes[i] > album.List.Count - 1 && indexes[i] < 0) { continue; } album[indexes[i]].ReplaceImage(Type, IsAdjust, gifentry[i]); } break; case 2: var images = GetImages(album, indexes.Length); for (var i = 0; i < indexes.Length && i < images.Length; i++) { if (indexes[i] > album.List.Count - 1 || indexes[i] < 0) { continue; } album[indexes[i]].ReplaceImage(Type, IsAdjust, images[i]); } break; default: break; } }