If I save a TBitmap as jpg into the public picture folder, the file will not show up in picture viewer.
Also it is not shown in the windows explorer which is connected via USB cable to the android device.
The file is created as expected into the android device.
Using a file explorer I can see the file and can open it manually: The file content seems to be correct.
The strange thing:
After I rename or copy the file using a android file explorer the file shows up immediately in the picture viewer and also in the external windows explorer.
So it seems the way delphi create the file on the device is somehow not the way android expext it.
The sample source code of this problem is quite simple:
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Objects;
type
TfmTest = class(TForm)
procedure FormCreate(Sender: TObject);
private
public
end;
var
fmTest: TfmTest;
implementation
uses
System.IOUtils;
{$R *.fmx}
procedure TfmTest.FormCreate(Sender: TObject);
var
sFn: string;
sPath: string;
xBmp: TBitmap;
begin
// create sample bmp
xBmp := TBitmap.Create(100, 100);
try
xBmp.Canvas.BeginScene;
xBmp.Canvas.Clear(TAlphaColorRec.Aqua);
xBmp.Canvas.Fill.Color := TAlphaColorRec.Khaki;
xBmp.Canvas.FillEllipse(TRectF.Create(0, 0, 99, 99),1);
xBmp.Canvas.EndScene;
// save this bmp to puclic pictures
sFn := TPath.Combine(TPath.GetSharedPicturesPath, ‘test.jpg’);
xBmp.SaveToFile(sFn);
finally
xBmp.Free;
end;
end;
end.
Notes:
It does not matter which file explorer I take (e.g. ES File Explorer
or File Commander)
I tried different directories to create the file
in. Allways the same. If I create also the directory the content is
not shown unless I rename the directory with a file explorer.
Used Delphi Version: XE6 on Win7-64, used Android: 4.4.4 on Sony Xperia Z2