copying a 32 bit source into a 24 bit dest?

I found a bug in my code that happens when I use this line of code
//m.ColorValue(off, 24) = surface.Pixel(c,r)
If I comment it out and use the r,g,b method, it works (the image renders without color artifacts), but i think it’s slower.
I suspect there is a transposition error from the color to the ColorValue of m.

[code] dim surface as RGBSurface = p.RGBSurface
for r=0 to p.Height-1
for c=0 to p.Width-1
//m.ColorValue(off, 24) = surface.Pixel(c,r)

  m.UInt8Value(off) = surface.Pixel(c,r).Red
  m.UInt8Value(off+1) = surface.Pixel(c,r).Green
  m.UInt8Value(off+2) = surface.Pixel(c,r).Blue
  off = off + 3


Have you played with the littleEndian of the memoryBlock?

Agreed. Set LittleIndian = false will fix the issue.


m.LittleEndian = False
m.ColorValue(off, 24) = surface.Pixel(c,r)

I will try this… Is the default big endian???
Because I haven’t explicitly changed it.

Tried it… No luck … Still have to use R,G & B.

Brian, you can probably speed up the new code a little by putting the value of surface.pixel into a variable so you only call it once per loop.

#pragma disableBackgroundTasks.

Or use plugin functions.
e.g. here

Picture.CopyRGBtoMemoryblockMBS may do this.

Does anyone know if the OpenCV lib has xojo Picture integration?