public void Save(Stream outputStream) { if (_iconData != null) { ArgumentNullException.ThrowIfNull(outputStream); outputStream.Write(_iconData, 0, _iconData.Length); } else { // Ideally, we would pick apart the icon using // GetIconInfo, and then pull the individual bitmaps out, // converting them to DIBS and saving them into the file. // But, in the interest of simplicity, we just call to // OLE to do it for us. PICTDESC pictdesc = PICTDESC.CreateIconPICTDESC(Handle); Guid g = typeof(IPicture).GUID; IPicture picture = OleCreatePictureIndirect(pictdesc, ref g, false); if (picture != null) { try { ArgumentNullException.ThrowIfNull(outputStream); picture.SaveAsFile(new GPStream(outputStream, makeSeekable: false), -1, out int temp); } finally { Debug.Assert(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); Marshal.ReleaseComObject(picture); } } } }
public void Save(Stream outputStream) { if (_iconData != null) { outputStream.Write(_iconData, 0, _iconData.Length); } else { // Ideally, we would pick apart the icon using // GetIconInfo, and then pull the individual bitmaps out, // converting them to DIBS and saving them into the file. // But, in the interest of simplicity, we just call to // OLE to do it for us. PICTDESC pictdesc = PICTDESC.CreateIconPICTDESC(Handle); Guid g = typeof(IPicture).GUID; IPicture picture = OleCreatePictureIndirect(pictdesc, ref g, false); if (picture != null) { try { // We threw this way on NetFX if (outputStream == null) { throw new ArgumentNullException("dataStream"); } picture.SaveAsFile(new GPStream(outputStream, makeSeekable: false), -1, out int temp); } finally { Marshal.ReleaseComObject(picture); } } } }
public void SaveAsFile(IntPtr pstm, bool fSaveMemCopy, out int pcbSize) { Picture.SaveAsFile(pstm, fSaveMemCopy, out pcbSize); }