I have a client-server application. The server is pure Java, the client is an Android application. They communicate over TCP using a ServerSocket.
I want to create an Image on the server, edit it (e.g. draw lines on it) and then send it to the client to display it there as a Bitmap on the screen.
My first approach was to import the android.graphics.Bitmap library into the server to use it there, but of course since you can’t use Android libraries outside of an Android environment this can’t work.
My approach now is to use a BufferedImage on the server, but the problem is that I couldn’t find out how to serialize this in a way that the client can then reconstruct a Bitmap out of it. I tried using ImageIO.write, but then what do I have to do on the client-side?
Does anyone have an idea on how to solve this, or has a better approach?
I appreciate your help.
Any PNG or JPG image can be decoded in Android using the
BitmapFactoryclass. Get anInputStreamfor the image then useBitmapFactory.decodeStream(inputStream). It doesn’t need to be serialized specially…just send the bytes for the image.