开发者

Sending image from server to client

How to send image from server to client thro开发者_开发百科ugh bluetooth in j2me?


If you are in control of both the server and client, then you don't need to worry about the complexities of OBEX. You can create your own lightweight protocol that does only what you need.

If you are new to Bluetooth on J2ME, start by reading about JSR 82. You'll want to create an RFCOMM/SPP connection between your client and server.

Next is the matter of sending an image over a serial connection in J2ME. If you have the image loaded as a javax.microedition.lcdui.Image, you'll need to obtain the ARGB pixel data using Image.getRGB().

This gives you an int array, which you'll need to send over the SPP connection (look at DataOutputStream.writeInt()), and rebuild at the other end using Image.createRGBImage().

HTH.


I've found the avetana Bluetooth libraries to be a bit unstable, and found BlueCove to be a better proposition. As mentioned, OBEX is the OBject EXchange protocol to use, and the docs are all over the internet.


If you look into "apps\BluetoothDemo\src\example\bluetooth\demo" folder of Sun WTK 2.5.x installation folder, you can find BTImageServer.java and BTImageClient.java source codes.

It uses serial profile to send image data from server to client. I think you can easily understand by looking it.


If you mean OBEX, try avetana (obex implementation on JSR-82) - it includes some example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜