How to create a byte[] from a MemoryImageSource?

G

Greg Dameron

I need to output a byte[] buffer from a class that has access to a
MemoryImageSource and/or a BufferedImage. I need to be able to
somehow convert that to a byte array to pass on to another class.
Does anyone have an elegant way to convert from a bufferedimage (or
MIS) to a byte array?
Thanks!
Greg
 
A

ak

I need to output a byte[] buffer from a class that has access to a
MemoryImageSource and/or a BufferedImage. I need to be able to
somehow convert that to a byte array to pass on to another class.
Does anyone have an elegant way to convert from a bufferedimage (or
MIS) to a byte array?
MemoryImageSource takes byte or int array as argument
1) if it was byte array - nothing to convert
2) convert int array to byte array is easy work
If you have BufferedImage:
3) if you have BufferedImage than use getRGB() to get int array (see p. 2)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top