I get the bitmap from a HttpJob download, and then put the bitmap into an imageView to display it.How are you loading the files?
They are JPEG filesWhat format are they in?
There are many sizes, but they are all about 30-100kbWhat size are they?
I'm using a Motorola Defy, with a 1ghz micro and 512mb ram.What are the capabilities of the device you are using?
I have no canvas, I use a ImageViewHow are you initialising the Canvas to display the images?
I'm not using any code to indicate directly to Android to recycle, but I read that when you lose the reference to a bitmap, the garbage collector should recycle it.Have you attempted to indicate that when you display image 3 or so, that the memory occupied by image 1 can be recycled by Android?
Sub Show_Image
Dim h,w,aux As Double
Dim bmp As Bitmap
Dim mTuple As Tuple 'Tuple is an obj that holds a Title, ImageLink, and a Boolean that says if the Image have been downloaded or not
Dim Pz As PinchZoomAndMove
mTuple = mList.Get(Visor) 'I get the Info from the Image I wanna see
bmp.Initialize(File.DirDefaultExternal,Visor) 'Initialize the bitmap, at this point, the previous Image I was seeing,
'should have been recolected by the garbace collector
h = bmp.Height
w = bmp.Width
If Not(Image.IsInitialized) Then 'Image is a ImageView, its a global variable.
Image.Initialize("mImage")
End If
Image.RemoveView
Image.Bitmap = bmp 'At this point there is not reference at all to the previous Bitmap
Image.Gravity = Gravity.FILL
aux = (h/w)*Panel1.Width
Panel1.AddView(Image,0,Panel1.Height/2-aux/2,100%x,aux)
prev_image.BringToFront 'This are bottons to se the previous and next Image
next_image.BringToFront
Pz.Initialize(Image,"PZ",Image.Tag,1,3,1.5,False,Me) 'This is to pinch and zoom
Pz.SetLimitArea(True)
Activity.Title = (mTuple.Title)
If Not(Lock) Then 'I download 1 Image at the time on demand. DownloadNextImage puts a lock which is released when the Image is actually downloaded
DownloadNextImage
Else
Timer1.Enabled = True 'The Timer will ask every 0.5s if the Lock is released
End If
End Sub
Sub Process_Globals
Private bitmapsCache As Map
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
bitmapsCache.Initialize
bitmapsCache.Put("image1", LoadBitmapSample(...))
bitmapsCache.Put("image2", LoadBitmapSample(...))
bitmapsCache.Put("image3", LoadBitmapSample(...))
bitmapsCache.Put("image4", LoadBitmapSample(...))
End If
ImageView1.SetBackgroundImage(bitmapsCache.Get("image1"))
End Sub
gv.Initialize("gv")
Activity.AddView(gv, 0, 0, 100%x, 100%y)
AcSf.Initialize("AcSf", True)
Activity.AddView(AcSf, 0, 0, 100%x, 100%y)
gv.BitmapsData.Add(fondo)
gv.BitmapsData.Add(background)
gv.BitmapsData.Add(puntuacion)
For i=0 To 2
gv.BitmapsData.Add(Mtimedraw(i))
Next
gv.BitmapsData.Add(fondowhite)
For i=0 To 4
gv.BitmapsData.Add(Mscoredraw(i))
Next
gv.BitmapsData.Add(tittle)
gv.BitmapsData.Add(number3)
' bitmaps
For i=0 To 1
For j=0 To 1
gv.BitmapsData.Add(M22draw(i,j))
gv.BitmapsData.Add(M22drawb(i,j))
Next
Next
For i=0 To 2
For j=0 To 2
gv.BitmapsData.Add(M33draw(i,j))
gv.BitmapsData.Add(M33drawb(i,j))
Next
Next
For i=0 To 3
For j=0 To 3
gv.BitmapsData.Add(M44draw(i,j))
gv.BitmapsData.Add(M44drawb(i,j))
Next
Next
For i=0 To 2
gv.BitmapsData.Add(lifes(i))
Next
gv.BitmapsData.Add(checkdraw)
gv.BitmapsData.Add(levelicon)
gv.BitmapsData.Add(recordicon)
For i=0 To 4
gv.BitmapsData.Add(Msumadraw(i))
Next
For i=0 To 4
gv.BitmapsData.Add(Mtimeaddraw(i))
Next
If gv.IsHardwareAccelerated = False Then
Msgbox("Hardware acceleration is not supported!!!", "")
End If
Activity.LoadLayout("game31")
playagain=0
x=Activity.Width/100.0
y=Activity.Height/100.0
ho=(Activity.Height-50.0+104.0*x*2.0)*0.32
If (language="EN") Then
a=0.18
puntuacion.Bitmap=IU.LoadScaledBitmap(File.DirAssets,"score_330x110.png",330*a*x,110*a*x,True)
ImageView3.Bitmap=LoadBitmapSample(File.DirAssets,"start_410x150.png",Activity.Width,Activity.Height)
ImageView6.Bitmap=LoadBitmapSample(File.DirAssets,"Pausepanel_620x590.png",Activity.Width,Activity.Height)
a=0.16
tittle.Bitmap= IU.LoadScaledBitmap(File.DirAssets,"theyareequal_320x40.png",320*a*x,40*a*x,True)
fondowhite.Bitmap=IU.LoadScaledBitmap(File.DirAssets,"gameoverpanele_620x590.png",620*x*0.155,590*x*0.155,True)
End If
If (language="ES") Then
a=0.18
puntuacion.Bitmap=IU.LoadScaledBitmap(File.DirAssets,"puntuacion_330x110.png",330*a*x,110*a*x,True)
ImageView3.Bitmap=LoadBitmapSample(File.DirAssets,"empezar_410x150.png",Activity.Width,Activity.Height)
ImageView6.Bitmap=LoadBitmapSample(File.DirAssets,"Pausapanel_620x590.png",Activity.Width,Activity.Height)
a=0.16
tittle.Bitmap= IU.LoadScaledBitmap(File.DirAssets,"soniguales_320x40.png",320*a*x,40*a*x,True)
fondowhite.Bitmap=IU.LoadScaledBitmap(File.DirAssets,"gameoverpanels_620x590.png",620*x*0.155,590*x*0.155,True)
End If
......
This is a community forum. You should not limit your questions to a single member.Good afternoon Erel,
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?