Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » SWT Image
SWT Image [message #269515] Wed, 18 March 2009 14:53 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
hello ng,
i am trying to modify an image and print it on my canvas after doing this.

so what i got now is simple copy of content from image 'originalImage' to
image 'manipulatedImage',
then draw image 'manipulatedImage' to canvas

private Image originalImage;
private Image manipulatedImage;

in my paintControl i am doing this:

// create array to fit all pixels
int[] pixels = new int[width*height];
// read content of the originalImage into pixels[]
originalImage.getImageData().getPixels(0, 0, pixels.length, pixels, 0);
// write content of pixels[] to the manipulatedImage
manipulatedImage.getImageData().setPixels(0, 0, pixels.length, pixels, 0);
// draw the manipulatedImage
e.gc.drawImage(manipulatedImage, 0, 0);

all fine till this ^^ as the image does not get drawed

note: if i write
e.gc.drawImage(originalImage, 0, 0);
the original image is drawn correct!

any ideas what i am doing wrong?
thanks in advance
Re: SWT Image [message #269524 is a reply to message #269515] Wed, 18 March 2009 15:31 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
update:

changed the code to:
int[] pixels = new int[width*height];
ImageData id = originalImage.getImageData();
id.getPixels(0, 0, pixels.length, pixels, 0);

manipulatedImage = new Image(this.getDisplay(), width, height);
ImageData id2 = manipulatedImage.getImageData();
id2.setPixels(0, 0, pixels.length, pixels, 0);
manipulatedImage = new Image(this.getDisplay(), id2);
e.gc.drawImage(manipulatedImage, 0, 0);
now the image gets copied, but the colors get corrupt...
Re: SWT Image [message #269528 is a reply to message #269515] Wed, 18 March 2009 15:52 Go to previous message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
this is verry strange for me.

it seems that it "strips" data!
i am now changing channels by hand
which results in a correct image, but i have no clue why
setting pixels which were grabbed with the get function results in a mess
(BUG?!)

greets
Previous Topic:Suitable architecture for a plugin project
Next Topic:word wrapping in text editor
Goto Forum:
  


Current Time: Sun Sep 01 08:27:18 GMT 2024

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

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

Back to the top