Salva bitmap in png con dati medata wpf c # [duplicato]
Dec 30 2020
Ho bisogno di salvare una bitmap in jpg con medata come il copyright in wpf c #.
var handle = BitmapImage2Bitmap(currentimage).GetHbitmap();
System.Drawing.Image img = System.Drawing.Image.FromHbitmap(handle);
System.Drawing.Imaging.PropertyItem prop = img.PropertyItems[0];
SetProperty(ref prop, 33432, "Copyright");
img.SetPropertyItem(prop);
img.Save(@"C:\images\test.jpg");
Ho già provato a utilizzare il codice sopra ma dice che l'indice era fuori dall'arrayarea.
Risposte
Charlieface Dec 30 2020 at 09:52
var prop = img.GetPropertyItem(0x503B);
prop.Value = Encoding.Ascii.GetBytes("copyright name");
prop.Len = prop.Value.Length;
img.SetPropertyItem(prop);
Il valore 0x503B proviene da qui: PropertyItem.Id Property