Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » non-transparent image transfer
non-transparent image transfer [message #506189] Wed, 06 January 2010 13:37 Go to next message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
Hello Groups,

I would like to copy an image to the system clipboard. the image contains a
chart created using the Birt chart engine. When pasting the image into a
Word document everything is fine. but when using an image editing programm
like Gimp everything background filled rectangle (like a grey chart
background) is transparent. It there any way to force copying a
non-transparent image to the clipboard?

My code to copy the image:
=======
final Display current = Display.getCurrent();
final Clipboard clipboard = new Clipboard(current);
final Image image = new Image(current, xRes, yRes);
final GC gc = new GC(image);
try {
final IDeviceRenderer render =
PluginSettings.instance().getDevice("dv.SWT");
render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
final Generator gr = Generator.instance();

final Point dpi = gc.getDevice().getDPI();
final GeneratedChartState state = gr.build(render.getDisplayServer(),
chart,
BoundsImpl.create(0, 0, xRes * 72 / dpi.x, yRes * 72 / dpi.y), null,
null, null);

gr.render(render, state);
} catch (final ChartException e) {
e.printStackTrace();
}

final ImageTransfer imageTransfer = ImageTransfer.getInstance();
clipboard.setContents(new Object[] { image.getImageData() },
new Transfer[] { imageTransfer });
=======

Thanks in Advance

Enrico
Re: non-transparent image transfer [message #506255 is a reply to message #506189] Wed, 06 January 2010 17:13 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Enrico,

Can you open a bug up on this? I tried it an it works fine in paint,
but I assume it works fine for you in paint as well.

please post the bug number once it is open.

Thanks

Jason

Enrico Schnepel wrote:
> Hello Groups,
>
> I would like to copy an image to the system clipboard. the image contains a
> chart created using the Birt chart engine. When pasting the image into a
> Word document everything is fine. but when using an image editing programm
> like Gimp everything background filled rectangle (like a grey chart
> background) is transparent. It there any way to force copying a
> non-transparent image to the clipboard?
>
> My code to copy the image:
> =======
> final Display current = Display.getCurrent();
> final Clipboard clipboard = new Clipboard(current);
> final Image image = new Image(current, xRes, yRes);
> final GC gc = new GC(image);
> try {
> final IDeviceRenderer render =
> PluginSettings.instance().getDevice("dv.SWT");
> render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
> final Generator gr = Generator.instance();
>
> final Point dpi = gc.getDevice().getDPI();
> final GeneratedChartState state = gr.build(render.getDisplayServer(),
> chart,
> BoundsImpl.create(0, 0, xRes * 72 / dpi.x, yRes * 72 / dpi.y), null,
> null, null);
>
> gr.render(render, state);
> } catch (final ChartException e) {
> e.printStackTrace();
> }
>
> final ImageTransfer imageTransfer = ImageTransfer.getInstance();
> clipboard.setContents(new Object[] { image.getImageData() },
> new Transfer[] { imageTransfer });
> =======
>
> Thanks in Advance
>
> Enrico
>
>
Re: non-transparent image transfer [message #506259 is a reply to message #506189] Wed, 06 January 2010 12:28 Go to previous messageGo to next message
Carolyn MacLeod is currently offline Carolyn MacLeodFriend
Messages: 149
Registered: July 2009
Senior Member
I'm not sure, but you could try:
...
ImageData data = image.getImageData();
data.transparentPixel = -1;
clipboard.setContents(new Object[] { imageData }, new Transfer[] {
imageTransfer });
...

Carolyn

"Enrico Schnepel" <enrico.schnepel@randomice.net> wrote in message
news:hi23mc$a3p$1@build.eclipse.org...
> Hello Groups,
>
> I would like to copy an image to the system clipboard. the image contains
> a chart created using the Birt chart engine. When pasting the image into a
> Word document everything is fine. but when using an image editing programm
> like Gimp everything background filled rectangle (like a grey chart
> background) is transparent. It there any way to force copying a
> non-transparent image to the clipboard?
>
> My code to copy the image:
> =======
> final Display current = Display.getCurrent();
> final Clipboard clipboard = new Clipboard(current);
> final Image image = new Image(current, xRes, yRes);
> final GC gc = new GC(image);
> try {
> final IDeviceRenderer render =
> PluginSettings.instance().getDevice("dv.SWT");
> render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
> final Generator gr = Generator.instance();
>
> final Point dpi = gc.getDevice().getDPI();
> final GeneratedChartState state = gr.build(render.getDisplayServer(),
> chart,
> BoundsImpl.create(0, 0, xRes * 72 / dpi.x, yRes * 72 / dpi.y),
> null, null, null);
>
> gr.render(render, state);
> } catch (final ChartException e) {
> e.printStackTrace();
> }
>
> final ImageTransfer imageTransfer = ImageTransfer.getInstance();
> clipboard.setContents(new Object[] { image.getImageData() },
> new Transfer[] { imageTransfer });
> =======
>
> Thanks in Advance
>
> Enrico
>
Re: non-transparent image transfer [message #506354 is a reply to message #506259] Thu, 07 January 2010 09:04 Go to previous messageGo to next message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
Hello Carolyn & Jason,

thanks for your response. I have testet the code but as you could see below
the attribute has already a value of -1.
@Jason: yes, it does work with Paint, but it isn't my favorite program to
edit images... ;-)

The attributes in the ImageData object have the following values:
data = ImageData {
alpha = -1
alphaData = null
bytesPerLine = 4096
data = {...}
delayTime = 0
depth = 32
disposalMethod = 0
height = 768
maskData = null
maskPad = 0
palette = PaletteData {
blueMask = -16777216
blueShift = -24
colors = null
greenMask = 16711680
greenShift = -16
isDirect = true
redMask = 65280
redShift = -8
}
scanlinePad = 4
transparentPixel = -1
type = -1
width = 1024
x = 0
y = 0
}

I would like to open a bug report but I couldn't find a SWT product. Shall I
put it in BIRT or somewhere else?

Enrico

"Carolyn MacLeod" <Carolyn_MacLeod@ca.ibm.com> schrieb im Newsbeitrag
news:hi2gvr$llj$1@build.eclipse.org...
> I'm not sure, but you could try:
> ...
> ImageData data = image.getImageData();
> data.transparentPixel = -1;
> clipboard.setContents(new Object[] { imageData }, new Transfer[] {
> imageTransfer });
> ...
>
> Carolyn
>
> "Enrico Schnepel" <enrico.schnepel@randomice.net> wrote in message
> news:hi23mc$a3p$1@build.eclipse.org...
>> Hello Groups,
>>
>> I would like to copy an image to the system clipboard. the image contains
>> a chart created using the Birt chart engine. When pasting the image into
>> a Word document everything is fine. but when using an image editing
>> programm like Gimp everything background filled rectangle (like a grey
>> chart background) is transparent. It there any way to force copying a
>> non-transparent image to the clipboard?
>>
>> My code to copy the image:
>> =======
>> final Display current = Display.getCurrent();
>> final Clipboard clipboard = new Clipboard(current);
>> final Image image = new Image(current, xRes, yRes);
>> final GC gc = new GC(image);
>> try {
>> final IDeviceRenderer render =
>> PluginSettings.instance().getDevice("dv.SWT");
>> render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
>> final Generator gr = Generator.instance();
>>
>> final Point dpi = gc.getDevice().getDPI();
>> final GeneratedChartState state = gr.build(render.getDisplayServer(),
>> chart,
>> BoundsImpl.create(0, 0, xRes * 72 / dpi.x, yRes * 72 / dpi.y),
>> null, null, null);
>>
>> gr.render(render, state);
>> } catch (final ChartException e) {
>> e.printStackTrace();
>> }
>>
>> final ImageTransfer imageTransfer = ImageTransfer.getInstance();
>> clipboard.setContents(new Object[] { image.getImageData() },
>> new Transfer[] { imageTransfer });
>> =======
>>
>> Thanks in Advance
>>
>> Enrico
>>
>
>
Re: non-transparent image transfer [message #506470 is a reply to message #506354] Thu, 07 January 2010 16:14 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Open the bug in BIRT if it needs to be moved we will move it.

Enrico Schnepel wrote:
> Hello Carolyn & Jason,
>
> thanks for your response. I have testet the code but as you could see below
> the attribute has already a value of -1.
> @Jason: yes, it does work with Paint, but it isn't my favorite program to
> edit images... ;-)
>
> The attributes in the ImageData object have the following values:
> data = ImageData {
> alpha = -1
> alphaData = null
> bytesPerLine = 4096
> data = {...}
> delayTime = 0
> depth = 32
> disposalMethod = 0
> height = 768
> maskData = null
> maskPad = 0
> palette = PaletteData {
> blueMask = -16777216
> blueShift = -24
> colors = null
> greenMask = 16711680
> greenShift = -16
> isDirect = true
> redMask = 65280
> redShift = -8
> }
> scanlinePad = 4
> transparentPixel = -1
> type = -1
> width = 1024
> x = 0
> y = 0
> }
>
> I would like to open a bug report but I couldn't find a SWT product. Shall I
> put it in BIRT or somewhere else?
>
> Enrico
>
> "Carolyn MacLeod" <Carolyn_MacLeod@ca.ibm.com> schrieb im Newsbeitrag
> news:hi2gvr$llj$1@build.eclipse.org...
>> I'm not sure, but you could try:
>> ...
>> ImageData data = image.getImageData();
>> data.transparentPixel = -1;
>> clipboard.setContents(new Object[] { imageData }, new Transfer[] {
>> imageTransfer });
>> ...
>>
>> Carolyn
>>
>> "Enrico Schnepel" <enrico.schnepel@randomice.net> wrote in message
>> news:hi23mc$a3p$1@build.eclipse.org...
>>> Hello Groups,
>>>
>>> I would like to copy an image to the system clipboard. the image contains
>>> a chart created using the Birt chart engine. When pasting the image into
>>> a Word document everything is fine. but when using an image editing
>>> programm like Gimp everything background filled rectangle (like a grey
>>> chart background) is transparent. It there any way to force copying a
>>> non-transparent image to the clipboard?
>>>
>>> My code to copy the image:
>>> =======
>>> final Display current = Display.getCurrent();
>>> final Clipboard clipboard = new Clipboard(current);
>>> final Image image = new Image(current, xRes, yRes);
>>> final GC gc = new GC(image);
>>> try {
>>> final IDeviceRenderer render =
>>> PluginSettings.instance().getDevice("dv.SWT");
>>> render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
>>> final Generator gr = Generator.instance();
>>>
>>> final Point dpi = gc.getDevice().getDPI();
>>> final GeneratedChartState state = gr.build(render.getDisplayServer(),
>>> chart,
>>> BoundsImpl.create(0, 0, xRes * 72 / dpi.x, yRes * 72 / dpi.y),
>>> null, null, null);
>>>
>>> gr.render(render, state);
>>> } catch (final ChartException e) {
>>> e.printStackTrace();
>>> }
>>>
>>> final ImageTransfer imageTransfer = ImageTransfer.getInstance();
>>> clipboard.setContents(new Object[] { image.getImageData() },
>>> new Transfer[] { imageTransfer });
>>> =======
>>>
>>> Thanks in Advance
>>>
>>> Enrico
>>>
>>
>
>
Re: non-transparent image transfer [message #506673 is a reply to message #506470] Fri, 08 January 2010 15:55 Go to previous message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
done so...
https://bugs.eclipse.org/bugs/show_bug.cgi?id=299138

Best Regards

Enrico

"Jason Weathersby" <jasonweathersby@windstream.net> schrieb im Newsbeitrag
news:hi513p$ujl$1@build.eclipse.org...
> Open the bug in BIRT if it needs to be moved we will move it.
>
> Enrico Schnepel wrote:
>> Hello Carolyn & Jason,
>>
>> thanks for your response. I have testet the code but as you could see
>> below the attribute has already a value of -1.
>> @Jason: yes, it does work with Paint, but it isn't my favorite program to
>> edit images... ;-)
>>
>> The attributes in the ImageData object have the following values:
>> data = ImageData {
>> alpha = -1
>> alphaData = null
>> bytesPerLine = 4096
>> data = {...}
>> delayTime = 0
>> depth = 32
>> disposalMethod = 0
>> height = 768
>> maskData = null
>> maskPad = 0
>> palette = PaletteData {
>> blueMask = -16777216
>> blueShift = -24
>> colors = null
>> greenMask = 16711680
>> greenShift = -16
>> isDirect = true
>> redMask = 65280
>> redShift = -8
>> }
>> scanlinePad = 4
>> transparentPixel = -1
>> type = -1
>> width = 1024
>> x = 0
>> y = 0
>> }
>>
>> I would like to open a bug report but I couldn't find a SWT product.
>> Shall I put it in BIRT or somewhere else?
>>
>> Enrico
>>
>> "Carolyn MacLeod" <Carolyn_MacLeod@ca.ibm.com> schrieb im Newsbeitrag
>> news:hi2gvr$llj$1@build.eclipse.org...
>>> I'm not sure, but you could try:
>>> ...
>>> ImageData data = image.getImageData();
>>> data.transparentPixel = -1;
>>> clipboard.setContents(new Object[] { imageData }, new Transfer[] {
>>> imageTransfer });
>>> ...
>>>
>>> Carolyn
>>>
>>> "Enrico Schnepel" <enrico.schnepel@randomice.net> wrote in message
>>> news:hi23mc$a3p$1@build.eclipse.org...
>>>> Hello Groups,
>>>>
>>>> I would like to copy an image to the system clipboard. the image
>>>> contains a chart created using the Birt chart engine. When pasting the
>>>> image into a Word document everything is fine. but when using an image
>>>> editing programm like Gimp everything background filled rectangle (like
>>>> a grey chart background) is transparent. It there any way to force
>>>> copying a non-transparent image to the clipboard?
>>>>
>>>> My code to copy the image:
>>>> =======
>>>> final Display current = Display.getCurrent();
>>>> final Clipboard clipboard = new Clipboard(current);
>>>> final Image image = new Image(current, xRes, yRes);
>>>> final GC gc = new GC(image);
>>>> try {
>>>> final IDeviceRenderer render =
>>>> PluginSettings.instance().getDevice("dv.SWT");
>>>> render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gc);
>>>> final Generator gr = Generator.instance();
>>>>
>>>> final Point dpi = gc.getDevice().getDPI();
>>>> final GeneratedChartState state = gr.build(render.getDisplayServer(),
>>>> chart,
>>>> BoundsImpl.create(0, 0, xRes * 72 / dpi.x, yRes * 72 / dpi.y),
>>>> null, null, null);
>>>>
>>>> gr.render(render, state);
>>>> } catch (final ChartException e) {
>>>> e.printStackTrace();
>>>> }
>>>>
>>>> final ImageTransfer imageTransfer = ImageTransfer.getInstance();
>>>> clipboard.setContents(new Object[] { image.getImageData() },
>>>> new Transfer[] { imageTransfer });
>>>> =======
>>>>
>>>> Thanks in Advance
>>>>
>>>> Enrico
>>>>
>>>
>>
Previous Topic:OpenSolaris: Eclipse/SWT hangs in GTK OS call when trying to change fonts
Next Topic:SWT printing capabilities- followup
Goto Forum:
  


Current Time: Fri Mar 29 09:13:15 GMT 2024

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

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

Back to the top