- Notifications
You must be signed in to change notification settings - Fork0
A library to read .ico files in Java. Chingón.
License
miko3k/mejico
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A library to read.ico
/.cur
files in Java. Chingón.
Themejico
a small library to read Microsoft.ico
or.cur
format in java.
- a commercial-friendly license
- no dependencies on third-party libraries
- comprehensively unit tested
- fully compatible with .ico format
All versions should be supported. Hopefully. Please file a bug and help to improve this libraryif you find an.ico
or.cur
file in the wild, which can be read by any version of Windowsand this library fails to do so.
I decided to stop publishing to Maven Central, coz it is annoying.
Simply snatch this from it fromjitpack. Do not forget toselect correct subproject in the dropdown menu!
Should this project find heavy use, I might consider publishing to Maven Central again.
This project is split into multiple subprojects. Your application should depend on one of the first two.
mejico-awt
- decoder which returnsjava.awt.image.BufferedImage
mejico-andorid
- decoder which returnsandroid.graphics.Bitmap
mejico-core
- core decoding routines, mostly coming fromimage4j
mejico-test
- utility classes for unit testing, not intended for public use
Loading of PNG data is delegated to native facilities. This is the main reason why we haveseparate Android and AWT artifacts. You might want to depend onmejico-core
only, if you wantto supply your own PNG (or even BMP) decoder.
There are two classes with static factory methods to obtain anIconParser
, depending on the platform:
AwtMejico.getIconParser()
, returnsIconParser<BufferedImage>
AndroidMejico.getIconParser()
, returnsIconParser<Bitmap>
CheckIconParser
to see the high level API. It can return aList
of images contained in.ico
file.
Lower level API is in theIconReader
class and allows to retrieve image metadata first (including the hotspot position for.cur
files) and decodeselected images afterwards.
// AWT exampleimportjava.awt.image.BufferedImage;importjava.io.IOException;importjava.io.InputStream;importjava.util.List;importorg.deletethis.mejico.awt.AwtMejico;classMain {publicstaticvoidmain(String[]args)throwsIOException {InputStreamstream =Main.class.getResourceAsStream("bundled_icon.ico");List<BufferedImage>images =AwtMejico.getIconParser().getIcons(Main.class.getResourceAsStream("bundled_icon.ico"));// do something with images } }
// Android exampleimportjava.io.IOException;importjava.io.InputStream;importjava.util.List;importandroid.graphics.Bitmap;importandroid.app.Activity;importandroid.os.Bundle;importorg.deletethis.mejico.android.AndroidMejico;classMyActivityextendsActivity {@OverridepublicvoidonCreate(BundlesavedInstanceState) {super.onCreate(savedInstanceState);try {InputStreamstream =getResources().openRawResource(R.raw.resource_id);List<Bitmap>images =AndroidMejico.getIconParser().getIcons(stream);// do something with images }catch(IOExceptionex) {thrownewIllegalStateException("Cannot open resource"); } }}
Themejico
library is licensed under the GNU LGPL v2.1 so you are free to use it inyour Free Software and Open Source projects, as well as commercial projects,under the terms of the LGPL v2.1.
This is a fork ofimage4j. I changed the codebeyond recognition, added a battery of unit tests, ditched many parts includingencoding and general purpose BMP decoder.
I plan to maintain this library. More or less.
If you encounter bugs, please do not hesitate to report them.
- image4j
- TheFile Formats page at DaubNET for informationon various image formats
- GIMP, which we use for editing images
To my or original author knowledge, there are no patents on either the BMP or ICO formats.
About
A library to read .ico files in Java. Chingón.
Topics
Resources
License
Stars
Watchers
Forks
Packages0
Languages
- Java100.0%