简体   繁体   中英

Add date to picture J2ME

I have a code that I had in my phone, which takes photos and saves it to the memory cell.

I would like to add the functionality to save the image with the shooting date included in the picture.

            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);

sample image with the date 在此处输入图片说明 tnx

//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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM