Photo display program with smooth control

Frank

Member
Licensed User
Longtime User
Hi,
this is a small program that displays (jpg)-Photos in fullscreen-mode on the PPC. I am sure there are hundreds of programs that can do that, but I might work on it until it really suits my needs.
Controlling it is quite simple: Slide your finger across the screen (left to right or right to left) to load a photo, down for help, up to close help.

It scans the directories given in the file directories.txt for photos. If you try it on the desktop, you need to change the pathes in that file.

I would like to add more features such as a photo ribbon which can be scrolled, but I fear that the program becomes to slow. It is already quite slow on my XDA Orbit.
Is there any way to make this program faster?
Also: after a while I receive an out-of-memory-error, although I am not aware of a memory leak. Does anybody know why?

Thanks a lot,
Frank
 

Attachments

  • Photo.zip
    56 KB · Views: 410

agraham

Expert
Licensed User
Longtime User
That's a neat idea to maximise real estate for pictures. However there is quite a bit of duplicated code displaying images that really should be put into a Sub as good practice ,for ease of debugging, dictates.

Also: after a while I receive an out-of-memory-error, although I am not aware of a memory leak. Does anybody know why?
I can't see immediately see any leaks in the code. As a clutching at straws suggestion I wonder if your MouseUp sub is being re-entered and causing a recursion problem because it does a lot work and may take some time to run. I would try declaring a global for the sub set to false. Check it on entry to the sub and exit if true otherwise set it true. Set it to false on exit. You could also do something similar to count re-entries - that's if they are happening at all!
 

Frank

Member
Licensed User
Longtime User
Memory leak

Agraham,
thanks for the tip; I incorporated a Boolean variable, and so far I didn't get an out-of-memory error. The program is still slow, though...

I'll do the code cleanup next time; this time only the new variable...

Bye,
Frank
 

Attachments

  • photo.sbp
    10.5 KB · Views: 299

klaus

Expert
Licensed User
Longtime User
I had the same kind of trouble with bitmaps bigger than the screen which I scroll with a scroll bar.
Tried it like below, but still got the memory overload message but less often.

Sub HScroll_ValueChanged
If Done=1 Then Return
Done=1
MapX=HScroll.Value
bmpMap.Value=MapImage.CopyImage(ImageList1.Item(Map_I),MapX,MapY,GW,GH)
frmMain.DrawImage(bmpMap.Value,GX0,GY0)
Done=0
End sub
And after the first Out of memory message the variable Done remained at 1 and the bitmap did not move anymore.


Solved it like below:

Sub HScroll_ValueChanged
ErrorLabel(DoneH)
MapX=HScroll.Value
bmpMap.Value=MapImage.CopyImage(ImageList1.Item(Map_I),MapX,MapY,GW,GH)
frmMain.DrawImage(bmpMap.Value,GX0,GY0)
DoneH:
End Sub

Of course in scrolling I notice that some intermediate scroll values are not displayed, but this is less anoying than the error message.

Klaus
Switzerland
 
Last edited:
Top