Jump to content
John van de Waeter

iOS, Metal, Bitmaps, RGB becomes BGR?

Recommended Posts

Hi All,


I use Metal in a iOS FMX project like:


 if TUIScreen.Wrap(TUIScreen.OCClass.mainScreen).nativeScale=TUIScreen.Wrap(TUIScreen.OCClass.mainScreen).Scale


I use Media-Camera action TakePhotoFromCamera OnDidFinishTaking and assign the bitmap to a TImage.Bitmap.


This used to work okay, but now on Delphi11 it produces an image in which Red and Blue are interchanged.


Same thing happens if I paste an image from the clipboard.

Same thing happens if I get an image from the gallery.


Image.Bitmap.Loadfromfile('animage.jpg') and dito .png works okay.


If I turn off Metal, all is okay. Tested on iPhone5 and iPhone8.



Any thougts?

tia, John


Edited by John van de Waeter

Share this post

Link to post

Do I understand you right, that with 10.4 all works fine, but now with Delphi 11 not? Then I think you should open a QR-Report at jira.


In fact on macOS the bitmaps are in BGR order, but pasting images from the clipboard or getting images from the gallery should take this into account.

Share this post

Link to post

Did you try to move the metal initialization into the .dpr file? I think it's mandatory.

Something like in this example (to adapt for your need)

{$IF defined(MACOS)}
	if TCustomContextMetal.IsMetalSupported then
	GlobalUseMetal := True;
Application.CreateForm(TFormMain, FormMain);


I faced several problems when in the main application, it didn't work or even produced errors.
Someone here told me that, according to the documentation this has to be set into the DPR file.




Share this post

Link to post

Hi John,


First word that popped into my head was, endianness.

Use to pass data between old mpus.

looking at timage.LoadFromStream, it calls the TBitmapCodecManager.LoadFromStream who then passes it off to the CodecClass

but that's where i stop as the function to get the correct CodecClass is in fact called GuessCodecClass() , so your guess is as good as mine..

frack it, flip all the bits..


Sorry, no help..



Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now