Hi i'm trying to add image cache for an custom control that i made and share here as XUIImageBottom and can't find the reason why its save the full image instead the resize ones.
I'm implemented the cache using this code:
I currently use a lot this control, and wish boost the load time implementing image caching.
I'm implemented the cache using this code:
B4X:
'inizialize and load the icon object
imgIcon = CreateImageView("imgIcon")
If ImageFileName <> "" Then
imgIcon.Height = cmdButton.Height-Margin*2
imgIcon.Width = cmdButton.Height-Margin*2
'if cache is true we atempt to use the cache
Dim image As B4XBitmap
If vCacheImage = True Then
Try
image = objXUI.LoadBitmap(objXUI.DefaultFolder,"cache_"&ControlName&ImageFileName)
imgIcon.SetBitmap(image) 'fit on the box
Catch
Dim out As OutputStream
out = File.OpenOutput(objXUI.DefaultFolder,"cache_"&ControlName&ImageFileName, False)
image = objXUI.LoadBitmapResize(File.DirAssets,ImageFileName,imgIcon.Width, imgIcon.Height, True)
image.WriteToStream(out,100,"PNG")
out.Close
imgIcon.SetBitmap(image)
End Try
Else
image = objXUI.LoadBitmapResize(File.DirAssets,ImageFileName,imgIcon.Width, imgIcon.Height, True)
imgIcon.SetBitmap(image) 'fit on the box
End If
Else
imgIcon.Height = 0
imgIcon.Width = 0
End If
I currently use a lot this control, and wish boost the load time implementing image caching.