将日期添加到图片J2ME

时间:2014-02-07 18:09:00

标签: java java-me java-micro-editon-sdk3.0

我的手机中有一个代码,可以拍照并将其保存到存储单元中。

我想添加保存图像的功能,拍摄日期包含在图片中。

            byte[] capturedImageData = videoControl.getSnapshot("encoding=jpeg&width=2000&height=1500");
            String dirPhotos = "file:///e:/";

            m_suministro = TxtSuministro.getString();
            NombreFoto = m_suministro + "-" + ContadorFotos + ".jpg";

            String fileName = dirPhotos + NombreFoto;

            file = (FileConnection) Connector.open(fileName, Connector.READ_WRITE);
            // If there is no file then create it
            if (file.exists() == false) {
                file.create();
                ContadorFotos++;
            }
            // Write data received from camera while making snapshot to file
            outStream = file.openOutputStream();
            outStream.write(capturedImageData);

带有日期的示例图像 enter image description here TNX

1 个答案:

答案 0 :(得分:1)

//Using LWUIT lib, sames as native

//read image file into Image object
Image image = Image.creatImage(fileName);

//get Graphic object from your image
Graphic gImg = image.getGraphic();

//set color, or font, font size...etc
gImg.setColor(0xffffff);
...
//u can replace with other strings
int x = 0;
int y = image.getHeight() - g.getFont().getHeight();
gImg.drawString("07/02/2014 13:01", x, y);

//save your image into file, you need implenment save method
Image.saveImage(image);