RGBSurface Image Colour

I’m using an RGBSurface to check the pixel colour before moving an object.
c = surf.Pixel(sx,sy)
If c is blue the object can move if not it must be a collision

This was working fine on my older Mac but on the new M2 the blue on the jpeg image that is loaded has different RGB values to the older Mac

  1. Why would the blue be different?
  2. How can I get around it?

Are you loading the image into the Xojo picture using Xojo commands or a plugin?

There are many possible reasons why the colour is not the exact same, and the immediate possibility is that jpeg is a lossy format. Lossy means that the image is compressed and the colour is slightly changed. When the picture is viewed, then the colour can change based on a newer algorithm (newer mac) or an older jpeg algorithm (older mac). The benefit of using a lossy format is that the image file-size is smaller. Example formats of lossy image types are: JPEG,

Try and use a lossless image format. Common examples are: .RAW, .BMP, GIF, TIFF, and .PNG. The file-size will typically be larger. JPEG may be saved to lossless format when using the ‘maximum’ setting in photoshop - but caution should be used.

1 Like

ColorSpaces also, perhaps?

If c is blue

But you could try for ‘close enough to blue’ … looking at the rgb or HSL variance?


It is a picture asset in Xojo and called using g.DrawPicture(Map1…

OK. Some possible causes:
• If you have switched Xojo versions it could be because Xojo have changed how they interact with CoreImage.
• If you are running a different version of macOS, Apple may have tweaked their CoreImage JPEG decoding algorithm.
• If you have switched CPU architectures - Intel to ARM or M1 to M2, then CoreImage may be producing slightly different values because the algorithms are different.

Switching to PNG might solve the problem as the result is more predictable. However, you are still at the mercy of how Xojo interacts with CoreImage or any changes to the image decoding pipeline such as colour management.

The safest approach is to use the image decoding plugins from MBS or Einhuger as that gives you more control.

1 Like

Yes, PNG is just as unpredictable :frowning: I’ll check MBS

There are a lot of graphic methods is there a decoding example, nothing jumps out…

Instead of using rgb, you should try using HSV as they’ll let you calculate something “close enough” in hue, saturation (brightness) and value (lightness)

1 Like


1 Like