SWT Image [message #269515] |
Wed, 18 March 2009 10:53  |
Eclipse User |
|
|
|
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 11:31   |
Eclipse User |
|
|
|
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 11:52  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.08155 seconds