Save Image to Database runtime lazarus / 43-Android ---------------------------------------------------------------------- magleft · 2023-08-19 15:02 Hi to all. I am trying in the application I have made, to save in a database on runtime photos that I take with the camera. If I just select save, everything works fine. With the help of appCameraDemo I made the following code but it doesn't work. The message that comes out after some time is:   if no operation for a long time, the screen will enter the power saving state. About to exit camera or click on the screen to wake up. And then return        resultCode = RESULT_CANCELED :           photo Canceled I have set the camera resolution to 2MP although I would like more resolution. If anyone can help... 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 TFvisitland.Button16Click(Sender: TObject);begin  if IsRuntimePermissionGranted('android.permission.CAMERA') and     IsRunt imePermissionGranted('android.permission.WRITE_EXTERNAL_STORAGE') then  begin      Camera1.Filename :=GetNameFarmer ;      Camera1.RequestCode := 12345;      Camera1.TakePhoto;  end  else  ShowMessage('Sorry... Some Runtime Permission NOT Granted ...');end; procedure TFvisitland.FvisitlandActivityResult(Sender: TObject;  requestCode: integer; resultCode: TAndroidResult; intentData: jObject);var  photoPath: string;  photo_id:integer;begin  if resultCode = RESULT_CANCELED then  begin    ShowMessage('Photo Canceled!')  end  else if resultCode = RESULT_OK then //ok...  begin  if requestCode = Camera1.RequestCode then    begin      photoPath:= Camera1.FullPathToBitmapFile ;      Bitmap1.ImageIdentifier :=Camera1.FullPathToBitmapFile ;      // FIND LAST RECORD      DbVisitLandPhoto.close;      DbVisitLandPhoto.OpenOrCreate(dbname);    DbVisitLandPhoto.select('Select max(IDEPISK3) from Episkepsi4;') ; // Find Last record      photo_id:=DbVisitLandPhoto.Cursor.GetValueAsInteger(0)    ;      Bitmap1.LoadFromFile(photoPath) ;      DbVisitLandPhoto.UpdateImage('EPISKEPSI4',      'FIGURE',    // FIELD OF IMAGE      'IDEPISK3',  // FIELD ID      Bitmap1,      photo_id);  end;  end  else    ShowMessage('Photo Fail!');end; ---------------------------------------------------------------------- Mongkey · 2023-09-15 09:45 You could consider saving path of camera pic with detail -> ex:visit1,25-5-2023 10:10:23, path, note. You could simply call picture by retrieving its path, as long as you are not changing its path. Thank you. ---------------------------------------------------------------------- magleft · 2023-09-16 05:22 Thanks for the reply, but it's not possible as my app shares the database with a windows program. I'm thinking maybe it's the size of the files, so how could I reduce their size by maybe converting them to some other format. ---------------------------------------------------------------------- Mongkey · 2023-09-16 05:50 Creating web API is one of many solutions, you could upload your picture with detail using jhttpclient, but again using your first base64 image  -> 2MB image would take about 3-5 second to convert. ---------------------------------------------------------------------- fpcoder · 2023-09-16 11:13 Check these forum threads how to save images in database as BLOB. Thats the usual way. https://forum.lazarus.freepascal.org/index.php?topic=34191.0 https://forum.lazarus.freepascal.org/index.php?topic=17606.0 ---------------------------------------------------------------------- magleft · 2023-09-17 16:04 Thanks. I will try. Also i try to convert image to png https://forum.lazarus.freepascal.org/index.php/topic,64591.0.html