FabDev 8 Posted June 23, 2023 (edited) Hello, In Delphi 11.3, why a pasted image from clipboard RGB becomes BGR on IOS 64 bits (16.5) ? This sample which paste a bitmap from clipboard is extracted from : https://docwiki.embarcadero.com/CodeExamples/Alexandria/en/FMX.CopyPaste_Sample https://github.com/Embarcadero/RADStudio11Demos/tree/main/Object Pascal/Multi-Device Samples/User Interface/CopyPaste => This demo has the same problem ! procedure TForm66.Button1Click(Sender: TObject); var Bitmap:TBitmap; LStream:TMemoryStream; Svc: IFMXClipboardService; Value: TValue; begin if TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService, Svc) then begin Value := Svc.GetClipboard; if Value.IsType<TBitmapSurface> then begin ImageSRC.Bitmap.Assign(Value.AsType<TBitmapSurface>); end else showmessage('Clipboard not a bitmap'); end; end; Work fine on Windows 32 or 64 bits, Android 64 bits and MacOS 64 bits But on IOS 64 bits (16.5) image is pasted but RGB colors becomes BGR... is pasted to => Same with : GlobalUseMetal := True; GlobalUseSkia := True; Full sample in attachment. ImagePasteFromClipboardIOSRGBLost.zip Edited June 23, 2023 by FabDev Share this post Link to post
Rollo62 536 Posted June 23, 2023 Could this be related to 24Bit vs. 32Bit images ? https://stackoverflow.com/questions/57143845/mtktextureloader-messes-png-rgb-vs-bgr-formats https://developer.apple.com/documentation/accelerate/conversion https://stackoverflow.com/questions/46886993/how-to-determine-whether-the-colour-format-is-rgb-or-bgr https://developer.apple.com/documentation/coregraphics/cgcolorspacemodel?language=objc Share this post Link to post
Anders Melander 1784 Posted June 23, 2023 I don't have time to look at the source but if the bitmap being pasted is a 16 or 32-bit BMP bitmap with BI_BITFIELDS encoding then the problem can be that Delphi's TBitmap doesn't really support the nuances of that format. The BI_BITFIELDS format uses 3 (or 4, depending on the BMP version) mask values that specify the layout of the RGB channels in the pixel values and AFAIR TBitmap ignores the mask values and instead assumes a certain layout. Share this post Link to post
Patrick PREMARTIN 74 Posted June 24, 2023 Thanks for having opened an issue, it will be easier to follow at https://quality.embarcadero.com/browse/RSP-41896 Share this post Link to post
Anders Melander 1784 Posted June 24, 2023 8 hours ago, Patrick PREMARTIN said: Thanks for having opened an issue, it will be easier to follow at https://quality.embarcadero.com/browse/RSP-41896 The bitmap in that issue is a version 1 BMP in BI_RGB format so the problem I mentioned does not apply. Issue RSP-37651 might be related. According to that issue, it's fixed in 11.2 but as far as I can tell from looking at the source in 11.2 it hasn't been fixed. At least not in the way suggested by the reporter. Share this post Link to post
Dave Nottage 557 Posted June 25, 2023 47 minutes ago, Anders Melander said: At least not in the way suggested by the reporter. The fix in 11.2 is essentially the same as was suggested. The problem is that UIImageToBitmapSurface was not fixed, as opposed to UIImageToBitmap (directly below it), which was. 2 Share this post Link to post
FabDev 8 Posted June 27, 2023 (edited) The image provided in my sample is only to understand that happen. I don't check if all type a picture (png, jpeg etc..) have this problem. But it's a very easy to reproduce : 0) Take a photo 1) Select this photo (in photo app) 2) Copy this photo to the clipboard (with Share option in IOS) 3) Paste it in source app given or sample from Embarcadero "CopyPaste ". => RGB becomes BGR I have updated my report https://quality.embarcadero.com/browse/RSP-41896 Edited June 27, 2023 by FabDev Share this post Link to post