开发者

how to draw a line on an encoded image in bb?

I want to draw a line on the encoded image so I will get a new image. Can you please give me information about that if you want ? Thank you very much. Here I give my code that I got the encoded image.

String URL = "http://maps.google.com/maps/api/staticmap?center="
        + centerX + "," + centerY + "&zoom=15&size=480x320&"
        + "path=color:0x0000ff|weight:5" + path 
        + "&maptype=roadmap&sensor=true;deviceside=true";

            try {
                conn = (HttpConnection) Connector.open(URL);
                stream = conn.openInputStream();
                byteArr开发者_运维技巧ay = new ByteArrayOutputStream();
                int dataToWrite = 0;
                while ((dataToWrite = stream.read()) != -1) {
                    byteArray.write(dataToWrite);
                }
                byte[] bArray = byteArray.toByteArray();
                EncodedImage image = 
                    EncodedImage.createEncodedImage(bArray, 0, bArray.length);
                imageBitmap = image.getBitmap();
                vfm.deleteAll();
                bitField = new BitmapField(imageBitmap);
                vfm.add(bitField);


  1. create a Graphics object

    Graphics graphics = new Graphics(imageBitmap);
    
  2. Invoke Graphics.drawLine() to draw line on that bitmap.

    graphics.drawLine(x1,y1,x2,y2);
    

Now imageBitmap is a new bitmap with line.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜