0

I have a BufferedImage (Type.TYPE_INT_ARGB) that I want to convert to a int[]. I do this by using the following method: ((DataBufferInt)src.getRaster().getDataBuffer()).getData();. But when I do this with an image, it gives me the wrong array size. For a 320 x 240 Image it makes a 57,600 size int[] when it should give me a 78,600 size array. Do you know what I am doing wrong?

0

1 Answer 1

1

What's wrong with

src.getRGB(0,0,image.getWidth(),image.getHeight(),null,0,1);
Sign up to request clarification or add additional context in comments.

5 Comments

I just use this way because it is the first way I learned. I'll try that now.
"That didn't work" is not helpful. Have a look at the javadoc and play with the parameters a bit - I don't have your code.
It turns out that the source image is supposed to be 320x240 but it is 240x240. My bad
Ugh. And I though I was up late.
It's slow, that's what's wrong with it. :-) (It's not a bad suggestion though, as it will always give the expected results, but at the expense of possible extra color conversion and always array copy).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.