hi all
I tried to make one option one user click the button it should rotate the image 90 every time user click the button here is my code :
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim img_box As ImageView
Dim btn_rotate As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btn_rotate_click(bmp As Bitmap)
If bmp.width>bmp.height Then 'Image is landscape, rotate
Dim rbmp As RSImageProcessing
img_box=rbmp.rotateBitmap(bmp, -90)
End If
End Sub
what is the the error here (img_box=rbmp.rotateBitmap(bmp, -90) ?
it show me unknown variable or unknown member: rotateBitmap
What is error means does that mean i can not use rotatebitmap in button if it is what is the code I have to use to rotate image by clicking on button ?
Sub rotate_click(bmp As Bitmap)
Dim rbmp As RSImageProcessing
If bmp.width>bmp.height Then 'Image is landscape, rotate
image_view=rbmp.rotate(bmp,-90)
End If
End Sub
Sub btn_rotate_click(bmp As Bitmap)
If bmp.width>bmp.height Then
'Image is landscape, rotate
Dim rbmp As RSImageProcessing
img_box=rbmp.rotateBitmap(bmp, -90)
EndIf
End Sub
The Signature of a click event does not have an Bitmap as parameter!? Where do you got this sub from?
I tried to fix the error but I couldnt ? It show me the signature of clcik event dosent support which I am writing it should first initialize the bitmap I dont know how to do that . do you have any comment to push me up ?
From Post#1 I do not see where you are loading the image into the imageview. What is in Layout#1?
I can only assume:
An imageview called img_box
A button called btn_rotate
Is there anything else? Do you load the image via designer?
Then you could try (not tested):
B4X:
Sub rotate_click
Dim rbmp As RSImageProcessing
Dim bmp as Bitmap
bd.Initialize(directory, Imagefilename) 'load and initalise the bitmap
If bmp.width>bmp.height Then 'Image is landscape, rotate
bmp = rbmp.Rotate(bmp, -90)
'Re-size the imageview to bitmap if required
image_view.width=bmp.width
image_view.height=bmp.height
image_view.Bitmap=bmp 'Put bitmap into imageview
End If
End Sub
Maybe it can be simplier but its worth a try. Hope it helps.
The code I posted will only rotate the bitmap once, from landscape to portrait due to the if statement. I think you are looking at something like this [not tested]:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim img_box As ImageView
Dim btn_rotate As Button
Dim rbmp As RSImageProcessing
Dim bmp as Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
if FirstTime then
bmp.Initialize(directory, Imagefilename) 'load and initialise the bitmap
end
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btn_rotate_click
bmp = rbmp.Rotate(bmp, -90)
'Re-size the imageview to bitmap if required
img_box.width=bmp.width
img_box.height=bmp.height
img_box.Bitmap=bmp 'Put bitmap into imageview
End Sub
I have tried your code but it still show me error, this is my code
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim img_box As ImageView
Dim btn_rotate As Button
Dim rbmp As RSImageProcessing
Dim bmp as Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
if FirstTime then
bmp.Initialize(File.DirInternal, "csa.jpg") 'load and initialise the bitmap
end
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btn_rotate_click
bmp = rbmp.Rotate(bmp, -90)
'Re-size the imageview to bitmap if required
img_box.width=bmp.width
img_box.height=bmp.height
img_box.Bitmap=bmp 'Put bitmap into imageview
End Sub