[Gambas-user] Drawing

Benoit Minisini gambas at ...1...
Wed Apr 26 10:46:43 CEST 2006


On Wednesday 26 April 2006 10:39, Timothy Marshal-Nichols wrote:
> You must be using an older version of Gambas. The *= is just
> multiplication. Try:
>
>      imageWidth = imageWidth * scaleIsotropic
>      imageHeight = imageHeight * scaleIsotropic
>
> this the same code in long hand.
>
> The PrintImage code was to show you how to use the Resolution of the
> Printer and Desktop to find the required image/drawing size. Its just I had
> code to hand using a image that I knew worked. You can still Draw a
> Drawing.
>
> This is what you might get:
>
> PRIVATE SUB PrintDrawing(drw AS Drawing)
>   DIM drawingWidth AS Integer
>   DIM drawingHeight AS Integer
>   DIM scaleIsotropic AS Float
>   ' Display printer dialog
>   IF Printer.Setup() THEN RETURN
>   INC Application.Busy
>   ' Get drawing size for the printer resolution
>   drawingWidth = (drw.Width * Printer.Resolution) / Desktop.Resolution
>   drawingHeight = (drw.Height * Printer.Resolution) / Desktop.Resolution
>   ' Adjust drawing size if it does not fit on the printer page
>   IF drawingWidth > Printer.Width OR drawingHeight > Printer.Height THEN
>     ' Scale Isotropic, keep aspect ratio of the image
>     scaleIsotropic = Min(Printer.Width / drawingWidth, Printer.Height /
> drawingHeight)
>     drawingWidth *= scaleIsotropic
>     drawingHeight *= scaleIsotropic
>   END IF
>   'PRINT "Width: " & drawingWidth, drw.Width, Printer.Width
>   'PRINT "Height: " & drawingHeight, drw.Height, Printer.Height
>   ' Draw drawing centred on printer page
>   Draw.Begin(Printer)
>   'Draw.Rect((Printer.Width - drawingWidth) / 2, (Printer.Height -
> drawingHeight) / 2, drawingWidth, drawingHeight)
>   Draw.Drawing(drw, (Printer.Width - drawingWidth) / 2, (Printer.Height -
> drawingHeight) / 2, drawingWidth, drawingHeight)
>   Draw.End
>   DEC Application.Busy
> END
>
> Two points:
>
> 1. Convert the *= again!
>
> 2. On my system this still only prints the Drawing at the old resolution.
> You can see if you uncomment the Draw.Rect line that the calculation for
> the drawing size is correct. By setting the width and height the help says
> the drawing should be scaled. I think this has been fixed with later
> versions of Gambas as I know there has been some work the SVG code. (I was
> going to upgrade after installing SUES 10.1.)
>
> Also the scaling of a Drawing when drawing on a DrawingArea does not work -
> so it must be a problem with the Draw.Drawing method. If this method has
> not been fixed then you will never be able to print good image at the right
> size.
>
> Thanks
>
> 8-{)} Timothy Marshal-Nichols
> <mailto: timothy.marshal-nichols at ...247...>
>

If a kind people could make a little example of printing, I will put it with 
the other Gambas examples :-)

Regards,

-- 
Benoit Minisini





More information about the User mailing list