Hi All,
Back with another problem.
I have an App that takes a Screen Shot and the user saves to SD Card. This bit working well.
The code below is my attempt to select and view these Screen Shots. The code is basically a rip-off of Erel's Text Editor to save/load to/from external memory.
I have added added the following Sub LoadPNG into FileHanlder Class to handle PNG files.
When I try to Load Here.PNG file I get this error:
Regards Roger
Back with another problem.
I have an App that takes a Screen Shot and the user saves to SD Card. This bit working well.
The code below is my attempt to select and view these Screen Shots. The code is basically a rip-off of Erel's Text Editor to save/load to/from external memory.
B4X:
Sub BtnFiles_click
If File.Exists(File.Dirinternal&"/ABT/", "") = False Then File.MakeDir(File.Dirinternal&"/ABT/", "")
If File.Exists(File.Dirinternal&"/ABT/", "TempImage") = False Then File.Delete(File.Dirinternal&"/ABT/", "TempImage")
LoadIMG 'Takes user to file handler screen, user selects image to import
End Sub
Private Sub LoadIMG
Wait For (FileHandler1.LoadPNG) Complete (Result As LoadResult)
HandleLoadResult(Result)
End Sub
Private Sub HandleLoadResult(Result As LoadResult)
If Result.Success Then
Private in As InputStream
Private Out As OutputStream
Private byte1() As Byte
Private DirSource1 As String
Private TempPNG As Bitmap
Private LblH As Int = lblBTSLongLat.Height * 1.5
Filename1 = Result.RealName
DirSource1 = Result.Dir
'*******Gets file selected by FileHandler and stores it in DirInternal
If Filename1.EndsWith(".png") Then
byte1 = File.ReadBytes(DirSource1, Filename1) '************ This line causes the error.
in.InitializeFromBytesArray(byte1, 0, byte1.Length)
TempPNG.Initialize2(in)
Out = File.OpenOutput(File.Dirinternal&"/ABT/", "TempImage", False)
TempPNG.WriteToStream(Out, 100, "PNG")
Out.Close
'***************Image is now in internal memory folder as "TempImage"
'************ Now display image
ImgScreen.Top = LblH
ImgScreen.SetBackgroundImage(LoadBitmap(File.Dirinternal&"/ABT/", "TempImage"))
lblTitle2.Height = LblH
lblTitle2.Gravity = Gravity.CENTER_HORIZONTAL
lblTitle2.Text = Filename1
ListBack2.Height = LblH
ListBack2.Width = ListBack.Width
ListBack2.BringToFront
ListBack2.Visible = True
ListBackFlag = True
Else
toast.Show("Not a Valid file.")
End If
Else
toast.Show("No file loaded")
End If
End Sub
I have added added the following Sub LoadPNG into FileHanlder Class to handle PNG files.
B4X:
Public Sub LoadPNG As ResumableSub
Dim cc As ContentChooser
cc.Initialize("cc")
cc.Show("image/*", "Choose image")
Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
Dim res As LoadResult = CreateLoadResult(Success, Dir, FileName)
If res.Success Then ExtractInformationFromURI(res.FileName, res)
Return res
End Sub
When I try to Load Here.PNG file I get this error:
java.io.FileNotFoundException: No content provider: Here_.png
Regards Roger