Jump to content
FabDev

Paste image from clipboard : RGB becomes BGR on IOS 64 bits ?

Recommended Posts

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...

 

FM_ApplicationIcon_180x180.png.c98abba2e76c1b41a03daccfb67a5c46.png   is pasted to =>  image2.png.10af460cbf292d3a7825e0790d9dd3c4.png

 

 

 

Same with :

GlobalUseMetal := True;
GlobalUseSkia := True;

 

Full sample in attachment.

 

 

ImagePasteFromClipboardIOSRGBLost.zip

Edited by FabDev

Share this post


Link to post

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
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
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.

 

  • Like 2

Share this post


Link to post

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 by FabDev

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

×