Seite 1 von 1

Geschwindigkeit (Pixel Manipulation)

Verfasst: 27.09.2014 21:50
von gem
Guten Abend

Wie bekomm ich die Geschwindigkeit zur Darstellung des Zufallbildes noch schneller hin.
Bei mir braucht jede Darstellung mindestens 100ms. Das wären doch 10fps ?!.
Wenn ich ein HD Video mit einem Player (Flash, VLC) angucke habe ich eine Framerate von 25-30.
Mogeln die Programme oder wie bekommt man so eine hohe Bildrate?

Code: Alles auswählen

#window = 1

Structure p
	point.l
EndStructure

width.i = 1280
height.i = 720

Global *pixel.p

InitSprite()

OpenWindow(#window,0,0,width,height,"")
OpenWindowedScreen(WindowID(#window),0,0,width,height)

Repeat
	
	timer = ElapsedMilliseconds()
	
	StartDrawing(ScreenOutput())
	
	buffer = DrawingBuffer()
	pitch = DrawingBufferPitch()
	
	For y.i = 0 To height-1
		
		*pixel = buffer+y*pitch
		
		For x.i = 0 To width-1
			
			*pixel\point = 2455555
			*pixel + 4
		Next
	Next
	
	StopDrawing()
	
	FlipBuffers()
	
	Debug ElapsedMilliseconds()-timer

Until WindowEvent() = #PB_Event_CloseWindow

CloseWindow(#window)

Re: Geschwindigkeit (Pixel Manipulation)

Verfasst: 27.09.2014 22:11
von Danilo
Es ist nur mit Debugger so langsam. Habe Deinen Code etwas abgeändert und noch #PB_Screen_NoSynchronization hinzugefügt,
so dass man den Unterschied mit und ohne Debugger noch besser sieht:

Code: Alles auswählen

#window = 1

Structure p
   point.l
EndStructure

width.i = 1280
height.i = 720

Global *pixel.p

InitSprite()

OpenWindow(#window,0,0,width+100,height,"")
ListViewGadget(1,width+1,0,99,height)
OpenWindowedScreen(WindowID(#window),0,0,width,height,0,0,0,#PB_Screen_NoSynchronization)

Repeat
   
   timer = ElapsedMilliseconds()
   
   StartDrawing(ScreenOutput())
   
   buffer = DrawingBuffer()
   pitch = DrawingBufferPitch()
   
   For y.i = 0 To height-1
      
      *pixel = buffer+y*pitch
      
      For x.i = 0 To width-1
         
         *pixel\point = 2455555
         *pixel + 4
      Next
   Next
   
   StopDrawing()
   
   FlipBuffers()
   
   ;Debug ElapsedMilliseconds()-timer
   AddGadgetItem(1,-1,Str(ElapsedMilliseconds()-timer))
   SetGadgetState(1,CountGadgetItems(1)-1)
   
   Repeat
       event = WindowEvent()
       If event = #PB_Event_CloseWindow
           quit=1
       EndIf
   Until event=0

Until quit

CloseWindow(#window)

Re: Geschwindigkeit (Pixel Manipulation)

Verfasst: 27.09.2014 23:19
von NicTheQuick
Lustig. Unter Linux kommt einfach: "Programm abgebrochen. (durch eine externe Library)" und es bleibt bei "StopDrawing()" stehen. Ich muss wohl mal wieder Bugs melden gehen... :roll:

Re: Geschwindigkeit (Pixel Manipulation)

Verfasst: 27.09.2014 23:34
von ts-soft
Dann melde mal den Bug, kann ich bestätigen!

Aber mit 32-Bit läuft das Programm problemlos :roll:

Re: Geschwindigkeit (Pixel Manipulation)

Verfasst: 27.09.2014 23:40
von Danilo
NicTheQuick hat geschrieben:Lustig. Unter Linux kommt einfach: "Programm abgebrochen. (durch eine externe Library)" und es bleibt bei "StopDrawing()" stehen. Ich muss wohl mal wieder Bugs melden gehen... :roll:
Da sind keine Überprüfungen für InitSprite / ScreenOutput / StartDrawing / DrawingBuffer drin, und es wird
einfach angenommen dass ein Pixel aus 4 Bytes besteht.
Der Programmabbruch in einer externen Library könnte ein Hinweis auf eine Exception sein,
z.b. wenn in falsche Speicherregionen geschrieben wird.
Überprüfe mal ob DrawingBufferPixelFormat() wirklich ein 32bit-Format zurück gibt.

Re: Geschwindigkeit (Pixel Manipulation)

Verfasst: 27.09.2014 23:53
von ts-soft
Okay, mit 2 Byte läuft es durch, 3 und 4 stürzen ab.

Re: Geschwindigkeit (Pixel Manipulation)

Verfasst: 28.09.2014 00:04
von NicTheQuick
Ja, logisch. Ist wohl doch schon zu spät für mich. :D Mit 24 Bit geht es.

Code: Alles auswählen

#window = 1

Structure p
	r.a
	g.a
	b.a
EndStructure

width.i = 1280
height.i = 720

Global *pixel.p

InitSprite()

OpenWindow(#window,0,0,width+100,height,"")
ListViewGadget(1,width+1,0,99,height)
OpenWindowedScreen(WindowID(#window),0,0,width,height,0,0,0,#PB_Screen_NoSynchronization)

Repeat
	
	timer = ElapsedMilliseconds()
	
	If StartDrawing(ScreenOutput())
		
		buffer = DrawingBuffer()
		pitch = DrawingBufferPitch()
		
		For y.i = 0 To height-1
			
			*pixel = buffer+y*pitch
			
			For x.i = 0 To width-1
				
				*pixel\b = 255
				*pixel + 3
			Next
		Next
		
		StopDrawing()
	EndIf
	
	FlipBuffers()
	
	;Debug ElapsedMilliseconds()-timer
	AddGadgetItem(1,-1,Str(ElapsedMilliseconds()-timer))
	SetGadgetState(1,CountGadgetItems(1)-1)
	
	Repeat
		event = WindowEvent()
		If event = #PB_Event_CloseWindow
			quit=1
		EndIf
	Until event=0
	
Until quit

CloseWindow(#window)