SWT Image [message #269515] |
Wed, 18 March 2009 14:53 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Ludwig Moser![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=luke2000%40gmx.at) 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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Ludwig Moser![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=luke2000%40gmx.at) 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...
|
|
|
|
Powered by
FUDForum. Page generated in 0.08961 seconds