Recent

Author Topic: BGRABitmap for Android demo provides fast pixel access for jBitmap  (Read 3006 times)

neuro

  • Jr. Member
  • **
  • Posts: 71
I have created BGRABitmap for Android demo which provides fast pixel access for jBitmap, and allows fast conversion “array of Byte” into jBitmap.
jmpessoa, please download the attachment and include it in public distribution of LAMW demos.

Currently LAMW does not provide fast pixel access for Android graphics.
jCanvas has
Code: Pascal  [Select][+][-]
  1. procedure DrawPoint(_x1: single; _y1: single);
which is extremely slow and makes Android app almost unusable.

Attached “AppBGRABitmapDemo1” has solved the problem of extremely slow graphics and now everybody will be able to create fast graphics apps using LAMW.

Instructions how to test the AppBGRABitmapDemo1:

1) Install BGRABitmap package to Lazarus IDE.

2) Original BGRABitmap package does not compile in Android, thus you need to use patched source code files.
From project subdirectory “!BGRABitmap_fixed_files” take 3 files

bgrafreetype.pas
bgranoguibitmap.pas
bgraopengl.pas

and replace these 3 files in TBGRABitmap package, which are located in directory:
“C:\fpcupdeluxe\ccr\bgrabitmap\bgrabitmap”

3) Add “BGRABitmapPack4NoGUI” to the project “Required Packages”.
Go to the menu:
Project -> Project Inspector -> Required Packages -> Add -> BGRABitmapPack4NoGUI -> Ok

4) Run project and press button “Draw BGRABitmap”.


P. S.:  patched BGRABitmap package files need more investigation by the author of BGRABitmap. Now I have disabled all fonts and OpenGL related code in order to enable compilation under Android. Official distribution of BGRABitmap package should be updated accordingly.
« Last Edit: March 10, 2022, 01:33:44 am by neuro »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2317
Re: BGRABitmap for Android demo provides fast pixel access for jBitmap
« Reply #1 on: March 10, 2022, 03:03:15 am »
Quote
jmpessoa, please download the attachment and include it in public distribution of LAMW demos.

Done!

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: BGRABitmap for Android demo provides fast pixel access for jBitmap
« Reply #2 on: March 10, 2022, 08:46:24 am »
Thank you very much  :)

So to sum up, you've removed references to OpenGL and LazFreeType.

Regarding LazFreeType, one problem that happened with fpGui/noGui was that with new version of Lazarus, the FreeType units were moved to a new "freetypelaz" package instead of LazUtils. Have you tried adding the reference to this new package?

About OpenGL, I suppose that the OpenGL doesn't work at all?
Conscience is the debugger of the mind

neuro

  • Jr. Member
  • **
  • Posts: 71
Re: BGRABitmap for Android demo provides fast pixel access for jBitmap
« Reply #3 on: March 10, 2022, 10:38:00 am »
Yes, in BGRABitmapPack4NoGUI package I have removed references to OpenGL and LazFreeType, because they fail to compile under Android.
My goal was to gain fast pixel access for jBitmap, so all unnecessary functionality of BGRABitmap (like LazFreeType and OpenGL) could be sacrificed for that purpose.
Yesterday I had deleted and reinstalled the latest version of Lazarus (release v2.2.0h of fpcupdeluxe-x86_64-win64.exe), and only after fresh install of Lazarus I had created “AppBGRABitmapDemo1”.
I have never used “FreeType” before, so I do not know if it could be forced to compile under Android.
We should contact authors of BGRABitmap package and ask them to update the official distribution of BGRABitmap package to be compatible with Android (by disabling OpenGL and LazFreeType in Android version).

Btw, please note that current latest version release v2.2.0h of fpcupdeluxe-x86_64-win64.exe by default installs incorrect version of gradle-7.3.1 and all Android apps fail to launch.
The workaround solution is to manually install Gradle 6.8.3.
Please read here:
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/issues/507
Release v2.2.0h of fpcupdeluxe-x86_64-win64.exe needs gradle-6.8.3 instead of gradle-7.3.1

AlexTP

  • Hero Member
  • *****
  • Posts: 2479
    • UVviewsoft

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: BGRABitmap for Android demo provides fast pixel access for jBitmap
« Reply #5 on: March 10, 2022, 06:09:03 pm »
Well I am the author of the library. I am a bit lost when it comes to Android development.

I can make a package for android where I just remove the references as you suggest, though I wonder exactly what the problems are with those, to get an idea whether there is a workaround.

Can you give me more detailed information on the errors you encounter?

About FreeType, you can try adding the package freetypelaz as a condition to the BGRABitmap package. This may compile. No need to know how to use it. I don't know either if it is useful in Android development to have text rendering capabilities.
Conscience is the debugger of the mind

neuro

  • Jr. Member
  • **
  • Posts: 71
Re: BGRABitmap for Android demo provides fast pixel access for jBitmap
« Reply #6 on: March 10, 2022, 06:46:04 pm »
circular, as a quickest solution today, please just take 3 patched files from
https://github.com/jmpessoa/lazandroidmodulewizard/tree/master/demos/GUI/AppBGRABitmapDemo1/!BGRABitmap_fixed_files
bgrafreetype.pas
bgranoguibitmap.pas
bgraopengl.pas

and replace these 3 files in your official TBGRABitmap package distribution:
https://github.com/bgrabitmap/bgrabitmap/tree/master/bgrabitmap

The only modification in these three *.pas files is disabling OpenGL and LazFreeType when compiling for Android platform. There are no changes in code when compiling for other platforms. The patch affects only compilation for Android platform.
The patch was done in following way:
Code: Pascal  [Select][+][-]
  1.  {$IF not Defined (ANDROID)} // Workaround fix for Android compilation
  2. //program code which fails to compile under Android
  3.  {$ENDIF} // Workaround fix for Android compilation
Let’s hope later somebody maybe will figure out what to do with FreeType and OpenGL in Android. As for today, let’s just disable this code when compiling for Android.

circular

  • Hero Member
  • *****
  • Posts: 4356
    • Personal webpage
Re: BGRABitmap for Android demo provides fast pixel access for jBitmap
« Reply #7 on: September 24, 2023, 06:06:26 pm »
Thank you, neuro, for your dedicated efforts to improve BGRABitmap's compatibility with Android.

I've incorporated your idea on the dev branch and introduced a new package named BGRABitmap4Android, which bypasses the FreeType dependency. I hope this will provide a smoother experience for Android development. I don't have the development environment so we may need to iterate to finalize it.

My apologies for the delay in addressing this. Sometimes, in our pursuit for the perfect solution, we might overlook the practical and immediate fixes. Your proactive approach is really valuable to this community and the project.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018