Page 1 of 1
					
				Fast Refreshing of ImageGadget
				Posted: Tue Feb 10, 2004 3:17 pm
				by nci
				Hi all,
I've been working on re-writing my media player
in PB. I am having trouble with my spectrum analyzer.
It seems when drawing on an image created with CreateImage
the imagegadget flickers wildly. the spectrum is displayed but it
flickers. I tried to use RedrawWindow_ api but it flickers as well
and i cannot find any combination of flags that will refresh without
flickering.
Please, someone help!!!
Thanks
			 
			
					
				
				Posted: Tue Feb 10, 2004 3:42 pm
				by Pupil
				Maybe you could do some kind of doublebuffering scheme using two images and draw to the image that isn't currently used in the imagegadget and when the drawing is finished just change the image in imagegadget..
			 
			
					
				
				Posted: Tue Feb 10, 2004 3:53 pm
				by nci
				I tried doing something like:
Code: Select all
    UseImage(#SKIN_VISUAL)
    StartDrawing(ImageOutput())
      ;Clear
      Box(0,0,ImageWidth(),ImageHeight(),RGB(0,0,0))
      For X = 0 To 511
        lVal = 511 / ImageWidth() * X
        ;lVal = X / ImageWidth()
        LineXY(lVal,ImageHeight(),lVal,ImageHeight() - fSpectrum(X) * ImageHeight(),RGB(255,0,0))
      Next X
      
      ;SendMessage_(GadgetID(#IMG_VISUAL),#WM_PAINT,0,0)
      RedrawWindow_(GadgetID(#IMG_VISUAL),0,0,#RDW_VALIDATE | #RDW_UPDATENOW)
      ;DrawImage(UseImage(#SKIN_VISUAL),0,0)
    StopDrawing()
    ;SetGadgetState(#IMG_VISUAL,UseImage(#SKIN_VISUAL))
The commented code is what I have tried. Some don't work and others 
flicker.
EDIT: OK, I tried doing the sort of doublebuffer thing
but it didn't work either. Gosh, there has to be a way!!!!!
 
			 
			
					
				
				Posted: Tue Feb 10, 2004 5:40 pm
				by Fred
				May be you can try to display your sprectrum directly on the window with 'WindowOutput()', it should be the fastest way to do it and shouldn't suffer of flicker (use a DrawImage() to be sure to draw the whole stuff at once).
			 
			
					
				
				Posted: Tue Feb 10, 2004 5:42 pm
				by nci
				There is another image covering the whole form. Can I paint over that
with WindowOutput? or would I have to include the whole image as part
of the spectrum (ack!)
			 
			
					
				
				Posted: Wed Feb 11, 2004 3:07 pm
				by blueznl
				if you continuously update the display, why not draw directly on screen? (ie. window) it's not the way to do it, but hey, it works 

 
			 
			
					
				
				Posted: Wed Feb 11, 2004 5:27 pm
				by nci
				Thanks, but I did get it to work.
I just used StartDrawing(ImageOutput())
did stuff with image then
StopDrawing()
StartDrawing(WindowOutput())
DrawImage(ect...
StopDrawing()
It works like a charm now