EtheaDev / SVGIconImageList

Three engines to render SVG (Delphi Image32, Skia4Delphi, Direct2D wrapper) and four components to simplify use of SVG images (resize, fixedcolor, grayscale...)
Apache License 2.0
327 stars 96 forks source link

Blueish tint on Android and MacOS-X #229

Closed birbilis closed 2 years ago

birbilis commented 2 years ago

I see blueish tint on Android when using the latest TSVGIconImageList from GetIt Package Manager

Windows: TortoiseAndTheHare_EditMode_StructureView en

Android: Tortoise and the Hare en_StructureView_EditMode-Samsung Galaxy Tab S8-12 0

The app is at https://github.com/zoomicon/READCOM_App

Apart from using TSVGIconImage for the SVG images in the stories, I use TSVGIconImageList for the app icons. All those are tinted. However, stories that contain bitmap images show fine, so it's something with the SVG rendering

I think it uses Image32 for rendering now (judging from a little debugging). Is there any known issue with that? How can I tell your library to use Skia SVG renderer instead? (or is there other engine alternative on Android too?) Do I need to install Skia4Delphi too and right click my project and enabled Skia (to added needed lib to deployment)?

UPDATE: the same tint appears on MacOS-X (those are supposed to be English/Greek/Italian/Portuguese/Spanish flags in the image) image

Is it something related to RGB versus BGR? Is Image32 also being used by default on OS-X?

AngusJohnson commented 2 years ago

the safest way to try it is to add via drag-drop all the needed Image32 source files into the test project so that they're explicitly referenced. Note that I've tried that step too

Yes, fair point. Nevertheless, having done as you've suggested I get exactly the same result - reversed red blue colors.

Also, from one of your images above, you appear to be using an Android emulator. Is that correct? If so, perhaps that's givng you incorrect results.

birbilis commented 2 years ago

So I went to a laptop of mine that had Delphi 11.0, upgraded it to Delphi 11.1 (this uninstalls all GetIt packages first). Did check in My Documens at Embarcadero\Studio\22.0\CatalogRepository that there are no folders for SVGIconImageList anymore. That machine is not exactly "clean" since I sync My Documents via OneDrive with my main dev machine, however I'm pretty sure it's not pulling any compiled units from the other one.

Synced with my fork of Image32 and built the packages in the groupproj and the demo from FMX3 folder. Uploaded APK file to BrowserStack App Live testing / device cloud (note that is using real devices, not emulators). Shows fine:

image

Can you try the .apk at this link? https://1drv.ms/u/s!AlQsuVnvuzUjgYKjADi88p43TxDP414?e=gAGhZW

If it shows wrong on your device then it's someother issue (related to hardware acceleration or something). If it shows OK then it means one of us is compiling/linking different code than we think we are using

AngusJohnson commented 2 years ago

Can you try the .apk at this link?

Yes, and it looked just fine on my phone. 🤔

And what I've tried once again just now...

  1. Downloaded the Zip Package of you Image32 fork.
  2. Extracted the content into an empty folder.
  3. Copied the contents from the source folder into Examples/FMX3.
  4. Opened fmx_svg.dproj in that folder in Delphi's IDE (10.4 Update 2 Community Edition) and selected the Android 64bit target platform (and my Samsung phone). (And I also tried 32bit.)
  5. Compiled, installed and ran on my phone but I still get the wrong colors.
carloBarazzetta commented 2 years ago

"Stranger Things"...

birbilis commented 2 years ago

I think next best way to try is to rename all Image32 units with some prefix and rename all use clauses too at them and at the demo app (I'll take a look with grepwin)

birbilis commented 2 years ago

Copied the contents from the source folder into Examples/FMX3.

not sure that is enough - what I'm doing is drag-dropping the files (either from the Image32_FMX package project in the group project, or from Windows Explorer) onto the demo project so that it adds in its .dpr direct references to them (of the style uses xx in '..\somefolder\xx.pas').

birbilis commented 2 years ago

In the meantime, I also tried downloading the .zip from my fork, opened the groupproj and tried the fmx_svg demo with same good result (this time with 32-bit target) on Google Pixel (Android 8). Then added the Image32 FMX related source files (practically all apart Layers and the Fmt. PNG/JPG/QOI/GIF that seem to need Windows/VCL) to the project as direct references and tried on Google Pixel 6, same result. Then also added the .inc files just in case to the project as direct references (this doesn't seem to change the .dpr, just the .dproj most probably) and tried again the 32-bit Android APK with Google Pixel 5 on BrowserStack. Same good render of SVG.

Can you try changing (temporarily) the fmx_svg .dpr in my repo download to this one? (this uses the direct references I mentoned [to be more certain where it's pulling stuff from]):

program fmx_svg;

{$R *.dres}

uses
  System.StartUpCopy,
  FMX.Forms,
  unit1 in 'unit1.pas' {Form1},
  Img32.Clipper2 in '..\..\source\Img32.Clipper2.pas',
  Img32.CQ in '..\..\source\Img32.CQ.pas',
  Img32.Draw in '..\..\source\Img32.Draw.pas',
  Img32.Extra in '..\..\source\Img32.Extra.pas',
  Img32.Fmt.BMP in '..\..\source\Img32.Fmt.BMP.pas',
  Img32.Fmt.SVG in '..\..\source\Img32.Fmt.SVG.pas',
  Img32.FMX in '..\..\source\Img32.FMX.pas',
  Img32.Layers in '..\..\source\Img32.Layers.pas',
  Img32 in '..\..\source\Img32.pas',
  Img32.Resamplers in '..\..\source\Img32.Resamplers.pas',
  Img32.Storage in '..\..\source\Img32.Storage.pas',
  Img32.SVG.Core in '..\..\source\Img32.SVG.Core.pas',
  Img32.SVG.Path in '..\..\source\Img32.SVG.Path.pas',
  Img32.SVG.PathDesign in '..\..\source\Img32.SVG.PathDesign.pas',
  Img32.SVG.Reader in '..\..\source\Img32.SVG.Reader.pas',
  Img32.Text in '..\..\source\Img32.Text.pas',
  Img32.Transform in '..\..\source\Img32.Transform.pas',
  Img32.Vector in '..\..\source\Img32.Vector.pas',
  Clipper.Core in '..\..\source\Clipper\Clipper.Core.pas',
  Clipper.Engine in '..\..\source\Clipper\Clipper.Engine.pas',
  Clipper.Minkowski in '..\..\source\Clipper\Clipper.Minkowski.pas',
  Clipper.Offset in '..\..\source\Clipper\Clipper.Offset.pas',
  Clipper in '..\..\source\Clipper\Clipper.pas';

{$I Img32.inc}
{$R *.res}

begin
{$IFDEF REPORTMEMORYLEAKS}
  ReportMemoryLeaksOnShutdown := true;
{$ENDIF}
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
birbilis commented 2 years ago

So I did in a copy of my repo fork's unzipped folder a change with grepwin of all Image32 to Image42 and all Img32 to Img42, then via command prompt did ren Img32*.* Img42*.* and ren Image32*.* Image42*.* at main folder, at source, source\Packages and at examples\experimental subfolders

then built/deployed 64-bit Android target, see https://1drv.ms/u/s!AlQsuVnvuzUjgYKpC1wcZOeH5zDh3Rc?e=0hDxji (for the Image42 test folder) https://1drv.ms/u/s!AlQsuVnvuzUjgYKqEW84651LRu5Rihw?e=ITToG5 (for the resulting APK - make sure you uninstall any instances of that demo from your Android phone first, since I don't change the packagename or version - to be more sure this is the one you run you can also add some visible label to the demo in that Image42 source and rebuild). Have tried the APK on BrowserStack and looks fine again

AngusJohnson commented 2 years ago

Can you try changing (temporarily) the fmx_svg .dpr in my repo download to this one? (this uses the direct references I mentoned [to be more certain where it's pulling stuff from]):

Done, but with the same incorrect result.

make sure you uninstall any instances of that demo from your Android phone first,

Yes, I did that too. I just forgot to mention it in my steps above.

birbilis commented 2 years ago

Then please also try Image42 (and also try the APK I built with it separately). If that APK shows fine but you build one that doesn't from that Image42 folder, then if it's not something strange with h/w acceleration, it could be something with the Delphi version / Firemonkey library you use. I use Delphi 11.1 with both patches installed

AngusJohnson commented 2 years ago

Then please also try Image42 (and also try the APK I built with it separately)

The APK displayed correctly on my phone.

The Image42 code also displayed correctly on Windows but while it compiled and installed on my phone it always crashed before it displayed anything. I tried numerous times in both debug and release modes without success, and I uninstalled the app each time before each compile.

And just to clarify ... while I understand there are currently problems with Image32 on Mac devices, but is it not displaying correctly on your Android devices too?

birbilis commented 2 years ago

The Image42 code also displayed correctly on Windows but while it compiled and installed on my phone it always crashed before it displayed anything. I tried numerous times in both debug and release modes without success, and I uninstalled the app each time before each compile.

did you try right-clicking on the Libraries node and selecting to Reset to system defaults?

while I understand there are currently problems with Image32 on Mac devices, but is it not displaying correctly on your Android devices too?

yes, it seems that Image32 demo isn't showing ok on neither Mac nor Android without the fix (actually a removal of those swaps for either platform) in my fork

AngusJohnson commented 2 years ago

did you try right-clicking on the Libraries node and selecting to Reset to system defaults?

I'm afraid I don't understand. Where would I find the Libraries node?

yes, it seems that Image32 demo isn't showing ok on neither Mac nor Android without the fix

While I haven't received a lot of feedback re Image32 and Android, I have received some. And you're the only person that has reported this issue with color so far, except early on before I added in the compiler directive that is evidently problematic for you. (And I don't doubt for a minute that your problem is genuine, I'm just wondering how widespread it is and, like you, very much wondering the cause.)

birbilis commented 2 years ago

did you try right-clicking on the Libraries node and selecting to Reset to system defaults?

I'm afraid I don't understand. Where would I find the Libraries node?

I mean do this to reset libraries just in case (btw, which Delphi version are you using? are all patches installed for it?): image

also, if you deploy using the debugger (instead of manually signing the APK using your own keystore/certificate and then deploying it), you need to change the Configuration to "Development" instead of "Application Store"

AngusJohnson commented 2 years ago

I mean do this to reset libraries just in case (btw, which Delphi version are you using? are all patches installed for it?):

Thanks, that got your Image42 running on my phone but still with the wrong colors. I'm using Delphi 10.4 (Update 2) Community Edition.

you need to change the Configuration to "Development" instead of "Application Store"

I've never used "Application Store"

This is a long shot but worth trying (as it's likely this issue is due to a change between Delphi 10.4 and 11) ... In the procedure AssignImage32ToFmxBitmap in Img32.FMX change the following line

  //src := TBitmapData.Create(img.Width, img.Height, TPixelFormat.BGRA);
  src := TBitmapData.Create(img.Width, img.Height, TPixelFormat.RGBA);

This has no affect in Delphi 10.4 but it just might fix things in 11. And please try this with both my otherwise unaltered Image32 and your forked revision. Cheers.

luebbe commented 2 years ago

Interesting to see the problem here and the new discussion in Graphics32 occur at the same time: https://github.com/graphics32/graphics32/issues/199

carloBarazzetta commented 2 years ago

No more issue reported, I'm closing...