Android Question IU.Crop function

victormedranop

Well-Known Member
Licensed User
Longtime User
Hi, I try to use IU.Crop function, but I don't know the unit measure for using with an image.
I use gimp to check the margins and see where to crop.

B4X:
gameBackground(0) = IU.Crop(Backing,from_x,from_y,Crop_x,crop_y)

but crop_x and crop_y are related to the image. are in pixel, cm ,.....???

thanks,

Victor
 

victormedranop

Well-Known Member
Licensed User
Longtime User
UI id
B4X:
#Region  Project Attributes 
 #ApplicationLabel: B4A Example
 #VersionCode: 1
 #VersionName: Mymoney
 #SupportedOrientations: portrait
 #CanInstallToExternalStorage: True
#End Region
#Region  Activity Attributes 
 #FullScreen: False
 #IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
 Dim mySurface As AcceleratedSurface
 Dim gameBackground(2) As Bitmap
 Dim IU As AS_ImageUtils
 Private ImageView1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
 mySurface.Initialize("Surface",True)
 Dim Backing As Bitmap
 Backing = IU.LoadscaledBitmap(File.DirAssets, "__jet_pack_man_now_weapon_flying_die.png",-1,-1,True)
 
 gameBackground(0) = IU.Crop(Backing,0,0,860,599)
 gameBackground(1) = IU.Crop(Backing,960,0,899,599)
' gameBackground(2) = IU.Crop(Backing,1100,0,600,550)
' gameBackground(3) = IU.Crop(Backing,1650,0,600,550)
' gameBackground(4) = IU.Crop(Backing,2700,0,600,550)
' 
 Activity.LoadLayout("main")
 
 gameBackground(0) = IU.CreateScaledBitmap(gameBackground(0),100%x,80%y,True)
 gameBackground(1) = IU.CreateScaledBitmap(gameBackground(1),100%x,80%y,True)
' gameBackground(2) = IU.CreateScaledBitmap(gameBackground(2),100%x,80%y,True)
' gameBackground(3) = IU.CreateScaledBitmap(gameBackground(3),100%x,80%y,True)
' gameBackground(4) = IU.CreateScaledBitmap(gameBackground(4),100%x,80%y,True)
 
 For x = 0 To gameBackground.Length -1
  ImageView1.Bitmap = gameBackground(x)
  Sleep(1000)
 Next
 
 
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub ImageView1_Click
 
End Sub

I am using this image.
 

Attachments

  • __jet_pack_man_with_weapon_flying_die.png
    __jet_pack_man_with_weapon_flying_die.png
    209.4 KB · Views: 147
Last edited:
Upvote 0
Top