HS.Initialize (LargImg * 2, "HS")
IV1.Initialize ("")
IV2.Initialize ("")
IV1.Gravity = Gravity.FILL
IV2.Gravity = Gravity.Fill
Activity.AddView (HS, 0, 0, 100% x, y 100%)
BMP.Initialize (File.DirRootExternal, Main.FileName)
IV1.Bitmap = BMP
IV2.Bitmap = BMP
HS.Panel.AddView (IV1, 0.0, LargImg, 600)
HS.Panel.AddView (IV2, LargImg, 0, LargImg, 600)
Sub HS_ScrollChanged (Position As Int)
'--- Scroll right
If Position> * 1.5 Then LargImg
HS.ScrollPosition = LargImg / 2
else
'--- Left scroll
If Position <LargImg / 2 Then
HS.ScrollPosition LargImg * 1.5 =
end If
end If
end Sub
Sub Process_Globals
' create a process global for each map state to be saved and restored on orientation change
' use a GeoPoint object to save the map center
Dim MapCenter As GeoPoint
' an Int is all that's required to save the map zoom level
Dim ZoomLevel As Int
End Sub
Sub Globals
Dim MapView1 As MapView
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Dim OfflineTileCacheFilename, TileCacheDir As String
OfflineTileCacheFilename="panorama.zip"
TileCacheDir=File.DirRootExternal&"/osmdroid"
' check if the offline tile cache has already been copied to the OSMDroid cache folder
If File.Exists(TileCacheDir, OfflineTileCacheFilename)=False Then
' copy the offline tile cache to the OSMDroid cache folder
File.MakeDir(File.DirRootExternal, "osmdroid")
File.Copy(File.DirAssets, OfflineTileCacheFilename, TileCacheDir, OfflineTileCacheFilename)
End If
End If
MapView1.Initialize("")
MapView1.SetDataConnectionEnabled(False)
MapView1.SetMultiTouchEnabled(True)
MapView1.SetTileSource("Panorama")
MapView1.SetZoomEnabled(True)
Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
If FirstTime Then
' set the default initial map center and zoom level
MapCenter.Initialize(0, 0)
ZoomLevel=3
End If
MapView1.Zoom=ZoomLevel
MapView1.SetCenter3(MapCenter)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
' save the current map zoom level and center
MapCenter=MapView1.GetCenter
ZoomLevel=MapView1.Zoom
End Sub
HS.ScrollPosition = LargImg / 2
If Position > LargImg*1.5 Then
HS.ScrollPosition = LargImg / 2
end If
g.drawImage(pano, -v, 0, this); //disegna applet da pixel 0
if (v > (panow - applw)) {
g.drawImage(pano, panow - v, 0, this); //disegna seconda parte
}
Hi Warwound
Your library OSMDroid can not be used to display the views I have.
They are more than just JPG images. They have a lot of information in the EXIF data that display the labels with the names of the peaks.
In other words my jpg files CAN NOT be broken ("Cut your panoramic image into tiles").
I enclose a screenshot of my app is already running. Has only two problems (scroll and consumer-resources) reported.
Thank you for your interest.
Surely if you would Warwound will give me some suggestions to improve the horizontal scroll, that is its main flaw.
public void displayRedraw(Graphics g)
{
g.drawImage(vrImage,panPosition,0,this);
if (fullPanorama==1)
{
if (panPosition<(imageWidth-displayWidth)) g.drawImage(vrImage,panPosition+imageWidth,0,this);
if (panPosition>0) g.drawImage(vrImage,panPosition-imageWidth,0,this);
}
}
The competent and courteous Warwound ?
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim Bitmap1 As Bitmap
Dim Canvas1 As Canvas
Dim Gestures1 As Gestures
Dim Panel1 As Panel
Dim SrcRect, DestRect, SrcWrapRect, DestWrapRect As Rect
Dim TouchInProgress As Boolean
Dim LastX, LastY As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
Panel1.Initialize("")
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)
Gestures1.SetOnTouchListener(Panel1, "HandleTouch")
TouchInProgress=False
Bitmap1.Initialize(File.DirAssets, "aiera.jpg")
Canvas1.Initialize(Panel1)
SrcRect.Initialize(0, 0, Panel1.Width, Panel1.Height)
DestRect.Initialize(0, 0, Panel1.Width, Panel1.Height)
Canvas1.DrawBitmap(Bitmap1, SrcRect, DestRect)
Panel1.Invalidate
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub HandleTouch(Object1 As Object, PointerId As Int, Action As Int, X As Float, Y As Float) As Boolean
Select Action
Case Gestures1.ACTION_DOWN
If TouchInProgress=False Then
LastX=X
LastY=Y
TouchInProgress=True
End If
Case Gestures1.ACTION_MOVE
Dim MoveX, MoveY As Int
MoveX=LastX-X
MoveY=LastY-Y
SrcRect.Left=SrcRect.Left+MoveX
' SrcRect.Top=SrcRect.Top+MoveY
SrcRect.Right=SrcRect.Right+MoveX
' SrcRect.Bottom=SrcRect.Bottom+MoveY
Log(SrcRect)
Canvas1.DrawBitmap(Bitmap1, SrcRect, DestRect)
If SrcRect.Left<0 Then
' need to draw the right hand edge of the image to the left hand edge of the panel
SrcWrapRect.Initialize(Bitmap1.Width+SrcRect.Left, 0, Bitmap1.Width, Bitmap1.Height)
DestWrapRect.Initialize(0, 0, Abs(SrcRect.Left), Bitmap1.Height)
Canvas1.DrawBitmap(Bitmap1, SrcWrapRect, DestWrapRect)
' normalise SrcRect
SrcRect.Left=SrcRect.Left+Bitmap1.Width
SrcRect.Right=SrcRect.Right+Bitmap1.Width
Else
If SrcRect.Right>Bitmap1.Width Then
' need to draw the left hand edge of the image to the right hand edge of the panel
SrcWrapRect.Initialize(0, 0, SrcRect.Right-Bitmap1.Width, Bitmap1.Height)
DestWrapRect.Initialize(Panel1.Width-SrcWrapRect.Right, 0, Panel1.Width, Bitmap1.Height)
Canvas1.DrawBitmap(Bitmap1, SrcWrapRect, DestWrapRect)
' normalise SrcRect
SrcRect.Left=SrcRect.Left-Bitmap1.Width
SrcRect.Right=SrcRect.Right-Bitmap1.Width
End If
End If
LastX=X
LastY=Y
Panel1.Invalidate
Case Gestures1.ACTION_UP
TouchInProgress=False
End Select
Return True
End Sub
'Activity module
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 Bitmap1 As Bitmap
Dim Canvas1 As Canvas
Dim CurrentX, CurrentY, LastX, LastY As Int
Dim DestRect, SrcRect As Rect
Dim Gestures1 As Gestures
Dim Panel1 As Panel
Dim TouchInProgress As Boolean
End Sub
Sub Activity_Create(FirstTime As Boolean)
CurrentX=0
CurrentY=0
TouchInProgress=False
Panel1.Initialize("")
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)
Canvas1.Initialize(Panel1)
Bitmap1.Initialize(File.DirAssets, "aiera.jpg")
DestRect.Initialize(CurrentX, CurrentY, Bitmap1.Width-CurrentX, Bitmap1.Height-CurrentY)
SrcRect.Initialize(0, 0, Bitmap1.Width, Bitmap1.Height)
Gestures1.SetOnTouchListener(Panel1, "HandleTouch")
' draw the image for the first time with no movement in X or Y direction
DrawBitmap(0, 0)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
' free up resources used by the panorama image
Dim Reflector1 As Reflector
Reflector1.Target=Bitmap1
Reflector1.RunMethod("recycle")
End Sub
Sub HandleTouch(Object1 As Object, PointerId As Int, Action As Int, X As Float, Y As Float) As Boolean
Select Action
Case Gestures1.ACTION_DOWN
If TouchInProgress=False Then
LastX=X
LastY=Y
TouchInProgress=True
End If
Case Gestures1.ACTION_MOVE
Dim MoveX, MoveY As Int
MoveX=LastX-X
MoveY=LastY-Y
' only update display if image is dragged more then 10 pixels
' without this check in place even a single tap on the screen is likely to be interpreted as a small drag to to hardware inaccuracies
' choose a value that's large enough to prevent a single tap being interpreted as a small drag but small enough to make a real drag smooth
' as long as you choose a value that is less than Bitmap1.Width everything will work ok
If MoveX>=10 OR MoveX<=-10 OR MoveY>=10 OR MoveY<=-10 Then
DrawBitmap(MoveX, MoveY)
LastX=X
LastY=Y
End If
Case Gestures1.ACTION_UP
TouchInProgress=False
End Select
Return True
End Sub
Sub DrawBitmap(MoveX As Int, MoveY As Int)
Dim i As Int
CurrentX=CurrentX-MoveX
CurrentY=CurrentY-MoveY
' normalise CurrentX if wrapping has occurred
If CurrentX>0 Then
CurrentX=CurrentX-Bitmap1.Width
Else If CurrentX<-(Bitmap1.Width) Then
CurrentX=CurrentX+Bitmap1.Width
End If
' normalise CurrentY to keep Bitmap1 from dragging too far up or down
' this will fail if Bitmap1.Height<Panel1.Height
' (with aiera.jpg that will happen in portrait mode with a 800x480 screen)
If CurrentY>0 Then
CurrentY=0
Else If Abs(CurrentY)>Bitmap1.Height-Panel1.Height Then
CurrentY=-(Bitmap1.Height-Panel1.Height)
End If
For i=CurrentX To Panel1.Width Step Bitmap1.Width
DestRect.Left=i
DestRect.Right=i+Bitmap1.Width
DestRect.Top=CurrentY
DestRect.Bottom=CurrentY+Bitmap1.Height
Canvas1.DrawBitmap(Bitmap1, SrcRect, DestRect)
Next
' force the panel to redraw itself
Panel1.Invalidate
End Sub
For i = CurrentX To Step Panel1.Width Bitmap1.Width
DestRect.Left = i
DestRect.Right = i + Bitmap1.Width
DestRect.Top = CurrentY
DestRect.Bottom = + CurrentY Bitmap1.Height
Canvas1.DrawBitmap (Bitmap1, srcRect, destRect)
Log ("DrawBitmap")
Next
' Activity module WrappingImageViewer
' requires Gestures and Reflection libraries
Sub Process_Globals
End Sub
Sub Globals
Dim Bitmap1 As Bitmap
Dim Canvas1 As Canvas
Dim CurrentPointerId, CurrentX, CurrentY, LastX, LastY, MinDragMove As Int
Dim DestRect, SrcRect As Rect
Dim Gestures1 As Gestures
Dim Panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
CurrentPointerId=-1
CurrentX=0
CurrentY=0
MinDragMove=10
Panel1.Initialize("")
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)
Canvas1.Initialize(Panel1)
Bitmap1.Initialize(File.DirAssets, "brain.jpg")
DestRect.Initialize(CurrentX, CurrentY, Bitmap1.Width-CurrentX, Bitmap1.Height-CurrentY)
SrcRect.Initialize(0, 0, Bitmap1.Width, Bitmap1.Height)
Gestures1.SetOnTouchListener(Panel1, "Handle_Touch")
' draw the image for the first time with no movement in X or Y direction
DrawBitmap(0, 0)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
' free up resources used by Bitmap1
Dim Reflector1 As Reflector
Reflector1.Target=Bitmap1
Reflector1.RunMethod("recycle")
End Sub
Sub Handle_Touch(Object1 As Object, PointerId As Int, Action As Int, X As Float, Y As Float) As Boolean
' the first touch on Panel1 will be handled, touches after that first touch will be discarded
Select Action
Case Gestures1.ACTION_DOWN
If CurrentPointerId=-1 Then
LastX=X
LastY=Y
CurrentPointerId=PointerId
End If
Case Gestures1.ACTION_MOVE
If CurrentPointerId=PointerId Then
Dim MoveX, MoveY As Int
MoveX=LastX-X
MoveY=LastY-Y
' only update display if image is dragged more then MinDragMove pixels
' without this check in place even a single tap on the screen is likely to be interpreted as a small drag to to hardware inaccuracies
' choose a value that's large enough to prevent a single tap being interpreted as a small drag but small enough to make a real drag smooth
' as long as you choose a value that is less than Bitmap1.Width everything will work ok
If MoveX>=MinDragMove OR MoveX<=-(MinDragMove) OR MoveY>=MinDragMove OR MoveY<=-(MinDragMove) Then
DrawBitmap(MoveX, MoveY)
LastX=X
LastY=Y
End If
End If
Case Gestures1.ACTION_UP
If CurrentPointerId=PointerId Then
CurrentPointerId=-1
End If
End Select
Return True
End Sub
Sub DrawBitmap(MoveX As Int, MoveY As Int)
Dim X As Int
CurrentX=CurrentX-MoveX
CurrentY=CurrentY-MoveY
' normalise CurrentX if wrapping has occurred
' this will fail if MoveX>Bitmap1.Width
If CurrentX>0 Then
CurrentX=CurrentX-Bitmap1.Width
Else If CurrentX<-(Bitmap1.Width) Then
CurrentX=CurrentX+Bitmap1.Width
End If
' normalise CurrentY
If CurrentY>0 Then
' do not allow the Bitmap1 top edge to be dragged down from the top of Panel1
CurrentY=0
Else If Bitmap1.Height<Panel1.Height Then
' do not allow vertical dragging
CurrentY=0
Else If Abs(CurrentY)>Bitmap1.Height-Panel1.Height Then
' do not allow the Bitmap1 bottom edge to be dragged down from the bottom of Panel1
CurrentY=-(Bitmap1.Height-Panel1.Height)
End If
' draw Bitmap1 repeatedly on Panel1 from CurrentX, CurrentY until Panel1 is fully covered by Bitmap1
For X=CurrentX To Panel1.Width Step Bitmap1.Width
DestRect.Left=X
DestRect.Right=X+Bitmap1.Width
DestRect.Top=CurrentY
DestRect.Bottom=CurrentY+Bitmap1.Height
Canvas1.DrawBitmap(Bitmap1, SrcRect, DestRect)
Next
' force the panel to redraw itself
Panel1.Invalidate
End Sub
Sub ScrollLblPeak (X As Int, Y As Int)
Dim I As Int
'--- Scroll X
For I=0 To TotID-1
Linea(I).Left=Linea(I).Left - X
LblPeak(I).Left=LblPeak(I).Left - X
If Linea(I).Left>intLargImg Then Linea(I).Left=Linea(I).Left-intLargImg
If LblPeak(I).Left>intLargImg Then LblPeak(I).Left=LblPeak(I).Left-intLargImg
If Linea(I).Left<0 Then Linea(I).Left=Linea(I).Left+intLargImg
If LblPeak(I).Left<0 Then LblPeak(I).Left=LblPeak(I).Left+intLargImg
Next
'--- Scroll Y
' If ...
For I=0 To TotID-1
Linea(I).top=Linea(I).Top - Y
LblPeak(I).top=LblPeak(I).Top - Y
Next
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?