Welcome to Phrogram Sign in | Join | Help


GetPixelColor: slow and unhelpful?

  •  11-29-2006, 3:59 AM

    GetPixelColor: slow and unhelpful?

    The Drawing.GetPixelColor() method seems to be extremely slow and, also, somewhat unhelpful. The following program shows that you can only get about 65 calls per second on a 1.7GHz Pentium M --- which implies it takes about 25 million instructions to execute! This strikes me as very wrong for an essentially simple graphics operation.

    Not only that, but the result that it returns isn't what you might expect -- if I set the background to white, I'd expect the value it returns to be the same. Either that or we need a "CompareColors()" method to allow you to check if two colours have the same "handle" but are really equivalent.

    Would any of the Phrogram developers care to comment? 

    Program PixColor

        Method Main()

            ClearBackground(Colors.White)
            PrintLine("Working ...")
            Define startTime As Integer = TickCount()
            Define i As Integer
            Define p As Integer
            For i = 1 To 1000
                p = GetPixelColor(100, 100)
            Next
            Define endTime As Integer = TickCount()
            Define secs As Decimal = (endTime - startTime) * 0.001
            PrintLine("1000 iterations took " + secs + " seconds (" + (1000.0 / secs) + " per sec)")
            PrintLine("Pixel colour was " + p + ", white is " + Colors.White)

        End Method

    End Program

    Filed under:
View Complete Thread