From: pablo p. <par...@ya...> - 2004-12-13 10:12:05
|
First of all, my english's very poor, sorry. I wanted to know if there is any form to transform what you paint in a panel to an image you can save. I want to use the functions to draw rectangles, which draw them in a panel, instead of using the functions that paint pixel to pixel. picture :: Window a -> Var Color -> Var Color -> Var Color -> Var Color -> Var Color -> Var Int -> Var Int -> Var Int -> Var Int -> Var Int -> IO () picture w cl1 cl2 cl3 cl4 current alt anc num altr ancr ... let rgbSize = sz an al im <- imageCreateSized rgbSize imv <- varCreate im bim <- bitmapCreateDefault bimv <- varCreate bim ... guardar <- button f [text := "Guardar",on command :=do imagen <-varGet imv; salvarimagen f imagen] ... p <- panel f [clientSize := sz an al] ... set p [on paint := pintarect imv bimv var] where pintarect imv bimv var dc viewArea = do v <- varGet var ... randomcolours cl1 cl2 cl3 cl4 current curre <- varGet current drawRect dc (Rect 6 44 100 50) [penWidth := 6, brushColor := curre] bim <- bitmapCreateDefault dcDrawBitmap dc bim pointZero True if (v==0) then do varSet bimv bim im <- imageCreateFromBitmap bim print v varSet imv im varSet var 1 else do print v bim <- varGet bimv drawBitmap dc bim pointZero True [] return () salvarimagen :: Dialog a -> Image a -> IO () --This is the dialog for saving the image Well, the code of pintarect is with print and other things to help me debugging. The function is supposed to draw random pictures, it's called with variables which will change in pintarect, I want they keep the same the next events of paint, but everytime there is an event of paint, the colours change. Other problem is when I save the file, it's always empty, I suppose it's because dcDrawBitmap doesn´t convert the dc to a bitmap, the name confused me. Is there any form to paint in the dc and save that to a file??? Thanks. ______________________________________________ Renovamos el Correo Yahoo!: ¡250 MB GRATIS! Nuevos servicios, más seguridad http://correo.yahoo.es |