[Gtk-sharp-list] Best way to build a zoom effect?
WCrucius at sandc.com
Fri Mar 17 00:12:41 EST 2006
Here's pretty much everything you'll need... Enjoy!
private System.Xml.XmlDocument _xmlDoc;
_xmlDoc = new System.Xml.XmlDocument();
<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)
int width, height;
Gdk.Pixmap pixmap, pixmap_mask;
// get the "available" width and height
width = eventBox.Allocation.Width;
height = eventBox.Allocation.Height;
nodeElem = xmlDoc.SelectSingleNode("//*[@id='svgRoot']"); // xpath search for the root element by id
nodeElem.Attributes.GetNamedItem("width").Value = width.ToString();
nodeElem.Attributes.GetNamedItem("height").Value = height.ToString();
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 );
From: gtk-sharp-list-bounces at lists.ximian.com on behalf of Julien Sobrier
Sent: Thu 3/16/2006 10:36 PM
Cc: gtk-sharp-list at lists.ximian.com
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.
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.
Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gtk-sharp-list