Memoryblock Picture.ToData issue

Not many of my customers use OSX, but lately they complained more and more about my programs showing display issues, amongst others. I write these programs on an iMac, and compile them to 64 bit OSX and 32 bit Windows. The Windows .exe has no problems whatsoever. Running the .app on my iMac under El Capitan showed no problems at all.

This week I changed my old iMac – running El Capitan – for a new one, an iMac Retina 5K 27" 2020, 3.3GHz 6 Core Intel i5, 8GB, Big Sur 11.2. As expected it showed strange display issues when running my programs.
After a long search I was able to narrow down the display issue to one particular command:

Dim mb As MemoryBlock
mb = texture.ToData(Picture.Formats.BMP)

The picture saved in mb was sometimes shifted horizontally, but not always. It looks like if every row of pixels is shifted to the right (rotated is a better word, pixels shifted out appear on the other side). And without any logic. Every time I run the program other pictures are malformed.

I don’t think it’s a Xojo issue, because the apps are compiled with Xojo 2018.r1.1 under El Capitan, and show the issue when running under Big Sur (probably Catalina as well?). And on the new iMac, compiled with Xojo 2020.r2.1, nothing has changed - still the same issue.

What I like to know is if anyone else has noticed this. And know the origin of the issue, maybe a simple workaround? I’ve found a workaround: loop through all the pixels in the picture and write them in the Memoryblock. It works, but it’s obvious that 40 lines of code is a lot slower that those nice 2 lines. And it adds up, having a lot of pictures to be processed.

I wrote the simplest test program. Place a button ‘test’ on Window1 which invokes method ‘test’ (listed below) and add a picture ‘texture’ to the project (any picture will do). Button test will make 3 memoryblocks from this picture and compares the results. If you hear a beep all 3 where equal, or it will show one or two messageboxes when not. Note: if you hear a beep this does not imply the 3 Memoryblocks are OK, they can be all malformed equally! Press button several times and you will most likely experience different results every time. As I mentioned earlier: without any logic.


Method test

Dim mb1,mb2,mb3 As MemoryBlock
mb1 = texture.ToData(Picture.Formats.BMP)
mb2 = texture.ToData(Picture.Formats.BMP)
mb3 = texture.ToData(Picture.Formats.BMP)

Dim okflag As Boolean = True
If mb1 <> mb2 Then
  okflag = False
  MessageBox("mb1 not equals mb2")
End If
If mb1 <> mb3 Then
  okflag = False
  MessageBox("mb1 not equals mb3")
End If
If okflag Then
  beep
End If
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.