Display Jpeg Images And Rotate The Pages


Recommended Posts

Hi All,

Don't know if I'm cracking up here or just plain stupid! , but how do I display a sequence of 8 jpeg pictures and get them to automatically

rotate with a short delay between each page?

Any help greatly recieved!!!

Cheers,

Ian J - PCS Ltd

Link to comment
Share on other sites

Depends. First, are the 8 pictures going to change or are they fixed. I'm going to also assume they are about the same size. Let's assume they are going to change. If they are fixed you can use the same technique. There are other techniques available if they are fixed and you want the images embedded in your .ctl doc. This version requires them to be on a disk.

1) create a symbol component and place it on a page where you want the jpeg's. Name the component (right click on it after selecting and select "Component Name...". Let's call it "jpegs" for this example

2) create a new sequence:


private string filenames
filenames[0] = "c:\myimage1.jpg"
filenames[1] = "c:\myotherimage.jpg"
filenames[2] = "c:\anotherfolder\anotherimage.jpg"
// etc for as many as you want

while(1)
for(private x = 0, x < numrows(filenames), x++)
component.jpegs.loadJpeg(filenames[x])
delay(60)
endfor
endwhile

[/CODE]

Run the sequence whenever you want the rotation to occur. Change the 60 to whatever delay (in seconds) you want.

Link to comment
Share on other sites

Hey Support,

Many thanks for the swift reply!!

Ok - I've got the jpegs rotating, but they seem to appear half way down the screen..

Is there any way of getting them display full screen?

Again - Many thanks for your replies..

Ian J - PCS Ltd

Link to comment
Share on other sites

Sure. Two ways:

Method 1: keep the page from drawing while it loads:



private string filenames
filenames[0] = "c:\myimage1.jpg"
filenames[1] = "c:\myotherimage.jpg"
filenames[2] = "c:\anotherfolder\anotherimage.jpg"
// etc for as many as you want

while(1)
for(private x = 0, x < numrows(filenames), x++)
system.delayUpdate()
try
component.jpegs.loadJpeg(filenames[x])
delay(1)
catch()
? strLastError
endcatch
system.resumeUpdate()
delay(59)
endfor
endwhile


[/CODE]

You may have to tweak the delay(1) bigger (or ideally smaller) for best result. DelayUpdate() causes the page not to redraw itself until ResumeUpdate() is called. The thing is, I do not know if loadJpeg() is blocking, and might return immediately even though the jpeg isn't loaded. Thus the delay() to allow it to load before letting the page redraw. However, it might be blocking, in which case you can eliminate the delay(1). Try it and if you don't mind, post what works for you. The try/catch around the loadJpeg is to ensure that resumeUpdate gets called, even if there is an error. Note how resumeUpdate is outside the catch.

The problem with this method is that nothing on the page will redraw while the jpeg is loading.

Method #2: Create two symbol components, name then jpeg0 and jpeg1. Then change the script to:

[CODE]
component.jpeg0.visible = 0
component.jpeg1.visible = 0

private string filenames
filenames[0] = "c:\myimage1.jpg"
filenames[1] = "c:\myotherimage.jpg"
filenames[2] = "c:\anotherfolder\anotherimage.jpg"
// etc for as many as you want


private alter = 0
while(1)
for(private x = 0, x < numrows(filenames), x++)
execute("component.jpeg" + doubletostr(alter) + ".loadJpeg(filenames[x])")
execute("component.jpeg" + doubletostr(!alter) + ".visible = 0")
execute("component.jpeg" + doubletostr(alter) + ".visible = 1")
alter = !alter

delay(60)
endfor
endwhile
[/CODE]

This should work better: it simply creates to components and alternates between the two, making the other one invisible.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.