[Gambas-user] Drawing
Timothy Marshal-Nichols
timothy.marshal-nichols at ...247...
Sat Apr 29 16:26:29 CEST 2006
> -----Original Message-----
> From: gambas-user-admin at lists.sourceforge.net
> [mailto:gambas-user-admin at lists.sourceforge.net]On Behalf Of Benoit
> Minisini
> Sent: Wednesday, 26 April 2006 09:47
> To: gambas-user at lists.sourceforge.net
> Subject: Re: [Gambas-user] Drawing
>
>
> 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
>
>
>
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make
> your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
I have created a project to demonstrate the printing of text, images and
drawings.
There is one problem. This is with the drawing of a SVG file. When you call
Draw.Drawing it always draws the SVG file at the same size. For example the
following:
Draw.Drawing(SVGDrawing, 10, 10, 110, 110)
and
Draw.Drawing(SVGDrawing, 10, 10, 210, 210)
produces drawings at the original size of the drawing. The help says you
setting the width and height should scale the drawing. Setting the width and
height appears to have no effect. This means when printing you always get a
thumbnail whether you want it or not.
(You could convert to a Picture, then a Image, then scale, then print. But
this would not scale very well for printing.)
At first the thought this was just a problem with the version of gambas I
was using (1.9.17). But I also created a version of this project in the
stable version Gambas 1.0.15. The problem also appears to be in that version
also. So now I am now thinking the bug is in both versions 1 and 2 of
Gambas.
Try out the example. In ModulePrinting look at the procedure PrintDrawing.
If you uncomment the line Draw.Rect... you can see the size the SVG size
should print out at.
Thanks
8-{)} Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Printing.Gambas2.V0.0.1.tar
Type: application/x-tar
Size: 81920 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20060429/fb61d0eb/attachment.tar>
More information about the User
mailing list