Y yhyzhj Member Apr 9, 2021 #1 I want to know how to save a imageview.bakcground to file. And I want to know how to save a icon of app to file. pleae help me!
I want to know how to save a imageview.bakcground to file. And I want to know how to save a icon of app to file. pleae help me!
kisoft Well-Known Member Licensed User Longtime User Apr 10, 2021 #2 Write exactly what you want to achieve and what you need such a solution for ... Maybe it can be solved in a different way ... Upvote 0
Write exactly what you want to achieve and what you need such a solution for ... Maybe it can be solved in a different way ...
Peter Simpson Expert Licensed User Longtime User Apr 10, 2021 #3 Try this, you can also use GetSafeDirDefaultExternal if you really want to... Attachments ImageView.zip ImageView.zip 18.1 KB · Views: 398 Upvote 0
TILogistic Expert Licensed User Longtime User Apr 10, 2021 #4 better to use B4XImageView multi platform B4X: Copy Sub Class_Globals Private xui As XUI Private B4XImageView1 As B4XImageView End Sub B4X: Copy 'Load Image B4XImageView1.Bitmap = xui.LoadBitmap(File.DirAssets, "img.jpg") B4XImageView1.ResizeMode = "NONE" 'or "FILL" B4XImageView1.Update 'Save to file SaveBitmapToFile(B4XImageView1.Bitmap, xui.DefaultFolder, "ImageView1.png") B4X: Copy Public Sub SaveBitmapToFile(Image As B4XBitmap, DirFolder As String, FileName As String) Dim Out As OutputStream Out = File.OpenOutput(DirFolder, FileName, False) Image.WriteToStream(Out, 100, "PNG") Out.Close End Sub Last edited: Apr 10, 2021 Upvote 0
better to use B4XImageView multi platform B4X: Copy Sub Class_Globals Private xui As XUI Private B4XImageView1 As B4XImageView End Sub B4X: Copy 'Load Image B4XImageView1.Bitmap = xui.LoadBitmap(File.DirAssets, "img.jpg") B4XImageView1.ResizeMode = "NONE" 'or "FILL" B4XImageView1.Update 'Save to file SaveBitmapToFile(B4XImageView1.Bitmap, xui.DefaultFolder, "ImageView1.png") B4X: Copy Public Sub SaveBitmapToFile(Image As B4XBitmap, DirFolder As String, FileName As String) Dim Out As OutputStream Out = File.OpenOutput(DirFolder, FileName, False) Image.WriteToStream(Out, 100, "PNG") Out.Close End Sub
TILogistic Expert Licensed User Longtime User Apr 10, 2021 #5 or ImageView SaveBitmapToFile(ImageView1.Background, xui.DefaultFolder, "ImageView1.png") Click to expand... Upvote 0
or ImageView SaveBitmapToFile(ImageView1.Background, xui.DefaultFolder, "ImageView1.png") Click to expand...
Y yhyzhj Member Apr 11, 2021 #6 oparra said: or ImageView Click to expand... B4X: Copy icon=pm.GetApplicationIcon(pkgn(i)) B4X: Copy ImageView1.Background=icon B4X: Copy SaveBitmapToFile(ImageView1.Background,xui.DefaultFolder,"iv1.png") show Error description: Undeclared variable 'savebitmaptofile' is used before it was assigned any value. Upvote 0
oparra said: or ImageView Click to expand... B4X: Copy icon=pm.GetApplicationIcon(pkgn(i)) B4X: Copy ImageView1.Background=icon B4X: Copy SaveBitmapToFile(ImageView1.Background,xui.DefaultFolder,"iv1.png") show Error description: Undeclared variable 'savebitmaptofile' is used before it was assigned any value.
Y yhyzhj Member Apr 11, 2021 #7 kisoft said: Write exactly what you want to achieve and what you need such a solution for ... Maybe it can be solved in a different way ... Click to expand... i just want to write a launcher app. i have got all icon of apps, now need put the icons into gridview. but I use GridView.AddImage("",icon.Bitmap), show dir can not be null. so, i think that must save the icons to files. then i can use GridView.AddImage(dir,imagefile). Upvote 0
kisoft said: Write exactly what you want to achieve and what you need such a solution for ... Maybe it can be solved in a different way ... Click to expand... i just want to write a launcher app. i have got all icon of apps, now need put the icons into gridview. but I use GridView.AddImage("",icon.Bitmap), show dir can not be null. so, i think that must save the icons to files. then i can use GridView.AddImage(dir,imagefile).
Y yhyzhj Member Apr 11, 2021 #8 Peter Simpson said: Try this, you can also use GetSafeDirDefaultExternal if you really want to... Click to expand... still show error: Error description: Unknown member: getbitmap Error occurred on line: 31 ImageView1.GetBitmap.WriteToStream(Out, 100, "JPEG") Word: getbitmap Upvote 0
Peter Simpson said: Try this, you can also use GetSafeDirDefaultExternal if you really want to... Click to expand... still show error: Error description: Unknown member: getbitmap Error occurred on line: 31 ImageView1.GetBitmap.WriteToStream(Out, 100, "JPEG") Word: getbitmap
TILogistic Expert Licensed User Longtime User Apr 11, 2021 #9 sample with BitmapDrawable and icon APP you APP Application.PackageName B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.SetBackgroundImage(icon.Bitmap) SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png") or B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.Background = icon SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png") Last edited: Apr 11, 2021 Upvote 0
sample with BitmapDrawable and icon APP you APP Application.PackageName B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.SetBackgroundImage(icon.Bitmap) SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png") or B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.Background = icon SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png")
Y yhyzhj Member Apr 12, 2021 #10 oparra said: sample with BitmapDrawable and icon APP you APP Application.PackageName B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.SetBackgroundImage(icon.Bitmap) SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png") or B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.Background = icon SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png") Click to expand... thank you! it works! if I want to add icons into GridView, how to do? Upvote 0
oparra said: sample with BitmapDrawable and icon APP you APP Application.PackageName B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.SetBackgroundImage(icon.Bitmap) SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png") or B4X: Copy Dim pm As PackageManager Dim icon As BitmapDrawable = pm.GetApplicationIcon(Application.PackageName) ImageView1.Background = icon SaveBitmapToFile(ImageView1.Bitmap, xui.DefaultFolder, "myicon.png") Click to expand... thank you! it works! if I want to add icons into GridView, how to do?