Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Create Image from Composite for printing
Create Image from Composite for printing [message #466860] Wed, 18 January 2006 15:40 Go to next message
Steve is currently offline SteveFriend
Messages: 29
Registered: July 2009
Junior Member
I would like to print the contents of my Composite. To do this, I was going
to convert the Composite to an Image and then print the image. I used this
snippet from http://www.eclipse.org/swt/faq.php#noprintimage as a guide:

// Take the snapshot into a display Image
Point size = myWidget.getSize();
Image image = new Image(display, size.x, size.y);
GC gc = new GC(myWidget);
gc.copyArea(image, 0, 0);
gc.dispose();

// Get the ImageData and create a new printer Image from it
ImageData imageData = image.getImageData();
Image printImage = new Image(printer, imageData);

This work well if the entire Composite is visible. If the Composite has
scroll bars, only the portion of the Composite that is showing is included
in the Image. Is there a way to create an Image from a Composite such that
the Image contains the entire contents of the composite and not just the
part that is visible?

Thanks,
Steve
Re: Create Image from Composite for printing [message #466861 is a reply to message #466860] Wed, 18 January 2006 16:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

Steve <spbgamer@yahoo.com> wrote:
> I would like to print the contents of my Composite. To do this, I
> was going to convert the Composite to an Image and then print the
> image. I used this snippet from
> http://www.eclipse.org/swt/faq.php#noprintimage as a guide:
>
> // Take the snapshot into a display Image
> Point size = myWidget.getSize();
> Image image = new Image(display, size.x, size.y);
> GC gc = new GC(myWidget);
> gc.copyArea(image, 0, 0);
> gc.dispose();
>
> // Get the ImageData and create a new printer Image from it
> ImageData imageData = image.getImageData();
> Image printImage = new Image(printer, imageData);
>
> This work well if the entire Composite is visible. If the Composite
> has scroll bars, only the portion of the Composite that is showing is
> included in the Image. Is there a way to create an Image from a
> Composite such that the Image contains the entire contents of the
> composite and not just the part that is visible?
>
Not without resorting to native calls.
SWT does not support offscreen or hidden widget painting.

--
Sunil
Re: Create Image from Composite for printing [message #467076 is a reply to message #466861] Tue, 24 January 2006 15:03 Go to previous messageGo to next message
Steve is currently offline SteveFriend
Messages: 29
Registered: July 2009
Junior Member
Sunil,
Thanks for the quick response. I have been playing with this a lot over the
past few days hoping that someting might work. Is it possible to do this
with a new Display or a hidden Shell or some kind of Canvas..., something?
I've heard that the Visual Editor does something like this, putting the SWT
widgets on a hidden Shell(?). Any ideas.

Thanks,
Steve

"Sunil Kamath" <sunil_kamath@nohotspammail.com> wrote in message
news:dqlpvn$v47$1@utils.eclipse.org...
> Steve <spbgamer@yahoo.com> wrote:
> > I would like to print the contents of my Composite. To do this, I
> > was going to convert the Composite to an Image and then print the
> > image. I used this snippet from
> > http://www.eclipse.org/swt/faq.php#noprintimage as a guide:
> >
> > // Take the snapshot into a display Image
> > Point size = myWidget.getSize();
> > Image image = new Image(display, size.x, size.y);
> > GC gc = new GC(myWidget);
> > gc.copyArea(image, 0, 0);
> > gc.dispose();
> >
> > // Get the ImageData and create a new printer Image from it
> > ImageData imageData = image.getImageData();
> > Image printImage = new Image(printer, imageData);
> >
> > This work well if the entire Composite is visible. If the Composite
> > has scroll bars, only the portion of the Composite that is showing is
> > included in the Image. Is there a way to create an Image from a
> > Composite such that the Image contains the entire contents of the
> > composite and not just the part that is visible?
> >
> Not without resorting to native calls.
> SWT does not support offscreen or hidden widget painting.
>
> --
> Sunil
>
>
Re: Create Image from Composite for printing [message #467091 is a reply to message #467076] Tue, 24 January 2006 17:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

Steve <spbgamer@yahoo.com> wrote:
> Sunil,
> Thanks for the quick response. I have been playing with this a lot
> over the past few days hoping that someting might work. Is it
> possible to do this with a new Display or a hidden Shell or some kind
> of Canvas..., something? I've heard that the Visual Editor does
> something like this, putting the SWT widgets on a hidden Shell(?).
> Any ideas.
>

VE uses native code for screen capture of widgets.
e.g., for Windows, you would send the WM_PRINT message to the control with
the handle of the gc for an Image.
org.eclipse.swt.internal.win32.OS.SendMessage (control.handle, OS.WM_PRINT,
gc.handle, OS.PRF_NONCLIENT | OS.PRF_CLIENT | OS.PRF_ERASEBKGND |
OS.PRF_CHILDREN);

There are similar native calls for other operating and windowing systems.

--
Sunil
Re: Create Image from Composite for printing [message #467402 is a reply to message #467091] Mon, 30 January 2006 21:59 Go to previous messageGo to next message
Steve is currently offline SteveFriend
Messages: 29
Registered: July 2009
Junior Member
Sunil,
Thanks for all the help. I was able to get the SendMessage() to do what I
want. Your snippet gave me some good search criteria for Google. But, I
can't seem to find anything for the other OS's (Linux, Mac, ....). You made
mention of similar native calls for other operating systems. Can you give
me a little more information. This is all new to me and I appreciate the
help.
Thanks,
Steve

"Sunil Kamath" <sunil_kamath@nohotspammail.com> wrote in message
news:dr5mss$j8u$1@utils.eclipse.org...
> Steve <spbgamer@yahoo.com> wrote:
> > Sunil,
> > Thanks for the quick response. I have been playing with this a lot
> > over the past few days hoping that someting might work. Is it
> > possible to do this with a new Display or a hidden Shell or some kind
> > of Canvas..., something? I've heard that the Visual Editor does
> > something like this, putting the SWT widgets on a hidden Shell(?).
> > Any ideas.
> >
>
> VE uses native code for screen capture of widgets.
> e.g., for Windows, you would send the WM_PRINT message to the control with
> the handle of the gc for an Image.
> org.eclipse.swt.internal.win32.OS.SendMessage (control.handle,
OS.WM_PRINT,
> gc.handle, OS.PRF_NONCLIENT | OS.PRF_CLIENT | OS.PRF_ERASEBKGND |
> OS.PRF_CHILDREN);
>
> There are similar native calls for other operating and windowing systems.
>
> --
> Sunil
>
>
Re: Create Image from Composite for printing [message #467406 is a reply to message #467402] Mon, 30 January 2006 22:40 Go to previous message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

Steve <spbgamer@yahoo.com> wrote:
> Sunil,
> Thanks for all the help. I was able to get the SendMessage() to do
> what I want. Your snippet gave me some good search criteria for
> Google. But, I can't seem to find anything for the other OS's
> (Linux, Mac, ....). You made mention of similar native calls for
> other operating systems. Can you give me a little more information.
> This is all new to me and I appreciate the help.
> Thanks,
> Steve
>

For other OSes, check out the VE sources.
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.ve.swt/ ?cvsroot=Tools_Project
---
Sunil

> "Sunil Kamath" <sunil_kamath@nohotspammail.com> wrote in message
> news:dr5mss$j8u$1@utils.eclipse.org...
>> Steve <spbgamer@yahoo.com> wrote:
>>> Sunil,
>>> Thanks for the quick response. I have been playing with this a lot
>>> over the past few days hoping that someting might work. Is it
>>> possible to do this with a new Display or a hidden Shell or some
>>> kind of Canvas..., something? I've heard that the Visual Editor does
>>> something like this, putting the SWT widgets on a hidden Shell(?).
>>> Any ideas.
>>>
>>
>> VE uses native code for screen capture of widgets.
>> e.g., for Windows, you would send the WM_PRINT message to the
>> control with the handle of the gc for an Image.
>> org.eclipse.swt.internal.win32.OS.SendMessage (control.handle,
>> OS.WM_PRINT, gc.handle, OS.PRF_NONCLIENT | OS.PRF_CLIENT |
>> OS.PRF_ERASEBKGND | OS.PRF_CHILDREN);
>>
>> There are similar native calls for other operating and windowing
>> systems.
>>
>> --
>> Sunil

--
Sunil
Previous Topic:slow treeitem dispose time
Next Topic:Are windows modal dialog boxes supported on Mac OS X
Goto Forum:
  


Current Time: Thu Apr 25 13:08:41 GMT 2024

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

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

Back to the top