J js486dog Active Member Licensed User Longtime User Jul 11, 2020 #1 I have used the code below to open jpg image. There is no problem to open not large image. But I can not open (load into ImageView) large image (w:7800, h:7400). Please is there a way to load large image into ImageView with B4J ? My code: B4X: Copy Sub Process_Globals Private fx As JFX Private MainForm As Form Private Button1 As Button Dim directory, fileName As String Private ImageView1 As ImageView Private P_imag As Pane End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 MainForm.RootPane.LoadLayout("Layout1") MainForm.Show End Sub Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Sub Button1_Click Dim fc As FileChooser fc.Initialize fc.InitialDirectory = File.DirApp fc.SetExtensionFilter("Layouts",Array("*.jpg")) fc.Title = "photo" Dim f As String = fc.ShowOpen(MainForm) directory = File.GetFileParent(f) fileName = File.GetName(f) Dim bmp As Image = fx.LoadImage(directory,fileName) If f <> "" Then ImageView1.SetImage(bmp) ImageView1.SetSize(bmp.Width, bmp.Height) End If End Sub
I have used the code below to open jpg image. There is no problem to open not large image. But I can not open (load into ImageView) large image (w:7800, h:7400). Please is there a way to load large image into ImageView with B4J ? My code: B4X: Copy Sub Process_Globals Private fx As JFX Private MainForm As Form Private Button1 As Button Dim directory, fileName As String Private ImageView1 As ImageView Private P_imag As Pane End Sub Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 MainForm.RootPane.LoadLayout("Layout1") MainForm.Show End Sub Sub Application_Error (Error As Exception, StackTrace As String) As Boolean Return True End Sub Sub Button1_Click Dim fc As FileChooser fc.Initialize fc.InitialDirectory = File.DirApp fc.SetExtensionFilter("Layouts",Array("*.jpg")) fc.Title = "photo" Dim f As String = fc.ShowOpen(MainForm) directory = File.GetFileParent(f) fileName = File.GetName(f) Dim bmp As Image = fx.LoadImage(directory,fileName) If f <> "" Then ImageView1.SetImage(bmp) ImageView1.SetSize(bmp.Width, bmp.Height) End If End Sub
J js486dog Active Member Licensed User Longtime User Jul 11, 2020 #3 emexes said: perhaps this: View attachment 96955 Click to expand... Thanks for answer. This one works fine. Image is loaded into ImageView1. B4X: Copy Dim bmp As Image = fx.LoadImageSample(directory,fileName,300,200) But this one does not work. Image is not loaded into ImageView1. B4X: Copy Dim bmp As Image = fx.LoadImageSample(directory,fileName,7800,7400) Upvote 0
emexes said: perhaps this: View attachment 96955 Click to expand... Thanks for answer. This one works fine. Image is loaded into ImageView1. B4X: Copy Dim bmp As Image = fx.LoadImageSample(directory,fileName,300,200) But this one does not work. Image is not loaded into ImageView1. B4X: Copy Dim bmp As Image = fx.LoadImageSample(directory,fileName,7800,7400)
TILogistic Expert Licensed User Longtime User Jul 11, 2020 #4 Could it be what you are looking for? [B4X] ZoomImageView - Cross platform zoomable + pannable image view A custom view that shows an image and allows the user to zoom and pan the image. Instructions: - Add with designer. - Call SetBitmap. Updates: v1.06 - Fixes an issue with Android 15. v1.05 - Base_Resize is public. Call it after resizing the view in B4A. v1.04 - Fixes an issue in B4i where the... www.b4x.com Upvote 0
Could it be what you are looking for? [B4X] ZoomImageView - Cross platform zoomable + pannable image view A custom view that shows an image and allows the user to zoom and pan the image. Instructions: - Add with designer. - Call SetBitmap. Updates: v1.06 - Fixes an issue with Android 15. v1.05 - Base_Resize is public. Call it after resizing the view in B4A. v1.04 - Fixes an issue in B4i where the... www.b4x.com
E emexes Expert Licensed User Longtime User Jul 11, 2020 #6 I gave big images a go here, tried creating larger and larger ones until something broke: 18600 x 18600 x 24 bit color = at least 1,037,880,000 bytes, or perhaps one-third more if is RGBA. Then I looked to see if the Java heap could be made larger, and sure enough somebody suggested giving #VirtualMachineArgs a burl: so I did, and that was the last I heard from my computer for about 8 minutes. It sank to its knees and I was starting to worry. Anyway, when it blinked I managed to capture this: and then when it properly regained consciousness I had this: both of which suggest that the maximum object size, for the JVM on my machine at least, is limited by the maximum value of Java's default signed 32-bit Integer, so the maximum image size would be like 23000 RGBA pixels square. Last edited: Jul 11, 2020 Upvote 0
I gave big images a go here, tried creating larger and larger ones until something broke: 18600 x 18600 x 24 bit color = at least 1,037,880,000 bytes, or perhaps one-third more if is RGBA. Then I looked to see if the Java heap could be made larger, and sure enough somebody suggested giving #VirtualMachineArgs a burl: so I did, and that was the last I heard from my computer for about 8 minutes. It sank to its knees and I was starting to worry. Anyway, when it blinked I managed to capture this: and then when it properly regained consciousness I had this: both of which suggest that the maximum object size, for the JVM on my machine at least, is limited by the maximum value of Java's default signed 32-bit Integer, so the maximum image size would be like 23000 RGBA pixels square.
J js486dog Active Member Licensed User Longtime User Jul 11, 2020 #7 oparra said: Could it be what you are looking for? [B4X] ZoomImageView - Cross platform zoomable + pannable image view A custom view that shows an image and allows the user to zoom and pan the image. Instructions: - Add with designer. - Call SetBitmap. Updates: v1.06 - Fixes an issue with Android 15. v1.05 - Base_Resize is public. Call it after resizing the view in B4A. v1.04 - Fixes an issue in B4i where the... www.b4x.com Click to expand... Thank you very much for the answer. ZoomImageView is fine. I can work with large images, but I miss "EventData" (at least MouseMoved). Classic ImageView has "EventData" (MouseMoved, MouseDragged ...). B4X: Copy Sub ImageView1_MouseMoved (EventData As MouseEvent) L_xsur_pix = EventData.X L_ysur_pix = EventData.Y End Sub Upvote 0
oparra said: Could it be what you are looking for? [B4X] ZoomImageView - Cross platform zoomable + pannable image view A custom view that shows an image and allows the user to zoom and pan the image. Instructions: - Add with designer. - Call SetBitmap. Updates: v1.06 - Fixes an issue with Android 15. v1.05 - Base_Resize is public. Call it after resizing the view in B4A. v1.04 - Fixes an issue in B4i where the... www.b4x.com Click to expand... Thank you very much for the answer. ZoomImageView is fine. I can work with large images, but I miss "EventData" (at least MouseMoved). Classic ImageView has "EventData" (MouseMoved, MouseDragged ...). B4X: Copy Sub ImageView1_MouseMoved (EventData As MouseEvent) L_xsur_pix = EventData.X L_ysur_pix = EventData.Y End Sub
J js486dog Active Member Licensed User Longtime User Jul 11, 2020 #8 oparra said: or xui.LoadBitmapResize Click to expand... Thanks for the answer. As above. This works fine. bmp.Resize(400, 300, True) This does not work. bmp.Resize(7800, 7400, True) Upvote 0
oparra said: or xui.LoadBitmapResize Click to expand... Thanks for the answer. As above. This works fine. bmp.Resize(400, 300, True) This does not work. bmp.Resize(7800, 7400, True)
E emexes Expert Licensed User Longtime User Jul 11, 2020 #9 js486dog said: This does not work. bmp.Resize(7800, 7400, True) Click to expand... If you need to handle larger images outside of ZoomImageView, perhaps try increasing the Java heap size using #VirtualMachineArgs attribute: Use G for gigabytes or M for megabytes. Upvote 0
js486dog said: This does not work. bmp.Resize(7800, 7400, True) Click to expand... If you need to handle larger images outside of ZoomImageView, perhaps try increasing the Java heap size using #VirtualMachineArgs attribute: Use G for gigabytes or M for megabytes.
J js486dog Active Member Licensed User Longtime User Jul 11, 2020 #10 emexes said: If you need to handle larger images outside of ZoomImageView, perhaps try increasing the Java heap size using #VirtualMachineArgs attribute: View attachment 96968 Use G for gigabytes or M for megabytes. Click to expand... Thank you very much. B4X: Copy #VirtualMachineArgs: -Xms1024m -Xmx1024m is fine when I start app from B4J IDE. But after compilation jar to exe (Launch4j) still works only: bmp.Resize(400, 300, True) not bmp.Resize(7800, 7400, True) Upvote 0
emexes said: If you need to handle larger images outside of ZoomImageView, perhaps try increasing the Java heap size using #VirtualMachineArgs attribute: View attachment 96968 Use G for gigabytes or M for megabytes. Click to expand... Thank you very much. B4X: Copy #VirtualMachineArgs: -Xms1024m -Xmx1024m is fine when I start app from B4J IDE. But after compilation jar to exe (Launch4j) still works only: bmp.Resize(400, 300, True) not bmp.Resize(7800, 7400, True)
J js486dog Active Member Licensed User Longtime User Jul 11, 2020 #11 js486dog said: Thank you very much. B4X: Copy #VirtualMachineArgs: -Xms1024m -Xmx1024m is fine when I start app from B4J IDE. But after compilation jar to exe (Launch4j) still works only: bmp.Resize(400, 300, True) not bmp.Resize(7800, 7400, True) Click to expand... It seems here is the solution. Have to be set "heap size" in "Launch4j" to 1024 or another number. Now exe file works as B4J IDE - also with large image . Upvote 0
js486dog said: Thank you very much. B4X: Copy #VirtualMachineArgs: -Xms1024m -Xmx1024m is fine when I start app from B4J IDE. But after compilation jar to exe (Launch4j) still works only: bmp.Resize(400, 300, True) not bmp.Resize(7800, 7400, True) Click to expand... It seems here is the solution. Have to be set "heap size" in "Launch4j" to 1024 or another number. Now exe file works as B4J IDE - also with large image .