Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] HTML To Image tool


Hi Roland,

(note that swt usage questions should be asked on the eclipse.platform.swt newsgroup)

There isn't currently a way to do what you want without making the browser visible.  This question has come up in the past with other widgets, so there may be an existing Feature Request for the ability to do this, but I can't find it at the moment, so if you want you can log a new one with Platform - SWT and specify the Browser as the widget that you're interested in.

Regarding the vertical scrollbar, the underlying browser is in control of this, so there is not an swt style or api that can set its visibility.  The only way to control this is if you're providing the content being shown, in which case you can use <body style='overflow:hidden;'> or <body style='overflow:auto;'> .

Grant




Roland Auckenthaler <Roland_Auckenthaler@xxxxxxxx>
Sent by: platform-swt-dev-bounces@xxxxxxxxxxx

03/27/2006 11:13 AM

Please respond to
"Eclipse Platform SWT component developers list."

To
platform-swt-dev@xxxxxxxxxxx
cc
Subject
[platform-swt-dev] HTML To Image tool






Hi All,

Today i was writing an HTML to image rendering tool using the SWT which works pretty well so far. I have attached to code here too. To this little app i ahve a couple of questions which i wasnt able to do yet.


- capturing a widget image when not visible. When i capture the rendered HTML from the browser widget i need to be visible. I tried to minimize the visibility to only a couple of lines ( see the capture method) but would like to be fully invisible when capturing.


- vertical scroll bar. I cannot get rid of the vertical scroll bar when capturing at the moment i reduce the capturing area by 18 pixels (see capture metohd) but ideally i would prefer not to do that. Is there a way around that?


It would be nice if somebody could give some help on these two questions.


Thanks in advance


roland


public class DocumentationViewer

{

   private Display display;

   private Shell shell;

   private Browser browser;

   private boolean completed = false;

   
   public DocumentationViewer(String a_Url)

   {

       display = new Display();

       shell = new Shell(display);

       shell.setVisible(false);

       shell.setLayout(new FillLayout());


       browser = new Browser(shell, SWT.EMBEDDED | SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE);

       browser.setUrl(a_Url);

       browser.addProgressListener(new BrowserProgress());  

       
       while (!shell.isDisposed())

       {

           if (!display.readAndDispatch())

           {

               if (completed)

               {

                   capture();

                   completed = false;

               }

               display.sleep();

           }

       }

       display.dispose();

   }

   
   private void capture()

   {

       final GC gc = new GC(browser);

       shell.setVisible(true);

       Point size = browser.getSize();

       final Image image = new Image(display, size.x-18, size.y);

       gc.copyArea(image, 0, 0);

       shell.setVisible(false);

       
       final ImageLoader imageLoader = new ImageLoader();

       imageLoader.data = "" ImageData[] {image.getImageData()};

       imageLoader.save("D:\\foo1.jpg", SWT.IMAGE_JPEG);

       gc.dispose();

       image.dispose();

       System.out.println("captured");

   }

   
   public static void main(String argv[])

       throws Exception

   {

       new DocumentationViewer("http://www.google.com");

   }

   
   public class BrowserProgress implements ProgressListener

   {

       public void changed(ProgressEvent a_Event)

       {

       }


       public void completed(ProgressEvent a_Event)

       {

           completed = true;

       }

   }
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


Back to the top