8

I want to save canvas object as image, and for this I want use ImageIO class. I'm using Eclipse, but when I try make import of this lib (import javax.imageio.ImageIO;) Eclipse is shows me an error "The import javax.imageio cannot be resolved". Pls. tell me what I have to do to solve this problem and import imageio lib to my project.

Thanks

Harald K
  • 26,314
  • 7
  • 65
  • 111
Ivan B
  • 394
  • 1
  • 5
  • 18

1 Answers1

10

You have tagged your question with Android. javax.imageio.ImageIO is not part of the Android platform, so unfortunately you can't use it. Instead you need to use what's available in the Android SDK for reading and storing images.

Have a look at the Bitmap and BitmapFactory classes for a starting point.

These classes contains the necessary methods to read (BitmapFactory.decode*(...) methods) and write (Bitmap.compress(...) method).

Harald K
  • 26,314
  • 7
  • 65
  • 111
  • What is javax.imageio "part" of? An android application is a java application with the Android framework. Isn't javax.imageio a library built into the jdk? – John Sardinha Nov 12 '19 at 15:02
  • @JohnSardinha While the Android SDK and the JDK does share a lot of API, they are not the same. The javax.imageio package is part of the java.desktop module (from Java 9) and is not part of the Android SDK. – Harald K Nov 12 '19 at 16:30
  • Its difficult to use Bitmap for gif and animated webp resizing. ImageIO is high level – CrackerKSR Mar 14 '22 at 08:26