Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you animate every time a picture is shown in VFP9? 1

Status
Not open for further replies.

Mandy_crw

Programmer
Jul 23, 2020
585
PH
Hi everyone, I have this in my program that eveytime an ID number is entered, a picture is shown. Is there a way or way that i can animate in showing picture? thanks and God bless!
 
How exactly do you want to "animate" the picture. I understand that if an ID is entered, you want to show a picture of the person whose ID it is. But where does the animation come in?

VFP supports animated GIFs. These are usually used to show that some sort of event is in progress, like a spinning wheel during a long search. Is that what you are looking for?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The simplest would be having an animated GIF set up to run once, ie starting as empty and then zooming in to full size (not in a loop). That has a color limitation, as GIFs only allow 256 color palettes, but you'd need to do nothing else but change an image.picture property to the GIF filename. Also, you could do any animation effect within whatever image processing software you have at hand, it needs to store it as GIF animation. If this should be of higher quality you could generate AVIs, there's a solution example for displaying AVI movies in VFP with the mci32.ocx. Same prionciple, you need to animate outside of VFP, make a movie ending in the image as you finally want to show it as a still image, and then play it. And last not least, with any still image format (jpg most often) you could do a zoom by changing image position and width/height with a timer.



Chriss
 
If you want to experiment with animated GIFs, there are a couple of samples in the VFP folder (under Graphic\GIFS). For example, MORPHFOX.GIF.

They are very easy to use. Just put an Image control on a form, and set its Picture property to the GIF's path and filename. Then run the form.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mandy_crw,

in case you want to show the user, that a field has been changed and offer a button/image to 'undo' the change or 'init' the value you can make use of 'interactivechange'.
But!!!!! Implementing such a feature doesn't make sense if you have to write code each and every time you want to bring it into one of your forms. My way of doing something like that would be a container class with a label, a textbox and a button/image. The container has some code in its INIT method that binds the textbox.interactivechange event as well as the buttons/image.click event to special methods that handle the corresponding actions.

Attached is a demoform that does it in a quick and dirty way just for demo purposes.

Demoform_t7vivf.png


HTH

-Tom
 
Good day everyone... thanks for all your answers.... i want the picture to be shown to appear as a smallest picture until to the size defined. Its like zooming in not just appear when the id number is found.... thank you so much...
 
So, presumably,the picture that you want to show is an image (a mug shot, if you prefer the term) of the person whose ID has been entered?

If that's right, an animated GIF won't really serve, as you would need to create a separate file specifically for each person.

So, what you need to do is to put an Image control on your form. Set its Height and Width to the smallest practical size. Set its Picture property to point to the image file. Set its Stretch to 1. And finally set its Visible to .F

At the point at which you accept the ID, do something like this:

Code:
THISFORM.MyImage.Visible = .T.
FOR lnI = 1 to 25
  THISFORM.MyImage.Height = THISFORM.MyImage.Height + 1
  THISFORM.MyImage.Width = THISFORM.MyImage.Width + 1
  Sleep(100)
ENDFOR

Also, somewhere near the start of your program, you will need to define the Sleep() function, like this:

Code:
DECLARE Sleep IN WIN32API INTEGER iPeriod

You only need to do that once.

In the first bit of code, above, you will need to experiment with the values of 5, 25 and 100 until you get what you judge to be the best effect.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike's idea is the way to go.

But IMHO, VFP isn't prepared for doing such things. Every time you have to use a timer, the rest of the app stops til the job, that the timer shall start is done. Perhaps Joel Leachs 'Parallel Fox' project on Github could help, but on the other hand just for the fun of doing it, this might be a too big overload.

Honestly, zooming in an image looks cool in the beginning, but as soon as you want to work with the app, everyone wants to turn it off as it stops them from being productive.

I'd prefer another way. Create two pictures. One for the thumbnail i.e. 32x32px and another one in high dpi that appears when the thumbnail is clicked. The big picture might even be placed in a special form where the user can zoom in/out with the mouse wheel.

Creating thumbnails on the fly based on a high dpi image can be done with gdiplus on github/vfpx.

JM2C

-Tom
 
Thanks Mike and Tom.... this vfp is really pushing me to do much of its capabilities... I'll be trying Mike's suggestion first for it is the idea i want... then try Tom's then see what's best for my program... I'm really learning alot... appreciate it so much... thank you guys....
 
Mandy,

By all means experiment with this as a way of getting to know VFP and of testing its capabilities. But I would echo Tom's point. This sort of animation might look cool at first, but it can quickly become annoying, especially when you just want to get on with your job.

Have you ever visited a web page in order to get some important information, only to have your concentration interrupted by moving images, automatic slide shows and auto-play videos? I certainly have. Unnecessary animations can be equally irritating.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I think you want to give feedback about the completed entry of the ID. Perhaps there is a simpler way: You could change the background color of the textbox. I'd suggest white, when it's empty, yellow as long as the ID is incomplete, and green when it gets complete, together with the change of the image (be it a person or a product with that ID) just without animation. And you could use red for the case a completed ID isn't found.

Chriss
 
Just want to point out that using color as an indicator is a mixed bag as lots of people have various forms of colorblindness, and others have other visual impairments that may make it difficult to see, for example, black on green. If you want to use background colors as an indicator, stick with light versions that won't reduce contrast and make sure there's some other indicator if the indication is essential.

Tamar
 
Chris....
I had fun animating the ID picture it started with dot size then it grows big enough to see the image.... but everytime i enter another ID number, the image does not reset to zero, what happens is that it just continue to enlarge the picture.... am i correct when i put the red text to reset the value of height and width? code is below...

SEEK idcode

iF FOUND()

this.Parent.text1.value = TRIM(tsulat.idnum)
this.parent.text2.value = TRIM(tsulat.sname) + ", " + TRIM(tsulat.fname)
this.Parent.text3.value = TRIM(tsulat.mobile)

this.Parent.image2.Visible = .F.

lcFile = "D:\Program Files\SCMS Info Wave\Pictures\"+ ALLTRIM(this.Parent.text1.value) + ".jpg"

IF FILE( lcFile , 1 )
this.Parent.image1.picture = lcFile
this.parent.image1.visible = .t.

FOR lnI = 1 to 160
this.parent.image1.Height = this.parent.image1.Height + 1
this.parent.image1.Width = this.parent.image1.Width + 1
Sleep(1)
ENDFOR

this.parent.image1.Height.value = 160
this.parent.image1.width.value = 160

FOR lnI = 160 to 0
this.parent.image1.Height = this.parent.image1.Height - 1
this.parent.image1.Width = this.parent.image1.Width - 1
ENDFOR



ELSE
this.Parent.image1.visible = .f.
this.Parent.image2.Visible = .T.
ENDIF
 
One thing you can optimize is that you can assign the loop value directly to the image objects width and height
Code:
FOR lnI = 1 to 160
 this.parent.image1.Height = lnI
 this.parent.image1.Width = lnI
 Sleep(1)
ENDFOR 

FOR lnI = 160 to 0 STEP -1
 this.parent.image1.Height = lnI
 this.parent.image1.Width = lnI
 sleep(1)
ENDFOR



-Tom
 
Mandy, what your code shows is that you are gradually increasing the size of the image from 1 x 1 to 160 x 160, then immediately making it invisible again. If that's what you want to achieve, then the code should work as intended. However, the code you showed in red is redundant. You will get exactly the same effect by setting its Visible to .F.

The next time you display a picture, the whole process should start again, with the new image starting again at 1 x 1, which is presumably what you want. If that's not what you are seeing, there must be something else happening somewhere that is preventing it.

Edit: Tom is correct, of course. You need the [tt]STEP -1[/tt]. That would explain what you are seeing. Sorry I missed that. But my subsequent answer still stands. The whole of that loop is redundant.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
To me, it seems you want to zoom out the previous image, then zoom in on the new one. That should be done using the descending loop first, then change the picture property to the new file, and then loop incrementing the size. Then you don't even need to switch the visibility.

Edit:

I see you use Sleep(1). This only waits 1 ms.

That's quite a long time for a CPU, but not for a display. Even modern displays have 100Hz, perhaps 200Hz as extreme, and even then it only applies to high contrast changes. With such refresh rates, an image needs to be on screen for at least 5-10ms, to be displayed.

Or in short: As Mike said, experiment with the step size and sleep duration until you get a good enough result with lesser frames. Note that such relatively low frequencies for display are still in use because the human eye is even slower in recognizing image changes, so we don't need to improve this, only for sake of 3D a double frame rate is nice to have. But a fluid animation is already possible with 25-30 frames per second and that would be Sleep(33) to Sleep(40). Then you'd obviously change size in larger steps. If you combine Sleep(x) with Step x you still have 1 pixel per millisecond animation speed, just fewer frames and more time slices for other processes, which keeps up the responsivity of the whole computer.

Chriss
 
Thanks everyone for your very big help, i ahd fun experimenting with the animation, and i really liked the turn out or the output itself... but I've noticed it slowed down drastically the performance of the app I'm designing...so I've minimized the animation... its really just good for the eyes... what good about this is that I'm really learning alot from you guys... i really appreciate it... thank you everyone...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top