medata 데이터 wpf c #을 사용하여 비트 맵을 png로 저장 [중복]

Dec 30 2020

wpf c #의 저작권과 같은 medata를 사용하여 비트 맵을 jpg로 저장해야합니다.

         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");

이미 위의 코드를 사용해 보았지만 인덱스가 arrayarea를 벗어났다고합니다.

답변

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);

0x503B 값은 여기에서 가져옵니다. PropertyItem.Id Property