私はJavaとBlackberryの開発に比較的慣れていないので、少し苦労しています。画面上のURLから画像を読み込んで表示しようとしています。画像を取得するために使用しているコードは次のとおりです。
public static Bitmap connectServerForImage(String url) {
HttpConnection httpConnection = null;
DataOutputStream httpDataOutput = null;
InputStream httpInput = null;
int rc;
Bitmap bitmp = null;
try {
httpConnection = (HttpConnection) Connector.open("http://upload.wikimedia.org/wikipedia/en/thumb/b/bd/AA_Reckless_%26_Relentless.jpg/220px-AA_Reckless_%26_Relentless.jpg");
rc = httpConnection.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}
httpInput = httpConnection.openInputStream();
InputStream inp = httpInput;
byte[] b = IOUtilities.streamToBytes(inp);
EncodedImage hai = EncodedImage.createEncodedImage(b, 0, b.length);
return hai.getBitmap();
} catch (Exception ex) {
System.out.println("URL Bitmap Error........" + ex.getMessage());
} finally {
try {
if (httpInput != null)
httpInput.close();
if (httpDataOutput != null)
httpDataOutput.close();
if (httpConnection != null)
httpConnection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return bitmp;
g.drawBitmap(250, 120, 150, 150, bitmp, 0, 0);
私が抱えている問題は、「g.drawBitmap(250, 120, 150, 150, bitmp, 0, 0);」にあります。インポートする必要があるものなどはありますか?
画像を画面に描画/追加するにはどうすればよいですか..明らかなものが欠けていることはわかっていますが、それが何であるかわかりませんか? 何か助けてください。
ありがとう