-
Convert Images into a byte array.
Hi,
I need to know is there is a way to convert a Image into a array of bytes? I know a way using BufferedInputStream but that is loading a image from a file. I need to know a way to do it, if I already have an Image loaded in my class. Thanks in advance.
-
you could probably turn the picture into an array of bytes by serializing it. Something like...
public static byte[] serializeObj(Object obj) throws IOException
{
ByteArrayOutputStream baOStream = new ByteArrayOutputStream();
ObjectOutputStream objOStream = new ObjectOutputStream(baOStream);
objOStream.writeObject(obj); //object must be serializable
objOStream.flush();
objOStream.close();
return baOStream.toByteArray(); //returns stream as byte array
}
-
How to convert an image to a byte array in C#
Image im = ...
ImageConverter converter = new ImageConverter();
Byte[] imageByteArray = (byte[]) converter.ConvertTo(im, typeof(byte[]));
-
how to get coordinates of an image and convert into matrix or multidimensional array in array?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|