Title: RE: [Gtk-sharp-list] Best way to build a zoom effect?

Here's pretty much everything you'll need... Enjoy!

Wes



<method variables>  
   private System.Xml.XmlDocument _xmlDoc;

<initialization>
   _xmlDoc = new System.Xml.XmlDocument();
   _xmlDoc.Load(SVGFileName);
        
<Called from the SizeAllocated event for the Gtk.ScrolledWin that contains the passed in Gtk.EventBox>
   private void RenderSVG(ref System.Xml.XmlDocument xmlDoc, ref Gtk.EventBox eventBox)
   {     
    XmlNode nodeElem;

    int width, height;
    Gdk.Pixmap pixmap, pixmap_mask;
    Gdk.Pixbuf pixbuf;

      // get the "available" width and height   
      width = eventBox.Allocation.Width;
      height = eventBox.Allocation.Height;

      try
      {
         nodeElem = xmlDoc.SelectSingleNode("//[EMAIL PROTECTED]'svgRoot']");  // xpath search for the root element by id
         nodeElem.Attributes.GetNamedItem("width").Value = width.ToString();
         nodeElem.Attributes.GetNamedItem("height").Value = height.ToString();
       }
       catch(Exception ex)
       {
          Console.WriteLine("Error updating SVG size properties: ");
          Console.WriteLine("  " + ex.Message );
       }

      // render the SVG into a pixbuf     
      System.IO.MemoryStream streamSVG = new System.IO.MemoryStream();
      xmlDoc.Save(streamSVG);  // put the XML doc in a Stream
      streamSVG.Position = 0;     // reset the stream once written, this is IMPORTANT!              

      pixbuf = new Gdk.Pixbuf(streamSVG);
      pixbuf.RenderPixmapAndMask(out pixmap, out pixmap_mask, 0 );
      eventBox.GdkWindow.SetBackPixmap( pixmap, false );

   }




-----Original Message-----
From: [EMAIL PROTECTED] on behalf of Julien Sobrier
Sent: Thu 3/16/2006 10:36 PM
Cc: [email protected]
Subject: Re: [Gtk-sharp-list] Best way to build a zoom effect?

Crucius, Wesley wrote:
> I'd suggest using Inkscape to draw the text and save it as an SVG
> document and then use Gdk.Pixbuf to load and render to a bitmap.  If the
> text is static you can just use the ".svg file load with scaling
> version" of the constructor, otherwise, load the svg into an XML DOM
> doc, manipulate the width & height attributes of the SVG within the DOM
> (to scale it), save it as an XMLStream, and then use the stream version
> of the Pixbuf constructor.
>
> I've done it both ways, so I know either one will work, however it is a
> bit CPU intensive.
>
> Wes

Thanks. I'll try that. And I guess I still need to modify the picture
size every x milliseconds.

I'm not familiar with the XML library of Mon, and I can't find the "XML
DOM doc". I guess it should be in the class System.XML, but I don't know
in which class.


Thank you
Julien
_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list


_______________________________________________
Gtk-sharp-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
  • [Gtk-sharp-l... Julien Sobrier
    • RE: [Gt... Crucius, Wesley
      • Re:... Julien Sobrier
        • ... Crucius, Wesley
          • ... Julien Sobrier
            • ... Jorge Monsalvo
              • ... Victor Rafael Rivarola Soerensen (FANATICO y LOCO por Cristo)
                • ... Jorge Monsalvo
                • ... Jorge Monsalvo
                • ... Victor Rafael Rivarola Soerensen (FANATICO y LOCO por Cristo)
              • ... Mario Carrión
                • ... Jorge Monsalvo

Reply via email to