B4J Library [B4X] jPictureBox (image rotate & zoom / movie resize)

Hello all;

This is as image and basic movie viewer. it can enlarge or reduce the size of the pictures and movies. It can rotate only pictures to the right or left. You can also make full screen.The Contex menu is available in the menu itself, but you can add your own.

I added an example; its very simple and clear.



Release 2.14:
  • some bugs fixed
Release 2.0:
  • basic control video : zoom
  • adding video method
  • adding media method
  • max/min ratio limits added
  • some bugs fixed
  • icon sets declared


jPictureBox
Author:
Tayfur
Version: 2.0
  • jPictureBox
    Methods:
    • Initialize (Callback As Object, EventName As String) As
    • Initialize2 (Main_Form As Form, Callback As Object, EventName As String, ContextMenuN As Map, ContextMenuFS As Map) As
      visible : sets whether the jpicturebox initialize
      jPicturebox1.Initialize2(Mainform1,Me,"jPicturebox1",Null,Null )
    • Show As
    • ShowFullScreen As
      Open fullscreen form
      jPicturebox1.ShowFullScreen
    • ClearAll As
      clear all pictures
      jPicturebox1.ClearAll
    • GetBase As
    • addPictureAll (FolderName As String) As
      auto loading pictres for in folders
      clear all pictures
      jPicturebox1.addPictureAll("c:\pictures")
    • addMedia (Folder As String, Filename As String) As Boolean
      adding a picture
      type : flv / mp4 / vp6 / bmp, png, jpg
      jPicturebox1.addPicture("c:\pictures","image.png")
    • addMovie (Folder As String, Filename As String) As Boolean
      adding a picture
      type : flv / mp4 ... etc java sup. types
      jPicturebox1.addPicture("c:\pictures","youtube.mp4")
    • addPicture (Folder As String, Filename As String) As Boolean
      adding a picture
      type : bmp / jpg /png
      jPicturebox1.addPicture("c:\pictures","image.png")
    • Fit_in_Page As
      fit picture into frame
      jPicturebox1.Fit_in_Page
    Properties:
    • PictureIndex As
      it set/get active image index
      jPictureBox1.PictureIndex=1
    • Context_Menu As [read only]
      This add context menü
      Map value must be C_Menu
      Dim m As Map
      m.Initialize
      Dim z As C_Menu
      z.Initialize
      z.Enable=True
      z.imageFolder=File.DirAssets
      z.imageName="zoom-in.png"
      z.Text="+25%"
      z.CM_Type=CM_Type_Incremental
      z.CM_Rate=0.25
      m.Put(z.Text,z)
      jPicturebox1.Context_Menu=m
    • FSContext_Menu As [read only]
      This add context menü for FULL SIZE
      Map value must be C_Menu
      Dim m As Map
      m.Initialize
      Dim z As C_Menu
      z.Initialize
      z.Enable=True
      z.imageFolder=File.DirAssets
      z.imageName="zoom-in.png"
      z.Text="+25%"
      z.CM_Type=CM_Type_Incremental
      z.CM_Rate=0.25
      m.Put(z.Text,z)
      jPicturebox1.Context_Menu=m
    • Color As
      change background color
      Jpicturebox1.Color=(fx.Colors.Green)
    • Tag As
      tag values set /get object
      Jpicturebox1.tag="test tag"
    • RotateImage As
      it changene image directions
      it must be 0,90,180,270 degree
      set/get intger values for angel
      Jpicturebox1.RotateImage=90
    • Visible As
      visible : gets/sets whether the jpicturebox visible
      Jpicturebox1.visible=False
    • Label_Background_Color_True As
      Labels of indicator backgraound color setting for active
      Jpicturebox1.Label_Background_Color_T=fx.Colors.Blue
    • Label_Background_Color_N As
      Labels of indicator backgraound color setting for normal
      Jpicturebox1.Label_Background_Color_N=fx.Colors.yellow
    • Label_Background_Color_F As
      Labels of indicator backgraound color setting for passive
      Jpicturebox1.Label_Background_Color_F=fx.Colors.gray
    • Enabled As
    • Full_Size_Form As [read only]
      get form for full size node
      dim f as form
      Jpicturebox1.Full_Size_Form

      **** Control types******
      Dim z As C_Menu
      z.CM_Type=CM_Type_Incremental 'its for control type
    • CM_Type_Absolite As [read only]
      this method can absolite resize. it must be use with double value on CM_Rate : 10% = 0.1 ;250%=2.5
    • CM_Type_Incremental As [read only]
      this method can incremental resize. it must be use with double value on CM_Rate: 10% = 0.1 ;250%=2.5
    • CM_Type_Function As [read only]
      this method use for specila function on Context Menu
      you can use ready functions on CM_Rate like under below, or you can create own method.
      **** Standart rate and special fonksion types******
    • CM_Rate_Close As [read only]
      ts close form on fullscreen mode
    • CM_Rate_FullScreen As [read only]
      ts open full form on normal mode
    • CM_Rate_Rotate_CW As [read only]
      this method returns right
    • CM_Rate_Rotate_CCW As [read only]
      this method returns left
    • CM_Rate_Original_Size As [read only]
      this method resized like org. size
    • CM_Rate_Fit_Page As [read only]
      this method risez acording to main panel
      **** Standart icon set is ready in lib. like under below******
    • Icon_exit As [read only]
    • Icon_fit_size As [read only]
    • Icon_fullscreen As [read only]
    • Icon_original_size As [read only]
    • Icon_resize_in As [read only]
    • Icon_resize_out As [read only]
    • Icon_rotate_left As [read only]
    • Icon_rotate_right As [read only]
    • Icon_zoom_in As [read only]
    • Icon_zoom_out As [read only]
    • Icon_play As [read only]
    • Icon_pause As [read only]
    • Icon_Folder As [read only]
      this value is folder name for icons set in lib.
      log(jPictureBox1.Icon_Folder)

    • Action_Click_Count As
      click count for indicator mouse event accept
      jPictureBox1.Action_Click_Count=1
    • MaxRatio As
      this value is max limit for zoom.Exp: 500% org.size
      jPictureBox1.MaxRatio=5
    • MinRatio As
      this value is min limit for zoom. Exp: 10% org.size
      jPictureBox1.MinRatio=0.1
    • isFullScreen As [read only]
      this value is cheking full screen mode
      log(jPictureBox1.isFullScreen)

[*]jPFS
Methods: NOT USE!!!
 

Attachments

  • test_example_jPicturebox2.zip
    291.2 KB · Views: 815
  • jPictureBox.b4xlib
    23.6 KB · Views: 750
Last edited:

Tayfur

Well-Known Member
Licensed User
Longtime User

Peter Meares

Member
Licensed User
Longtime User
Nice. I will study the right click function which was something I wanted to do.
I realise it is a demo, but the Left and Right image buttons only go one way.
Thanks for sharing.
 

Tayfur

Well-Known Member
Licensed User
Longtime User
Nice. I will study the right click function which was something I wanted to do.
I realise it is a demo, but the Left and Right image buttons only go one way.
Thanks for sharing.

Thank you @Peter Meares ;
My lib has a bug. it's default value of rotate left &right is same.
For you, quick solution is you can load by manuel context menu .
Sample sub is :
B4X:
private Sub Context_Menu_load
'.....
I uploaded new sample. See #1 article.


And You can try directly like under below

B4X:
 z.Text="Rotate Left"
    z.CM_Type=jPictureBox1.CM_Type_Function
    z.CM_Rate=jPictureBox1.CM_Rate_Rotate_CCW


  z.Text="Rotate Right"
    z.CM_Type=jPictureBox1.CM_Type_Function
    z.CM_Rate=jPictureBox1.CM_Rate_Rotate_CW


in this week; I will release new version, I will fixed bug and it has video support.
 

Tayfur

Well-Known Member
Licensed User
Longtime User
Hello all;

UPDATE 2.0

Now its support MOVIE

This is as image and basic movie viewer. it can enlarge or reduce the size of the pictures and movies. It can rotate only pictures to the right or left. You can also make full screen.The Contex menu is available in the menu itself, but you can add your own.

I added an new example; its very simple and clear.


News 2.0:
  • basic control video : zoom
  • adding video method
  • adding media method
  • max/min ratio limits added
  • some bugs fixed
  • icon sets declared
for more info please see article #1
 

rboeck

Well-Known Member
Licensed User
Longtime User
@Tayfur
Hi,
first of all, thanks for your library! Currently i try to find out, if i can use it for my needs. So i come to my first problem: i want to translate the context menus. I tried to find out with your sample; you have used "PRINTER" and "PRINT" in Context_Menu_load, but i never find this words in any context menu. For me, i see always the same menus. What to i make wrong?
 

T201016

Active Member
Licensed User
Longtime User
@Tayfur
Hi,
I see interesting solutions in the library. Is it possible to add a new one to the library?
method: addPicture from ImageView ?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…