Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » SWT to Image
SWT to Image [message #191233] Tue, 09 August 2005 15:38 Go to next message
Eclipse UserFriend
Originally posted by: renjitheclipse.yahoo.com

Iam trying to capture the image of an SWT widget into a ImageFigure so it
can be displayed on GEF. Has any one done this successfully. I am only
able to capture this when the widget is visible.

Shell shell2=new Shell();
org.eclipse.swt.widgets.Button button=new
org.eclipse.swt.widgets.Button(shell2,SWT.SIMPLE);

GC gc=new GC(button);

button.setBounds(0,0,100,20);

Image img=new
Image(shell.getDisplay(),button.getBounds().width,button.get Bounds().height);

gc.copyArea(img,0,0);
ImageFigure imgFig=new ImageFigure(img);
panel.add(imgFig);

This works as longs as the spinner is visible on screen. But I need to
have this hidden. When I tried, button.setBounds(-1000,-1000,100,20), it
is not able to capture the image since it is not visible.

Any ideas?
Re: SWT to Image [message #191249 is a reply to message #191233] Tue, 09 August 2005 17:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Renjith" <renjitheclipse@yahoo.com> wrote in message
news:c5d878f51b97870fa07a706925e02399$1@www.eclipse.org...
> Iam trying to capture the image of an SWT widget into a ImageFigure so it
> can be displayed on GEF. Has any one done this successfully. I am only
> able to capture this when the widget is visible.
>
> Shell shell2=new Shell();
> org.eclipse.swt.widgets.Button button=new
> org.eclipse.swt.widgets.Button(shell2,SWT.SIMPLE);
>
> GC gc=new GC(button);
>
> button.setBounds(0,0,100,20);
>
> Image img=new
> Image(shell.getDisplay(),button.getBounds().width,button.get Bounds().height);
>
> gc.copyArea(img,0,0);
> ImageFigure imgFig=new ImageFigure(img);
> panel.add(imgFig);
>
> This works as longs as the spinner is visible on screen. But I need to
> have this hidden. When I tried, button.setBounds(-1000,-1000,100,20), it
> is not able to capture the image since it is not visible.
>
SWT does not support scraping of hidden controls, or even of hidden portions
of partially visible controls.
So, if you need it hidden, then you are out of luck.
What you could do is create the widget, scrape it, then dispose it
immediately.
That way you have the image and the widget is gone.
---
Sunil
Re: SWT to Image [message #191277 is a reply to message #191233] Tue, 09 August 2005 19:39 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The VE project can tell you everything you need to know about screen
scraping. Ask on their newsgroup.
Previous Topic:Invoking A Command
Next Topic:which TreeViewer should I use? jFace or GEF
Goto Forum:
  


Current Time: Thu Dec 12 17:24:46 GMT 2024

Powered by FUDForum. Page generated in 0.03947 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top