如何在bb中的编码图像上画一条线?

时间:2011-03-23 18:48:10

标签: blackberry java-me drawing

我想在编码图像上画一条线,这样我就会得到一个新图像。如果你愿意,能否告诉我有关的信息? 非常感谢你。 在这里,我给出了我获得编码图像的代码。

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();
                byteArray = 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 个答案:

答案 0 :(得分:1)

  1. 创建Graphics对象

    Graphics graphics = new Graphics(imageBitmap);
    
  2. 调用Graphics.drawLine()在该位图上绘制线条。

    graphics.drawLine(x1,y1,x2,y2);
    
  3. 现在imageBitmap是一个带线的新位图。