FastImageOutput

Share your advanced PureBasic knowledge/code with the community.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I think it's a good approach to have a flexible fast image manipulation. It could be added natively to PB in a future version.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post by nco2k »

sounds good. :P

ImageOutput() = ~200ms
FastImageOutput() = 0-15ms

c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Illegal memory access...
I testet it with remi_meier's "The beauty of z^2 + c" trick...
http://www.purebasic.fr/english/viewtopic.php?t=22446
I like logic, hence I dislike humans but love computers.
S.M.
Enthusiast
Enthusiast
Posts: 118
Joined: Sat Apr 24, 2004 1:11 pm
Contact:

Post by S.M. »

Illegal memory access...
I testet it with remi_meier's "The beauty of z^2 + c" trick...
http://www.purebasic.fr/english/viewtopic.php?t=22446
Thanks :D , I corrected the code above.
Now FastImageOutput() returns zero if a device dependent bitmap (bitmap created with #PB_Image_DisplayFormat) is used.
To get the code working, just replace:

Code: Select all

img = CreateImage(#PB_Any, #S, #S)
with:

Code: Select all

img = CreateImage(#PB_Any, #S, #S,32)
Now it should work.

@all
Thanks for the nice feedback!
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

It says 0 ms on my machine. Is that possible?
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

It will say 0 ms if you aren't using a high-enough-res method of timing. ElapsedMilliseconds() is only good to a resolution of 15 ms or so, and if the operation you're timing finishes faster than that the ElapsedMilliseconds() value will not have changed. Hence the 0 ms. You can get 1ms accuracy easily with:

Code: Select all

timeBeginPeriod_(1)
start = timeGetTime_()
  ; timed operation
ending = timeGetTime_()
or look to QueryPerformanceFrequency_() for microsecond accuracy (you shouldn't need this much)

IIRC, when I tested this FastImageOutput() I had to drop to a lower-res method as well to avoid getting 0 ms for a result. I think I posted the method if you look a few posts back in this thread.
BERESHEIT
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

That seemed to work, I'm getting 15 ms now.
But if I run it two or three times after each other then I sometimes get 0 ms and then back to 15 again.
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: FastImageOutput

Post by PB »

This code no longer works with v4.10 B3, and I don't know how to fix it.
Changing to "img = CreateImage(#PB_Any, #S, #S,32)" doesn't help as
it doesn't exist in the original code snippet.
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Maybe it's now native? Fred?
User avatar
IceSoft
Addict
Addict
Posts: 1683
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Post by IceSoft »

Fred wrote:I think it's a good approach to have a flexible fast image manipulation. It could be added natively to PB in a future version.
@Fred,
Maybe together with the 'DirectX9' Version of PB?
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Native or not, the tip should work!?
And it doesn't for 4.10 version
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Is this faster than drawing on a window with WindowOutput()?
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: FastImageOutput

Post by dige »

Since PB4.40 drawing on Gadgets with StartDrawing(GadgetOutput(GadgetID.i))
does not work anymore.
May be the Structure has changed?

Code: Select all

Structure DrawingInfoStruct
  Type.l
  Window.l
  DC.l
  ReleaseProcedure.l
  PixelBuffer.l
  Pitch.l
  Width.l
  Height.l
  Depth.l
  PixelFormat.l
  StopDirectAccess.l
  StartDirectAccess.l
EndStructure

Global FastImgOutputID.DrawingInfoStruct

Procedure ReleaseGadgetOutput()
  ReleaseDC_(FastImgOutputID\Window, FastImgOutputID\DC)
EndProcedure

Procedure GadgetOutput(GadgetID) ; returns the outputID for the declared window handle
  hwnd = GadgetID(GadgetID)
  FastImgOutputID\Type=2
  FastImgOutputID\Window=hwnd
  FastImgOutputID\DC=GetDC_(hwnd)
  FastImgOutputID\ReleaseProcedure=@ReleaseGadgetOutput()
  ProcedureReturn FastImgOutputID
EndProcedure 
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: FastImageOutput

Post by Michael Vogel »

Any news about FastImageOutput for PB4.50?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: FastImageOutput

Post by Fred »

It shouldn't have much difference since 4.40.
Post Reply