load a PNG file from assets lazarus / 43-Android ---------------------------------------------------------------------- Dzandaa · 2021-12-29 16:42 Hi everybody, Trying LAMW on Linux installed yesterday I try to load a .PNG picture that I put in the assets directory of my program. I just have a button and the Click event is: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.BLoadClick(Sender: TObject);var  DeskPict :jBitmap;begin  DeskPict.LoadFromAssets('cards.png');end;  ' = ' of course Build... OK.  "Run" -> "[LAMW] Build Apk and Run".. OK. The APK run fine until I press the button and then crash... Any idea with example how to load a .PNG file? The picture size is 468x250 Thank you. ---------------------------------------------------------------------- jmpessoa · 2021-12-29 17:39 Put a jBitmap component on the form ... then Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TAndroidModule1.BLoadClick(Sender: TObject);begin   Bitmap1.LoadFromAssets('cards.png');end; ---------------------------------------------------------------------- Dzandaa · 2021-12-29 19:08 Hi, Thank you jmpessa. No crash now, but now, I tried to draw part of my .PNG on a jDrawingView So I drop a JDrawingView on the Form, Center on Parent with Height 148 width 116 margins 0 LayoutParamHeight and Width to lpExac Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  Pict: jDrawingView; procedure TAndroidModule1.BLoadClick(Sender: TObject);begin  DeskPict.LoadFromAssets('cards.png');  Pict.DrawCroppedBitmap(DeskPict, 11, 11, 0, 0, 36, 50); // position on Pict: 11, 11, draw DeskPict from x=0, y=0, Width=36, Height=50end;  But I don't know if this is the right thing to do ---------------------------------------------------------------------- jmpessoa · 2021-12-29 19:24 QuoteHeight 148 width 116 This dont work  on android... use only LayoutParamHeight and LayoutParamWidth QuotePict: jDrawingView;  No!!! Put a jBitmap and a jDrawingView (or jImageView) component on the form ... then procedure TAndroidModule1.BLoadClick(Sender: TObject); begin    Bitmap1.LoadFromAssets('cards.png');    DrawingView1.DrawCroppedBitmap(Bitmap1.GetImage, ..........);   //or    //ImageView1.SetImage(Bitmap1.GetImage); end; Please, take a look at the "demos"... so you can learn how LAMW works.... ---------------------------------------------------------------------- Dzandaa · 2021-12-30 11:08 Hi Again, Working now, I missed the 'GetImage' function Thank you very much for your help. ---------------------------------------------------------------------- Dzandaa · 2022-01-04 13:49 Hi, I found that when I load a .PNG picture from asset(size width=468 Height=250) And I use this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   CardWidth: Integer;  CardHeight: Integer;  CardsPict: jBitmap; ... CardsPict.LoadFromAssets('cards.png'); CardWidth := CardsPict.GetWidth(); CardHeight := CardPict.GetHeight();  CardWidth = 250 and CardHeight = 468 Is this normal?