Fast Refreshing of ImageGadget

Just starting out? Need help? Post your questions and find answers here.
nci
User
User
Posts: 28
Joined: Mon Jul 28, 2003 6:03 pm

Fast Refreshing of ImageGadget

Post 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
Neptune Century Inc.
Eric Butler, CEO, Lead programmer

"The road to happiness never ends..."
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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..
nci
User
User
Posts: 28
Joined: Mon Jul 28, 2003 6:03 pm

Post 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!!!!!
Neptune Century Inc.
Eric Butler, CEO, Lead programmer

"The road to happiness never ends..."
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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).
nci
User
User
Posts: 28
Joined: Mon Jul 28, 2003 6:03 pm

Post 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!)
Neptune Century Inc.
Eric Butler, CEO, Lead programmer

"The road to happiness never ends..."
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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 :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
nci
User
User
Posts: 28
Joined: Mon Jul 28, 2003 6:03 pm

Post 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
Neptune Century Inc.
Eric Butler, CEO, Lead programmer

"The road to happiness never ends..."
Post Reply