Android Question Loading bitmap error JAVALINE

Espinosa4

Active Member
Licensed User
Longtime User
Hi,

I use always the same pics in my programs and I never got an error but now, some people have this problem. Comment that his version of android is 4.4.2

Is possible that an B4A updated the library and now this old version of android have this problem?

Thanks in advance
Espinosa
 

Espinosa4

Active Member
Licensed User
Longtime User
Thanks Erel for your reply.

Here the error.
It always works until now
 

Attachments

  • Screenshot_2017-11-16-16-53-16-838_com.whatsapp.png
    Screenshot_2017-11-16-16-53-16-838_com.whatsapp.png
    287.3 KB · Views: 171
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
I have Two different things
Java updated in my windows.
And also I started to use your last version
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
The image in which format is it? In what folder is it located? Can you see the code lines where loading the image?
 
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
Here the code that I use...

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim SourceImageRect, TouchImageViewRect As Rect
    Dim Bitmap1 As Bitmap
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim TouchImageView1 As TouchImageView
    Dim SQLVariables2 As SQL
    Dim CurVariables2 As Cursor
    Dim SQueryVariables2 As String
    Private PnlOrd As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("LytImagen")
    If SQLVariables2.IsInitialized = False Then
        SQLVariables2.Initialize(File.DirDefaultExternal, "l4pro.sql", False)
    End If
    SQueryVariables2 = "SELECT * FROM Variables"
    CurVariables2 = SQLVariables2.ExecQuery(SQueryVariables2)
    CurVariables2.Position = 0
    Activity.Title = CurVariables2.GetString("TituloActivity")
   
    TouchImageView1.Initialize("TouchImageView1")
    Activity.AddView(TouchImageView1, 0, 0, 100%x, 100%y)

    TouchImageView1.MinScale=0.5            '    default is 0.5
    TouchImageView1.MaxScale=6                '    default is 1.5
    TouchImageView1.TranslatePadding=128dip    '    default is 64dip
   
    TouchImageView1.Gravity=Gravity.FILL
    'TouchImageView1.SetBackgroundImage(LoadBitmap(File.DirAssets,"fondo.png"))
'   
'   
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize(File.DirDefaultExternal,CurVariables2.GetString("UltimaImagen")) '
    TouchImageView1.SetBitmap(Bitmap1)
    If FirstTime Then
        SourceImageRect.INITIALIZE(0, 0, Bitmap1.WIDTH, Bitmap1.HEIGHT)
        TouchImageViewRect.INITIALIZE(0, 0, TouchImageView1.WIDTH, TouchImageView1.HEIGHT)
    End If

'    if the scaling process scales the image to less than the current MinScale or more than the current MaxScale then MinScale or MaxScale will be adjusted
    TouchImageView1.ScaleSrcRectToDestRect(SourceImageRect, TouchImageViewRect, "CENTER")    '    make string a static constant in library
    Activity.AddMenuItem("Enviar Servicio","Enviar_Servicio")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
    TouchImageViewRect=TouchImageView1.GetDestRect
    If UserClosed Then
        SQLVariables2.Close
    End If
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
       If KeyCode = KeyCodes.KEYCODE_BACK Then
        Activity.Finish
       End If
End Sub

Sub Enviar_Servicio_Click
    Dim u As Uri 'ContentResolver library
    u.Parse("file://" & File.Combine(File.DirDefaultExternal,CurVariables2.GetString("UltimaImagen")))
    Dim i As Intent
    i.Initialize(i.ACTION_SEND, "")
    i.SetType("*/*")
    i.PutExtra("android.intent.extra.STREAM",u)
    StartActivity(i)
End Sub


I can't reproduce the error in with my mobile or my tablet. The problem, I think, It is on the android version and rare mobiles (CUBOC). As curiosity they never had problems. Will see. I reduce the images from 1280px to 1024. As curiosity as well, they can open the pics using ES file explorer but his default visor have problems.

The default directory is File.DirDefaultExternal

Thak you for your help
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Is this the lines that generates the error?
B4X:
Dim u AsUri'ContentResolver library u.Parse("file://" & File.Combine(File.DirDefaultExternal,CurVariables2.GetString("UltimaImagen")))Dim i AsIntent
 i.Initialize(i.ACTION_SEND, "")
 i.SetType("*/*")
 i.PutExtra("android.intent.extra.STREAM",u)StartActivity(i)
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Which brand and device model?

Try using the MSShare library
 
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
The mobile with problems are Cubok. I think I wrote write. A cheap mobile. Android 4.4.2

Thank you
I'll try.

The size seems isn't the problem
 
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
It is not related to the Java version or B4A version.

There is no information in this message. It might be a memory issue or a decoding issue.
If you are able to reproduce it then check the logs for the full error message.

Make sure to use LoadBitmapSample or LoadBitmapResize when loading large images.
Hi Erel,

Can I know the B4A version I used for compiling a project looking for the info into the APK file?

The Android version isn't the problem and still I can't reproduce the problem.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
the problem may be related to the device, not the App.
 
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
the problem may be related to the device, not the App.
Hi Star-Dust!

The mobile maybe is the problem but I'm curious why my program doesn't works now after and update (only I fixed some errors but totally different to the upload images).

Maybe the new version of B4A has some differences.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
What did you change with the new version?
 
Upvote 0

Espinosa4

Active Member
Licensed User
Longtime User
The B4A version is not stored in the APK.
As I wrote, nothing has changed in the way bitmaps are loaded. Use LoadBitmapSample if the image is large.
Ok thanks Erel.
But just a stupid question from a dummy guy....

Can a java update in my computer change something?
I use to show the images the library touchview and i don't use loadbitmapsample.

Thank youuu and I am very sorry for my questions.
Best regards
 
Upvote 0
Top