Is there a way to convert a Xojo.Core.MemoryBlock to a classic framework MemoryBlock? I’m playing around with the Picture.FromData() method but that requires the data to be in the format of the old MemoryBlock where I have the data as a Xojo.Core.MemoryBlock.

The new MemoryBlock Data property will give you a Ptr. You can create a classic MemoryBlock with that Ptr, then copy the data to a “regular” MemoryBlock.

dim temp as MemoryBlock  = newMb.Data
dim mb as new MemoryBlock( newMb.Size )
mb.StringValue( 0, mb.Size ) = temp.StringValue( 0, mb.Size )
temp = nil

Really helpful Kem. Thank you.

Please support case 39159 for a way to do this without copying bytes.

Dim classicMB As New MemoryBlock(newMb.Data)

@Eli Ott This does not help. The classicMB is invalid when newMb gets deleted and has no size set, so the range checks don’t work.

Of course.

Christian’s right. The lack of a size parameter screws up a number of operations - the Picture.FromData method for one…

I’ve added my support to the feedback case @Christian Schmitz


12 Feedback Points added :slight_smile:

75 points from me