Bitmap objects are written as image files, watermarks, and other android
Android Fileoutputstream m_fileoutputstream = NULL;
Try {
M_fileoutputstream = new fileoutputstream (filepath); // path of the written file
} Catch (filenotfoundexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
M_newbitmap.compress (compressformat. PNG, 100, m_fileoutputstream );
Try {
M_fileoutputstream.flush ();
M_fileoutputstream.close ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
// Add a watermark
Bitmap m_srcbitmap = bitmapfactory. decodefile (srcpath); // Original Image
M_bmp width = m_srcbitmap.getwidth ();
M_bmpheight = m_srcbitmap.getwidth ();
M_bmp Config = m_srcbitmap.getconfig ();
// Draw a new bitmap
M_newbitmap = bitmap. createbitmap (m_bmp width, m_bmpheight, m_bmp config );
M_newcanvas = new canvas (m_newbitmap); m_newcanvas.drawbitmap (m_srcbitmap, 0, 0, null );
M_newcanvas.drawtext (water_text, 0, m_bmpheight-100, m_paint );
M_newcanvas.save (canvas. all_save_flag );
// Write a new image
Try {
M_fileoutputstream = new fileoutputstream (m_filename );
} Catch (filenotfoundexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
M_newbitmap.compress (compressformat. PNG, 100, m_fileoutputstream );
Try {
M_fileoutputstream.flush ();
M_fileoutputstream.close ();
} Catch (ioexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}