From: Daan L. <da...@cs...> - 2004-08-03 13:26:10
|
shelarcy wrote: > I chaged the program like this.But program doen't work yet. > Where is my mistake? Hi Shelarcy, Your mistakes are in the plain Haskell code. For example: > pixelColorInt (Point ptx pty) (Size szx szy) > | ptx < 0 = pixelColorInt (Point 0 pty) (Size szx szy) > | pty < 0 = pixelColorInt (Point ptx 0) (Size szx szy) > | ptx > szx = pixelColorInt (Point ptx pty) (Size 0 szy) > | pty < szy = pixelColorInt (Point ptx pty) (Size 0 szy) > | otherwise = do pixel <- pixelBufferGetPixel pb If I call this with (Point x y) (Size sz sy) where y < sy, this function loops indefinitely. What you should try to do is to split up everything into small functions that can be tested independently -- instead of writing everything at once. Also, if certain expression patterns occur more than once, try to make that into a function. Anyway, to help you along, I have attached a version of your program that does what you want. As you will notice, it is rather slow. After some testing I found that it is due to the slow "pixelBufferGet/SetPixel" functions. In the cvs release I'll commit a version that allows you to retrieve the entire buffer at once which makes it much faster. That version is probably available by anonymous cvs tomorrow. All the best, Daan. |