ResizeImage() slow under Linux?
Posted: Wed Jan 02, 2008 11:18 pm
I'm doing a program which should resize big pictures for on screen view, and keep the original picture in memory. My computer is equipped with AMD XP2100 cpu and 1,25GB ram ticking at 333MHz. I'm running PB 4.10 on Ubuntu 7.10. My code gives these results:
I don't know why, but neither CopyImage nor GrabImage() use more than 1ms to execute in Ubuntu. Can this be correct?
The rezise time is not consistant on Ubuntu. It varies several seconds. After running the program, the window cannot be closed for the first 20-30 seconds, as the Redraw() procedure is always called 3 times when started. "Only" 2 times in WinXP. Can I avoid this?
- Copytime when initializing using CopyImage()
0
Rezise time when initializing:
5091
Copytime within Redraw() using GrabImage()
0
Rezise time within Redraw():
6442
Copytime within Redraw() using GrabImage()
0
Rezise time within Redraw():
8048
Copytime within Redraw() using GrabImage()
0
Rezise time within Redraw():
7997
- Copytime when initializing using CopyImage()
235
Rezise time when initializing:
281
Copytime within Redraw() using GrabImage()
94
Rezise time within Redraw():
281
Copytime within Redraw() using GrabImage()
94
Rezise time within Redraw():
281
I don't know why, but neither CopyImage nor GrabImage() use more than 1ms to execute in Ubuntu. Can this be correct?
The rezise time is not consistant on Ubuntu. It varies several seconds. After running the program, the window cannot be closed for the first 20-30 seconds, as the Redraw() procedure is always called 3 times when started. "Only" 2 times in WinXP. Can I avoid this?
Code: Select all
Procedure Redraw()
If IsImage(1)
FreeImage(1)
EndIf
tt=ElapsedMilliseconds()
GrabImage(0, 1, 0, 0, ImageWidth(0), ImageHeight(0))
tt-ElapsedMilliseconds()
t=ElapsedMilliseconds()
ResizeImage(1,WindowWidth(0),WindowHeight(0))
t-ElapsedMilliseconds()
If SetGadgetState(0, ImageID(1)) =0
Debug "Couldn't set gadget image"
End
EndIf
Debug "Copytime within Redraw() using GrabImage()"
Debug -tt
Debug "Rezise time within Redraw():"
Debug -t
EndProcedure
Procedure LoadImg()
x = 2399
y = 3349
If CreateImage(0,x,y,32) = 0
Debug "Couldn't create image"
End
EndIf
If StartDrawing(ImageOutput(0))=0
Debug "Could'nt draw on image"
End
EndIf
Box(x*0.1,y*0.1, x*0.8,y*0.8,$440000)
xc=1
yc=1
c=Round(x*0.199,0)
xstep=Round(x/c,0)
ystep=Round(y/c,0)
For co=1 To c
LineXY(1,yc,xc,(y-1),$FFFFFF)
LineXY(xc,1,(x-1),yc,$FFFFFF)
xc=xc+xstep
yc=yc+ystep
Next co
StopDrawing()
EndProcedure
LoadImg()
WinWidth = 500
WinHeight = Round((ImageHeight(0)/ImageWidth(0))*winwidth,0)
tt=ElapsedMilliseconds()
CopyImage(0,1)
tt-ElapsedMilliseconds()
t=ElapsedMilliseconds()
ResizeImage(1,WinWidth,WinHeight)
t-ElapsedMilliseconds()
Debug "Copytime when initializing using CopyImage()"
Debug -tt
Debug "Rezise time when initializing:"
Debug -t
If OpenWindow(0, 0, 0, WinWidth, WinHeight, "Window for picture output", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) = 0
Debug "Could'nt open window"
End
EndIf
ImageGadget(0,0,0,100,100,ImageID(1))
Redraw()
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_CloseWindow
End
Else
If event = #PB_Event_SizeWindow
Redraw()
EndIf
EndIf
ForEver