Is there a way of converting a bitmapdrawable to a bitmap.
I am trying to create a Image Scroll View with a list of images located in the DirDefaultExternal directory.
I want to rotate each bitmapdrawable 90 degrees before it is loaded as the background image view.
I was hoping to use the bitmapExtended Library to do this as i dont really understand the rotate bitmap tutorial when using a list that is created in the LoadImages method....:BangHead:
My code so far is:
I am trying to create a Image Scroll View with a list of images located in the DirDefaultExternal directory.
I want to rotate each bitmapdrawable 90 degrees before it is loaded as the background image view.
I was hoping to use the bitmapExtended Library to do this as i dont really understand the rotate bitmap tutorial when using a list that is created in the LoadImages method....:BangHead:
My code so far is:
B4X:
Sub Process_Globals
Dim Bitmaps As List
End Sub
Sub Globals
Dim scvPics As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then 'only load the images once.
ProgressDialogShow("Loading images")
LoadImages
ProgressDialogHide
End If
Activity.LoadLayout("Page4") 'load the layout file
scvPics.Panel.Height = 200dip * Bitmaps.Size 'Set the inner panel height according to the number of images.
For i = 0 To Bitmaps.Size - 1
Dim iv As ImageView 'create an ImageView for each bitmap
iv.Initialize("") 'not interested in any events so we pass empty string.
Dim bd As BitmapDrawable
bd.Initialize(Bitmaps.Get(i))
iv.Background = bd 'set the background of the image view.
'add the image view to the scroll bar internal panel.
scvPics.Panel.AddView(iv, 5dip, 5dip + i * 200dip, scvPics.Width - 10dip, 190dip)
Next
End Sub
Sub LoadImages
Bitmaps.Initialize
Dim files As List
Dim imagesFolder As String
imagesFolder = File.DirDefaultExternal
If File.Exists(imagesFolder, "") = False Then
ToastMessageShow("Images folder not found: " & CRLF & imagesFolder, True)
Return
End If
files = File.ListFiles(imagesFolder) 'get all files in this folder
For i = 0 To files.Size - 1
DoEvents 'required for the ProgressDialog animation
Dim f As String
f = files.Get(i)
If f.ToLowerCase.EndsWith(".jpg") Then
Dim b As Bitmap
b.InitializeSample(imagesFolder, f, 200dip, 200dip) 'load the jpeg file and subsample it if it is too large.
Bitmaps.Add(b) 'add the bitmap to the bitmaps list.
If Bitmaps.Size > 50 Then Exit 'limit it to 50 images
End If
Next
ToastMessageShow("Found " & Bitmaps.Size & " images", True)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Last edited by a moderator: