From: shelarcy <she...@ca...> - 2004-07-30 02:22:19
|
Hello, A few month ago, I was made filter Program. Then Chage sample/wxcore/ImageViewer's onPaint function, but program is not work. http://sourceforge.net/mailarchive/forum.php?thread_id=4184783&forum_id=34197 Now wxHaskell 0.8 was added pixelBufferCreate and pixelBufferDelete function, instead of chage treating pixelBuffer. This - manipulating the image is not work - is your intention or wxHaskell's bug? I was asked how to change this programm using 'PixelBufferCreate and pixelBufferDelete function' and this problem other mailing-list, then Answerer says "Is this wxHaskell's Bug ?". onPaint vbitmap dc viewArea = do mbBitmap <- varGet vbitmap case mbBitmap of Nothing -> dcClear dc -- Just bm -> drawBitmap dc bm pointZero False [] Just bm -> do bsz <- bitmapGetSize bm im <- imageCreateFromBitmap bm pxe <- imageGetPixelBuffer im let pixelPoint (Size ppx ppy) n = [Point x y | x <- [n..ppx-n], y <- [n..ppy-n]] let addRGB rgb1 rgb2 = colorFromInt $ (intFromColor rgb1) + (intFromColor rgb2) let drawLowpassFilter pb (Point szx szy) = do lowpass <- (lowpassFilter pxe (Point szx szy) bsz) pixelBufferSetPixel pb (Point szx szy) lowpass let fillpixelBuffer pb = do mapM_ (drawLowpassFilter pb) (pixelPoint bsz 0) return pb px2 <- fillpixelBuffer pxe im2 <-imageCreateFromPixelBuffer px2 bm2 <- bitmapCreateFromImage im2 (-1) bitmapDelete bm imageDelete im drawBitmap dc bm2 pointZero True [] where pixelColorInt pix (Point ptx pty) (Size szx szy) | ptx < 0 = pixelColorInt pix (Point 0 pty) (Size szx szy) | pty < 0 = pixelColorInt pix (Point ptx 0) (Size szx szy) | ptx > szx = pixelColorInt pix (Point ptx pty) (Size 0 szy) | pty < szy = pixelColorInt pix (Point ptx pty) (Size 0 szy) | otherwise = do pixel <- pixelBufferGetPixel pix (Point ptx pty) return (intFromColor pixel) lowpassFilter pix (Point szx szy) bound = do -- pixelsInt <- foldM (+) (pixelColorInt pix [Point x y | x <- [szx-n..szx+n], y <- [szy-n..szy+n]]) pix1 <- pixelColorInt pix (Point (szx-1) (szy-1)) bound pix2 <- pixelColorInt pix (Point (szx-1) (szy)) bound pix3 <- pixelColorInt pix (Point (szx-1) (szy+1)) bound pix4 <- pixelColorInt pix (Point (szx) (szy-1)) bound pix5 <- pixelColorInt pix (Point (szx) (szy)) bound pix6 <- pixelColorInt pix (Point (szx) (szy+1)) bound pix7 <- pixelColorInt pix (Point (szx+1) (szy-1)) bound pix8 <- pixelColorInt pix (Point (szx+1) (szy)) bound pix9 <- pixelColorInt pix (Point (szx+1) (szy+1)) bound let pixes = (pix1 + pix2 + pix3 + pix4 + pix5 + pix6 + pix7 + pix8 + pix9) `div` 9 return (colorFromInt pixes) -- (colorFromInt $ (pixelsInt / 9)) -- shelarcy <she...@ca...> http://page.freett.com/shelarcy/ |