Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#20

AW: Memorystream vs TMemoryStream

  Alt 17. Apr 2015, 15:49
Wenn ich das richtig verstanden habe sollte das korrekt sein.
Aber es kracht immer noch.

Code:
byte[] Data = new byte[BitmapStream.Length];
BitmapStream.Read(Data, 0, (int)BitmapStream.Length);

GCHandle DataHandle = GCHandle.Alloc(Data, GCHandleType.Pinned);
IntPtr address = DataHandle.AddrOfPinnedObject();

CoverArtData.Name = Description;
CoverArtData.CoverType = 3;
CoverArtData.MIMEType = MIMEType;
CoverArtData.Description = Description;
CoverArtData.Width = Width;
CoverArtData.Height = Height;
CoverArtData.ColorDepth = ColorDepth;
CoverArtData.NoOfColors = NoOfColors;
CoverArtData.PictureFormat = CoverArtPictureFormat;
CoverArtData.Data = address;
CoverArtData.DataSize = BitmapStream.Length;



if (TagsLib.TagsLibrary_AddCoverArt(Tags, TTagType.ttAutomatic, CoverArtData) != 0)
{
  MessageBox.Show("Error while adding cover art: ", OpenFileDialog1.FileName, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
}
DataHandle.Free();
Muss ich die struct selbst jetzt auch noch pinnen ?

Code:
GCHandle structHandle = GCHandle.Alloc(CoverArtData, GCHandleType.Pinned);
structHandle.Free()
gruss

Geändert von EWeiss (17. Apr 2015 um 16:12 Uhr)
  Mit Zitat antworten Zitat