My two cent - Simple and very fast.
The way to do this is to abuse the FilterCallback to analyze an image.
FilterCallback is much faster than reading the lines manually, no matter how you do it.
The method of direct access without Point() has practically never shown a speed advantage for me, which is why I stopped using it a long time ago.
Bit based operations are very fast.
Then it is only necessary to avoid as sample "IF, AND" queries, which naturally act as a little handbrake.
Code: Select all
; Is a image grey scaled - By Saki
Global result
UsePNGImageDecoder() : UseTIFFImageDecoder() : UseJPEGImageDecoder()
Procedure CallBack_GreyCheck(x, y, source_color, destination_color)
result+Bool(Red(source_color)!(Red(source_color)!Green(source_color)!Blue(source_color)))
ProcedureReturn destination_color
EndProcedure
file$=OpenFileRequester("Select a image", "", "", 0)
window_ID=OpenWindow(#PB_Any, 0, 0, 800, 800, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
canvas_ID=CanvasGadget(#PB_Any, 0, 0, WindowWidth(window_ID), WindowHeight(window_ID))
image_ID=LoadImage(#PB_Any, file$)
ms=ElapsedMilliseconds()
If IsImage(image_ID)
StartDrawing(ImageOutput(image_ID))
DrawingMode(#PB_2DDrawing_CustomFilter)
CustomFilterCallback(@CallBack_GreyCheck())
DrawAlphaImage(ImageID(image_ID), 0, 0)
StopDrawing()
ms=ElapsedMilliseconds()-ms
Else
DrawText(10*DesktopResolutionX(), WindowHeight(window_ID)*DesktopResolutionY()-25, "Can not use this image")
EndIf
StartDrawing(CanvasOutput(canvas_ID))
DrawText(10*DesktopResolutionX(), WindowHeight(window_ID)*DesktopResolutionY()-25, "colored points "+result+" // Elapsedmilliseconds : "+ Str(ms))
ResizeImage(image_ID, WindowWidth(window_ID)*DesktopResolutionX(), WindowHeight(window_ID)*DesktopResolutionY()-40)
DrawAlphaImage(ImageID(image_ID), 0, 0)
StopDrawing()
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow