Android Question How to scroll a picture in a loop?

OlavRossland

Member
Licensed User
Longtime User
I want to horizontally scroll an image (EKG.jpg) of an ECG (Electrocardiodiagram) in a loop, but how?
 

Beja

Expert
Licensed User
Longtime User
Use a timer with the scrolling speed you wish
Start the image left property with the container width
Then reduce the left property with the step you wish
When image left is < -image width (negative of the width) then start over.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Yes, it is a static ECG image to scroll non-stop across the screen (restart when it reaches the end)

Surely, there are many methods.

Assuming that the scroll goes from right to left, copying a vertical "slice" which is located to the right of the image (eg minimum 1px width) in a memory area, moves the remaining area of the image (from 0 up to width-1px) and re-set the "slice" on the left (sorry but I do not know how to explain in brief and in English).

I believe that to achieve this, you should use the Canvas, but surely there is something ready, you can use Search :)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
I can hardly imagine a true oscilloscope display effect of a free-running cardiograph, without the use of a timer.
What I understood is that he is using a static image (the cardiogram) which was saved previously from a real-time
cardiograph. So the main point and purpose of all this is to simulate the real-time flow of cardiograph. this means
the picture must be running freely without touching the screen or anything.
My previous suggestion involved a picture of the graph, but a single picture will, yes, run until completely disappears,
and then starts from the right side again.. of course this has nothing to do with real world cardiograph.. to solve this
problem and show the wave continuously, another identical image is used.. and the same timer event, the left property
of the second image must = to the left + width properties of the first image, so it can show like it is stitched to it..
And then by one single trick we can stitch the left property of the first image to follow the second image... I think
this is where real test must begin because theory only can not cover everything.
 
Upvote 0

OlavRossland

Member
Licensed User
Longtime User
I can hardly imagine a true oscilloscope display effect of a free-running cardiograph, without the use of a timer.
What I understood is that he is using a static image (the cardiogram) which was saved previously from a real-time
cardiograph. So the main point and purpose of all this is to simulate the real-time flow of cardiograph. this means
the picture must be running freely without touching the screen or anything.
My previous suggestion involved a picture of the graph, but a single picture will, yes, run until completely disappears,
and then starts from the right side again.. of course this has nothing to do with real world cardiograph.. to solve this
problem and show the wave continuously, another identical image is used.. and the same timer event, the left property
of the second image must = to the left + width properties of the first image, so it can show like it is stitched to it..
And then by one single trick we can stitch the left property of the first image to follow the second image... I think
this is where real test must begin because theory only can not cover everything.

You understand what I want Beja. I have been on the same idea in how to solve this. I'll make an effort, then I give a feedback. Thank you for your response.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
The link i posted shows code that will scroll an image in a loop - wrapping the left or right edges for seamless scrolling.
You'd have to remove all the touch detection code and replace it with code that runs on a Timer Tick event...

Martin.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
The link i posted shows code that will scroll an image in a loop - wrapping the left or right edges for seamless scrolling.
You'd have to remove all the touch detection code and replace it with code that runs on a Timer Tick event...

Martin,
You did a great job that my suggestion is nothing compared to it.. may be the idea of simulation of real-time
cartography was not clear... it is very easy to replace touch events with a timer to automate the scrolling, moreover,
the touch also is needed for different apps.
Your solution is more intuitive.. all thumps up!
 
Upvote 0

OlavRossland

Member
Licensed User
Longtime User
This is how I did it, and the result was a seamless scrolling of the EKG picture from right to left.

Sub Settings_EKG
ImageViewEKG1.Bitmap=LoadBitmap(File.DirAssets,"sr001.jpg")
ImageViewEKG2.Bitmap=LoadBitmap(File.DirAssets,"sr001.jpg")
a=0
b=400
ImageViewEKG1.Left=a
ImageViewEKG2.Left=b

timer_EKGloop.Initialize("timer_EKGloop", 25)
timer_EKGloop.Enabled = True​
End Sub

Sub timer_EKGloop_tick
If a=-400 Then a=400
ImageViewEKG1.Left=a
a=a-5

If b=-400 Then b=400
ImageViewEKG2.Left=b
b=b-5​
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
This is how I did it, and the result was a seamless scrolling of the EKG picture from right to left.

Sub Settings_EKG
ImageViewEKG1.Bitmap=LoadBitmap(File.DirAssets,"sr001.jpg")
ImageViewEKG2.Bitmap=LoadBitmap(File.DirAssets,"sr001.jpg")
a=0
b=400
ImageViewEKG1.Left=a
ImageViewEKG2.Left=b

timer_EKGloop.Initialize("timer_EKGloop", 25)
timer_EKGloop.Enabled = True
End Sub

Sub timer_EKGloop_tick
If a=-400 Then a=400
ImageViewEKG1.Left=a
a=a-5

If b=-400 Then b=400
ImageViewEKG2.Left=b
b=b-5
End Sub

;)
 
Upvote 0
Top