public void GifAnimAdd(Stream sout, int localCm, int leftOfs, int topOfs, int delay, Disposal disposal, GD previm) { int size; IntPtr prevhandle = previm == null ? IntPtr.Zero : previm.handle.Handle; using (GDIntPtr rawdata = GDImport.gdImageGifAnimAddPtr(this.Handle, out size, localCm, leftOfs, topOfs, delay, (int)disposal, prevhandle)) { if (rawdata.IsNull) { throw new ApplicationException("Function GifAnimAdd failed"); } byte[] data = new byte[size]; Marshal.Copy(rawdata, data, 0, size); sout.Write(data, 0, size); } }