private void RefreshAdapter() { IPictureDecoder decoder = document.CurrentResource.Format.Decoder as IPictureDecoder; if (decoder == null) { document.CurrentResource.Format.Code = "Direct"; decoder = document.CurrentResource.Format.Decoder as IPictureDecoder; } if (picture != null) { picture.Changed -= new EventHandler(Format_Changed); } var old = picture; picture = new PictureAdapter(decoder); picture.Data = document.Data; picture.PicOffset = document.CurrentResource.Offset; if (old != null) { picture.Zoom = old.Zoom; } if (decoder is INeedsPalette) { ((INeedsPalette)decoder).Palette = palette; } picture.Changed += new EventHandler(Format_Changed); Format_Changed(picture, EventArgs.Empty); }
public void SetDecoder(Type decoderType) { if (picture != null && decoderType.IsInstanceOfType(picture.Decoder)) return; IPictureDecoder decoder = (IPictureDecoder)Activator.CreateInstance(decoderType); if (picture != null) { picture.Changed -= new EventHandler(Format_Changed); } var old = picture; picture = new PictureAdapter(decoder); if (old != null) { picture.Data = old.Data; picture.PicOffset = old.PicOffset; picture.Width = old.Width; picture.Height = old.Height; picture.ColorBPP = old.ColorBPP; picture.Zoom = old.Zoom; }; if (decoder is INeedsPalette) { ((INeedsPalette)decoder).Palette = palette; } picture.Changed += new EventHandler(Format_Changed); Format_Changed(picture, EventArgs.Empty); }