Depends whether you are coding OpenGL or Max2D.
In Open GL i'd have a texture with the image on it, then just draw quads, one for each column, adjusting the texture coordinates to show only a given column from the texture, for each column. And as you say, just have a sinewave with an offset that changes to make it move. That'd wiggle it horizontally.
To do it vertically as well, ideally you'd want to grab the drawn flag into another texture (or render to texture first), and then draw horizontal strips with another sinewave of offsets. That'd get it wiggling pretty good.
But even then it's not going to really look like a real flag in the wind with different shaped ripples progressing over the cloth, creating dynamic curves and shapes etc. For that you'd need a cloth simulator with a bunch of springs and maybe make it out of a grid of small quads, moving the vertices around to stretch it.
In Open GL i'd have a texture with the image on it, then just draw quads, one for each column, adjusting the texture coordinates to show only a given column from the texture, for each column. And as you say, just have a sinewave with an offset that changes to make it move. That'd wiggle it horizontally.
To do it vertically as well, ideally you'd want to grab the drawn flag into another texture (or render to texture first), and then draw horizontal strips with another sinewave of offsets. That'd get it wiggling pretty good.
But even then it's not going to really look like a real flag in the wind with different shaped ripples progressing over the cloth, creating dynamic curves and shapes etc. For that you'd need a cloth simulator with a bunch of springs and maybe make it out of a grid of small quads, moving the vertices around to stretch it.