How to edit the captured image?

56 views
Skip to first unread message

sakar

unread,
Jun 18, 2015, 7:03:28 AM6/18/15
to codenameone...@googlegroups.com
I want to edit captured image(add copyright symbol in image),is it possible? If yes,How to edit??

Shai Almog

unread,
Jun 18, 2015, 10:35:05 AM6/18/15
to codenameone...@googlegroups.com, sakar.ca...@gmail.com
Yes.
Create an image in the desired dimensions using Image create(int, int, int). Use getGraphics and draw using that graphics object.
Then save that image to a file using the ImageIO class.

Sakar Thapa

unread,
Jun 18, 2015, 12:56:15 PM6/18/15
to codenameone...@googlegroups.com, sakar.ca...@gmail.com
Sir.Thanx for your solution

sakar

unread,
Jun 19, 2015, 12:56:29 AM6/19/15
to codenameone...@googlegroups.com
Code Worked
  

 Image i = Image.createImage(path);
           Graphics g= i.getGraphics();
           g.drawString("CopyWrite:Capital Eye", 20, 20);
           String img_name=System.currentTimeMillis()+".png";
      
               String realpath=FileSystemStorage.getInstance().getAppHomePath();
            OutputStream out= FileSystemStorage.getInstance().openOutputStream( realpath+img_name);    
     ImageIO.getImageIO().save(i, out,  ImageIO.FORMAT_PNG, 1f);

sakar

unread,
Jun 22, 2015, 2:38:49 AM6/22/15
to codenameone...@googlegroups.com
This code only runs on simulator but does not work on android.On android IllegalStateException: Immutable bitmap passed to Canvasconstructor is thrown. because Image.createImage(InputStream)doesnot return mutable Image...How to create mutable image in this scenario. 

Shai Almog

unread,
Jun 22, 2015, 9:43:44 AM6/22/15
to codenameone...@googlegroups.com, sakar.ca...@gmail.com
Create a new image object. Use draw image to draw the other image onto the new mutable object.

sakar

unread,
Jun 23, 2015, 7:04:58 AM6/23/15
to codenameone...@googlegroups.com, sakar.ca...@gmail.com
drawImage() of Image Class is protected method

Shai Almog

unread,
Jun 23, 2015, 10:08:56 AM6/23/15
to codenameone...@googlegroups.com, sakar.ca...@gmail.com
Of the graphics class.
Reply all
Reply to author
Forward
0 new messages