static ResourceElement CreateSerializedImage(Stream stream, string filename) { object obj; string typeName; if (filename.EndsWith(".ico", StringComparison.OrdinalIgnoreCase)) { obj = new System.Drawing.Icon(stream); typeName = SerializedImageUtilities.SystemDrawingIcon.AssemblyQualifiedName; } else { obj = new System.Drawing.Bitmap(stream); typeName = SerializedImageUtilities.SystemDrawingBitmap.AssemblyQualifiedName; } var serializedData = Serialize(obj); var userType = new UserResourceType(typeName, ResourceTypeCode.UserTypes); var rsrcElem = new ResourceElement { Name = Path.GetFileName(filename), ResourceData = new BinaryResourceData(userType, serializedData), }; return(rsrcElem); }
/// <summary> /// Constructor /// </summary> /// <param name="type">User resource type</param> /// <param name="data">Raw serialized data</param> public BinaryResourceData(UserResourceType type, byte[] data) : base(type) => this.data = data;
public ImageResourceData(UserResourceType type, byte[] data) : base(type) => bitmap = new Bitmap(Image.FromStream(new MemoryStream(data)));
public IconResourceData(UserResourceType type, byte[] data) : base(type) => icon = new Icon(new MemoryStream(data));
public CharArrayResourceData(UserResourceType type, char[] data) : base(type) => this.data = data;