I am writing some code which already gets the pixel array from an image, I then alter the pixel values. How do I now display this new pixel array as an image? I hope someone can help.

Thank you

Here's a good starting point, but you'll have to adapt it to your specific code...

public static Image getImageFromArray(int[] pixels, int width, int height) {
            BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
            WritableRaster raster = (WritableRaster) image.getData();
            raster.setPixels(0,0,width,height,pixels);
            return image;
        }

( adjust the image type (INT_RGB etc) as required )

Hi James there is some more problems I'm having with parts of my code.because there is quite a lot I was wondering if it would be possible to send it through to you via email?if that's ok by you.
Thanks

Sorry man, I don't do anything via PM or email.
Try posting the relevant bits here and there are plenty of people (me included) willing to try to help.

I am implementing an FFT class. I get the pixel data from an image then pass this to the FFT class. Once I apply the fast fourier transform to the array the result is an array of complex numbers. At the moment I convert the array of complex number to ints and display it via the MemoryImageSource:

MemoryImageSource src = new MemoryImageSource(grabbing.getWidth(), grabbing.getHeight(), newNumbers, 0, grabbing.getWidth());

However I would like to display the original array so no information is lost but the MemoryImageSource only takes int arrays. Does you know of a different way I can display these images?

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.