Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to capture image of a composite
How to capture image of a composite [message #453812] Sun, 10 April 2005 22:01 Go to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Hello,

I have a composite and I am trying to take a snapshot of this
programmatically.

Image im = new Image(composite.getDisplay(),
composite.getClientArea().width,composite.getClientArea().he ight);

How do I draw the contents of the composite into the image?

The GEF newgroup has an example but uses classes that are available for GEF.

TIA
-chhil
Re: How to capture image of a composite [message #453819 is a reply to message #453812] Mon, 11 April 2005 12:22 Go to previous messageGo to next message
Charlie Surface is currently offline Charlie SurfaceFriend
Messages: 40
Registered: July 2009
Member
Create a GC on the thing you want to copy, then call copyArea().

Charlie


Chhil wrote:

> Hello,
>
> I have a composite and I am trying to take a snapshot of this
> programmatically.
>
> Image im = new Image(composite.getDisplay(),
> composite.getClientArea().width,composite.getClientArea().he ight);
>
> How do I draw the contents of the composite into the image?
>
> The GEF newgroup has an example but uses classes that are available for
> GEF.
>
> TIA
> -chhil
Re: How to capture image of a composite [message #453823 is a reply to message #453812] Mon, 11 April 2005 13:43 Go to previous messageGo to next message
Jeff Myers is currently offline Jeff MyersFriend
Messages: 396
Registered: July 2009
Senior Member
Chhil,

See this snippet:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet95.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup

- Jeff

Chhil wrote:
> Hello,
>
> I have a composite and I am trying to take a snapshot of this
> programmatically.
>
> Image im = new Image(composite.getDisplay(),
> composite.getClientArea().width,composite.getClientArea().he ight);
>
> How do I draw the contents of the composite into the image?
>
> The GEF newgroup has an example but uses classes that are available for
> GEF.
>
> TIA
> -chhil
Re: How to capture image of a composite [message #453825 is a reply to message #453819] Mon, 11 April 2005 14:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Charlie Surface wrote:
> Create a GC on the thing you want to copy, then call copyArea().
>
> Charlie
>
>
> Chhil wrote:
>
>> Hello,
>>
>> I have a composite and I am trying to take a snapshot of this
>> programmatically.
>>
>> Image im = new Image(composite.getDisplay(),
>> composite.getClientArea().width,composite.getClientArea().he ight);
>>
>> How do I draw the contents of the composite into the image?
>>
>> The GEF newgroup has an example but uses classes that are available
>> for GEF.
>>
>> TIA
>> -chhil
Hi Charlie,

I did try the copyarea and for some reason it ended up taking a snapshot
of my desktop. I am going to try what Gef suggested below.

Thank You for your feedback.
-Chhil
Re: How to capture image of a composite [message #453832 is a reply to message #453823] Mon, 11 April 2005 17:43 Go to previous message
Eclipse UserFriend
Originally posted by: aaa.domain.invalid

Jeff Myers wrote:
> Chhil,
>
> See this snippet:
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet95.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup
>
>
> - Jeff
>
> Chhil wrote:
>
>> Hello,
>>
>> I have a composite and I am trying to take a snapshot of this
>> programmatically.
>>
>> Image im = new Image(composite.getDisplay(),
>> composite.getClientArea().width,composite.getClientArea().he ight);
>>
>> How do I draw the contents of the composite into the image?
>>
>> The GEF newgroup has an example but uses classes that are available
>> for GEF.
>>
>> TIA
>> -chhil
Hello,

I followed the procedure in the example and I did get it to work but the
image quality for the jpeg was very bad.
Then I tried to save it as a GIF and got a

org.eclipse.swt.SWTException: Unsupported color depth

The bitmap format looke the best.

What do I need to do to save its a good quality JPEG or GIF?

-Chhil
Previous Topic:How to change button background color?
Next Topic:Multiple selection in ComboBoxPropertyDescriptor
Goto Forum:
  


Current Time: Thu Feb 25 16:56:58 GMT 2021

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

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

Back to the top