[Gambas-user] Drawing

GuruLounge - MailLists maillists at ...1367...
Wed Apr 26 18:32:18 CEST 2006


I've a sub that takes an icon and overlays another icon on it using
draw:

------------------------------------------------------

PUBLIC FUNCTION MaskImages(myIcon AS Picture, myOverLayPath AS String)
AS Picture

DIM drawIcon AS picture
DIM wX AS Integer
DIM wY AS Integer

  wX = myIcon.Width
  wY = myIcon.Height
  
  drawIcon = NEW picture(wX,wY,TRUE)
  Draw.Begin(drawIcon)
    Draw.picture(myIcon,0,0)
    Draw.Picture(StretchImage(picture[myOverLayPath],wX,wY),0,0)
  Draw.End

  myIcon = NULL
  
  RETURN drawIcon

END
------------------------------------------------------
HTH
Jeff,

On Wed, 2006-04-26 at 13:50 +0000, javier romero wrote:
> Thanks very much for the help.
> 
> I have an aditional question, is possible to convert a Drawing or a DrawingArea into a Image or Picture?
> 
> Regards
> Javier
> 
> ----------------------------------------
> > From: timothy.marshal-nichols at ...247...
> > To: gambas-user at lists.sourceforge.net
> > Subject: RE: Re: [Gambas-user] Drawing
> > Date: Wed, 26 Apr 2006 09:39:23 +0100
> > 
> > 
> > 
> > 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...>
> > 
> > 
> > -----Original Message-----
> > From: gambas-user-admin at lists.sourceforge.net
> > [mailto:gambas-user-admin at lists.sourceforge.net]On Behalf Of javier
> > romero
> > Sent: Tuesday, 25 April 2006 19:24
> > To: gambas-user at lists.sourceforge.net
> > Subject: RE: Re: [Gambas-user] Drawing
> > 
> > 
> > I try to do that, but in
> > 
> >      imageWidth *= scaleIsotropic
> >      imageHeight *= scaleIsotropic
> > 
> > the interpreter sends an error.
> > there is any error in there?.
> > 
> > Also i need convert a drawing area into a image, how i can do that?
> > 
> > Thanks
> > Javier
> > ----------------------------------------
> > > From: timothy.marshal-nichols at ...247...
> > > To: gambas-user at lists.sourceforge.net
> > > Subject: RE: Re: [Gambas-user] Drawing
> > > Date: Mon, 24 Apr 2006 17:57:08 +0100
> > >
> > >
> > > This example shows how to print an image centred on the page. In includes
> > > code to scale an image for the printer resolution. If the image is the to
> > > large for the printer height or width resizes it to fit on the page -
> > > keeping the aspect ratio.
> > >
> > > You will need something like this only with a drawing.
> > >
> > > PRIVATE SUB PrintImage(img AS Image)
> > >   DIM imageToPrint AS Image
> > >   DIM imageWidth AS Integer
> > >   DIM imageHeight AS Integer
> > >   DIM scaleIsotropic AS Float
> > >   ' Dispaly printer dialog
> > >   IF Printer.Setup() THEN RETURN
> > >   INC Application.Busy
> > >   ' Get image size for the printer resolution
> > >   imageWidth = (img.Width * Printer.Resolution) / Desktop.Resolution
> > >   imageHeight = (img.Height * Printer.Resolution) / Desktop.Resolution
> > >   ' Adjust image size if it does not fit on the printer page
> > >   IF imageWidth > Printer.Width OR imageHeight > Printer.Height THEN
> > >     ' Scale Isotropic, keep aspect ratio of the image
> > >     scaleIsotropic = Min(Printer.Width / imageWidth, Printer.Height /
> > > imageHeight)
> > >     imageWidth *= scaleIsotropic
> > >     imageHeight *= scaleIsotropic
> > >   END IF
> > >   'PRINT "Width: " & imageToPrint, Printer.Width
> > >   'PRINT "Height: " & imageToPrint, Printer.Height
> > >   ' Scale image
> > >   imageToPrint = img.Stretch(imageWidth, imageHeight, TRUE)
> > >   ' Draw image centered on printer page
> > >   Draw.Begin(Printer)
> > >   Draw.Image(imageToPrint, (Printer.Width - imageWidth) / 2,
> > > (Printer.Height - imageHeight) / 2)
> > >   Draw.End
> > >   DEC Application.Busy
> > > END
> > >
> > >
> > > Thanks
> > >
> > > 8-{)} Timothy Marshal-Nichols
> > > <mailto: timothy.marshal-nichols at ...247...>
> > >
> > >
> > > -----Original Message-----
> > > From: gambas-user-admin at lists.sourceforge.net
> > > [mailto:gambas-user-admin at lists.sourceforge.net]On Behalf Of javier
> > > romero
> > > Sent: Monday, 24 April 2006 14:37
> > > To: gambas-user at lists.sourceforge.net
> > > Subject: RE: Re: [Gambas-user] Drawing
> > >
> > >
> > > Ok, thanks, its works but the print is very small, i try scaling with
> > this:
> > >
> > >    draw.Begin(printer)
> > >      draw.drawing(p1,350,350, Printer.Width, Printer.Height)
> > >    draw.End
> > >    but dosent works the print is the same, little, i try then with
> > >
> > >    draw.Begin(printer)
> > >      draw.drawing(p1,350,350, p1.Width, p1.Height)
> > >    draw.End
> > > and the same, very little, in both dont change
> > >
> > > How i scale?
> > >
> > > sorry about my very bad english
> > >
> > > Regards
> > > Javier
> > > ----------------------------------------
> > > > From: christian.faurebouvard at ...357...
> > > > To: gambas-user at lists.sourceforge.net
> > > > Subject: Re: [Gambas-user] Drawing
> > > > Date: Sat, 22 Apr 2006 17:50:15 -0400
> > > >
> > > > El Viernes 21 Abril 2006 09:48, javier romero escribió:
> > > > > PUBLIC p1 AS Drawing
> > > > > PUBLIC pag AS DrawingArea
> > > > >
> > > > > PUBLIC SUB _new()
> > > > >     p1 = NEW Drawing
> > > > >     draw.Begin(p1)
> > > > >       draw.Text("Hello", 0, 0)
> > > > >     draw.End
> > > > >
> > > > > END
> > > > >
> > > > > PUBLIC SUB Form_Open()
> > > > >
> > > > > pag = NEW DrawingArea(sv1)
> > > > >
> > > > >   pag.Cached = TRUE
> > > > >   pag.Clear
> > > > >   pag.BackColor = color.White
> > > > >   pag.Width = printer.Width
> > > > >   pag.Height = printer.Height
> > > > >   pag.Border = 1
> > > > >   draw.Begin(pag)
> > > > >     draw.Drawing(p1, 0, 0)
> > > > >   draw.End
> > > > > ' This works OK
> > > > >   pag.Visible = TRUE
> > > > >
> > > > > END
> > > > >
> > > > > PUBLIC SUB Button1_Click()
> > > > >
> > > > >   draw.Begin(printer)
> > > > >     draw.drawing(p1,0,0, pag.Width, pag.Height)
> > > > >   draw.End
> > > > > ' This doesn't works
> > > > > END
> > > >
> > > > Hi Javier,
> > > >
> > > > Some printers can't print in (0,0)
> > > > Try
> > > >  draw.drawing(p1, 350, 350)
> > > >
> > > > it work, but very small, need to be scaled.
> > > >
> > > > Regards,
> > > > Christian
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > 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=k&kid0709&bid&3057&dat1642
> > > > _______________________________________________
> > > > Gambas-user mailing list
> > > > Gambas-user at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > > _________________________________________________________________
> > > Descarga gratis la Barra de Herramientas de MSN
> > >
> > http://www.msn.es/usuario/busqueda/barra?XAPID=2031&DI=1055&SU=http%3A//www.
> > > hotmail.com&HL=LINKTAG1OPENINGTEXT_MSNBH
> > >
> > > -------------------------------------------------------
> > > 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=k&kid0709&bid&3057&dat1642
> > > _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > 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
> > 
> > _________________________________________________________________
> > Descarga gratis la Barra de Herramientas de MSN
> > http://www.msn.es/usuario/busqueda/barra?XAPID=2031&DI=1055&SU=http%3A//www.
> > hotmail.com&HL=LINKTAG1OPENINGTEXT_MSNBH
> > 
> > -------------------------------------------------------
> > 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=k&kid0709&bid&3057&dat1642
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > 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
> 
> _________________________________________________________________
> Descarga gratis la Barra de Herramientas de MSN
> http://www.msn.es/usuario/busqueda/barra?XAPID=2031&DI=1055&SU=http%3A//www.hotmail.com&HL=LINKTAG1OPENINGTEXT_MSNBH
> 
> -------------------------------------------------------
> 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_______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
-- 

     .^.
     /V\
    /( )\
    ^^-^^
Linux Advocate





More information about the User mailing list