Hi, I'm looking for a convenient way to make an applet snap shot. The only solution I came up with is to print to a pdf file and then convert it to an image.
I tried to draw the main contents to an offscree-drawable but it doesn't work for text and the background. (Code attached) Any suggestions? Friedger
{curl 2.0, 3.0 applet} {import * from CURL.UTIL.MIME-ASSOC} {define-proc {save visual:Graphic, save-to-file?:bool = false, filename:String = "image.jpg"}:void || calculate offset let x:Distance = 0pt let y:Distance = 0pt {if visual.parent != null then set (x,y)={transform-coordinates 0pt,0pt, visual.parent,visual} } {dump x,y} || get display context let gc = {visual.get-display-context} {if visual.layout == null then {throw {Exception "InvalidLayout"}} } || get bounds let bounds:GRect = {visual.layout.get-bounds} {output bounds.width, bounds.height} || create the offscreen stuff let (r2:Renderer2d, d:Drawable) = {Renderer2d.create-offscreen (bounds.width + 2 * visual.margin + 2* visual.border-width), (bounds.height+ 2 * visual.margin + 2* visual.border-width) , ||the resolution makes a difference in the jpg-file {max 300dpi, (1/(gc.pixel-size))} } ||-- clear is private ???? ||-- {d.clear color = {get-background visual}} {with-render-properties translation = {Distance2d -x, -y}, draw-operation = DrawOperation.mask on r2 do || {visual.draw r2} || paint with decorations doesn't help {visual.paint-with-decorations r2} ||-- {visual.draw r2} } let pm:Pixmap = {d.to-Pixmap} || I can't use the drawable from the actual view :( || let pm:Pixmap = {gc.drawable.to-Pixmap} {set pm.ignore-alpha? = true} {popup-message {Frame width = d.width, height = d.height, background = pm} } {d.destroy} {if save-to-file? then let image:ImageData = {ImageData} ||{ImageData.from-url {url "leer.jpg"}} ||-- {output image.properties.size} ||-- {for s key k in image.properties do ||-- {output s,k} ||-- } set image.pixmaps = {{Array-of Pixmap} pm } {image.save-to-url {url filename}, {non-null {file-extension-to-mime-type ".jpg"}}} } } {let f = {Frame vorigin = 0, horigin = 0, color = "red", "hello"}} {value {Frame border-width = 1pt, border-color = "white", f}} {after 1s do {save f} }
******************************************* To unsubscribe from this list, send a mail to: mailto:[EMAIL PROTECTED] To contact a human list administrator, send a mail to: mailto:[EMAIL PROTECTED] To recieve a list of other options for this list, send a mail to: mailto:[EMAIL PROTECTED]