RecordStore、撮影された写真からの電話
-
28-10-2019 - |
質問
ユーザが写真を撮影し、彼は電話したいLWUITに特定の写真を追加するrecordstoreとし、後で取り出する。どのように達成した。
解決 2
わかりました、私はアプリケーションをコマンドを介してカメラを起動します:
mPlayer = Manager.createPlayer("capture://video");
mPlayer.realize();
mVideoControl = (VideoControl) mPlayer.getControl("VideoControl");
Canvas canvas = new CameraCanvas(this, mVideoControl);
canvas.addCommand(mBackCommand);
canvas.addCommand(mCaptureCommand);
canvas.setCommandListener(this);
mDisplay.setCurrent(canvas);
mPlayer.start();
McAptureCommandコマンドのアクションパフォーマンス:
public void capture() {
try {
// Get the image.
byte[] raw = mVideoControl.getSnapshot(null);
// "encoding=png&width=320&height=240");
bytelen = raw.length;
Image image = Image.createImage(raw, 0, raw.length);
Image thumb = createThumbnail(image);
// Place it in the main form.
if (mMainForm.size() > 0 && mMainForm.get(0) instanceof StringItem) {
mMainForm.delete(0);
}
mMainForm.append(thumb);
// Flip back to the main form.
mDisplay.setCurrent(mMainForm);
// Shut down the player.
mPlayer.close();
mPlayer = null;
mVideoControl = null;
} catch (MediaException me) {
handleException(me);
}
}
CreateThumbnailのコード:
private Image createThumbnail(Image image) {
int sourceWidth = image.getWidth();
int sourceHeight = image.getHeight();
int thumbWidth = 64;
int thumbHeight = -1;
if (thumbHeight == -1) {
thumbHeight = thumbWidth * sourceHeight / sourceWidth;
}
Image thumb = Image.createImage(thumbWidth, thumbHeight);
Graphics g = thumb.getGraphics();
for (int y = 0; y < thumbHeight; y++) {
for (int x = 0; x < thumbWidth; x++) {
g.setClip(x, y, 1, 1);
int dx = x * sourceWidth / thumbWidth;
int dy = y * sourceHeight / thumbHeight;
g.drawImage(image, x - dx, y - dy, Graphics.LEFT | Graphics.TOP);
}
}
Image immutableThumb = Image.createImage(thumb);
return immutableThumb;
}
今では、createThumbnailメソッドを呼び出すときに画像がどこに保存されているかはわかりません。つまり、image.createimageを呼び出した後です:Capture()メソッドには2つのCreateImage呼び出しが1つ、CreateThumbnail()メソッドに1つがあります。しかし、私の本当の問題は、作成された画像の位置と、それを銀行クライアントレコードストアIDに関連付ける方法を知ることです。
所属していません StackOverflow