-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use local divStar:ico4a so I can remove legacy appcompat dependency
- Loading branch information
Showing
25 changed files
with
2,700 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# ico4a | ||
This is a library to decode ICO files into a list of Bitmap-objects - based on [image4j project](https://github.com/imcdonagh/image4j "image4j") (I took the liberty to use a similar structure, classes and methods, so credits go to the authors of image4j as well!). | ||
There is a demo android application included, which shows off the library's functionality. This app is not bullet-proofed so take everything with caution. | ||
|
||
## Usage | ||
### Add dependency to your project and module | ||
The easiest way to include ico4a in your project, is to include the jcenter repository in your **project's _build.gradle_** and the following line in your **module's _build.gradle_**'s dependencies-section: | ||
```Gradle | ||
compile 'divstar:ico4a:v1.0' | ||
``` | ||
Alternatively you may download the AAR from [ico4a's gitHub releases site](https://github.com/divStar/ico4a/releases), create a new module (chose "import AAR" in the following dialog) and add the dependency to your app's project manually. | ||
|
||
### Use the ICODecoder.read(InputStream) method | ||
After having done so, use the following line anywhere to decode an ICO-InputStream into a List of Bitmap-objects: | ||
```Java | ||
List<Bitmap> images = ICODecoder.read(SOME_INPUTSTREAM); | ||
``` | ||
|
||
I suggest creating an AsyncTask to download and read the file, because while reading the file is a rather quick task, it still might result in UI thread blocking. | ||
|
||
See the sample app included in the gitHub repository to get an idea of how to use it. | ||
|
||
![Screenshot showing the sample application and the default icons](http://abload.de/img/screenshot_20160311-0o3oyq.png) | ||
|
||
## Limitations | ||
ico4a cannot write ICO files, because I did not need it myself. Some methods for writing an ICO file are already present, others are not. In particular I have avoided coding BMPEncoder and ICOEncoder, which you will find in the [image4j project](https://github.com/imcdonagh/image4j "image4j library"). Thus you will have to implement them yourself if you need them. | ||
You can however save each of the resulting Bitmap-objects easily using Android's built-in mechanisms. Here is an example: | ||
```Java | ||
File file = new File(dir, "output.png"); | ||
FileOutputStream fOut = new FileOutputStream(file); | ||
|
||
bmp.compress(Bitmap.CompressFormat.PNG, 100, fOut); | ||
fOut.flush(); | ||
fOut.close(); | ||
``` | ||
|
||
## Stability | ||
ico4a has been tested with various single- and multi-image ICO files. It has been tested to support 1-, 4-, 8-, 24- and 32-bit uncompressed images with and without alpha transparency. In addition 24- and 32-bit PNG-compressed images with and without alpha transparency have been tested. All of them loaded without any problems. | ||
|
||
## Final word | ||
Please report any problems if you encounter them and I will see if I can help solve them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdk rootProject.ext.compileSdkVersion | ||
namespace 'divstar.icon4a' | ||
|
||
defaultConfig { | ||
minSdkVersion 15 | ||
} | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
sourceSets.test.java.srcDirs = [] | ||
buildFeatures { | ||
buildConfig true | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "androidx.appcompat:appcompat:$appcompatVersion" | ||
implementation "androidx.annotation:annotation:${annotationVersion}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
In this release everything works as supposed (at least to me): ICO files can be decoded from any InputStream and one receives a List<Bitmap>. | ||
|
||
If you need the actual release, go into the ico4a build folder and grab the AAR-library, create a new module in Android Studio, chose "import AAR" and select the file. It will create a module in your project and you should add it as a dependency to your project. | ||
|
||
Currently it seems the file cannot be retrieved via jcenter (I have to fiddle with it some more). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<manifest></manifest> |
54 changes: 54 additions & 0 deletions
54
ico4a/src/main/java/divstar/ico4a/codec/bmp/BMPConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package divstar.ico4a.codec.bmp; | ||
|
||
/** | ||
* Provides constants used with BMP format. | ||
* | ||
* @author Ian McDonagh | ||
*/ | ||
public class BMPConstants { | ||
|
||
/** | ||
* The signature for the BMP format header "BM". | ||
*/ | ||
public static final String FILE_HEADER = "BM"; | ||
/** | ||
* Specifies no compression. | ||
* | ||
* @see InfoHeader#iCompression InfoHeader | ||
*/ | ||
public static final int BI_RGB = 0; // no compression | ||
/** | ||
* Specifies 8-bit RLE compression. | ||
* | ||
* @see InfoHeader#iCompression InfoHeader | ||
*/ | ||
public static final int BI_RLE8 = 1; // 8bit RLE compression | ||
/** | ||
* Specifies 4-bit RLE compression. | ||
* | ||
* @see InfoHeader#iCompression InfoHeader | ||
*/ | ||
public static final int BI_RLE4 = 2; // 4bit RLE compression | ||
/** | ||
* Specifies 16-bit or 32-bit "bit field" compression. | ||
* | ||
* @see InfoHeader#iCompression InfoHeader | ||
*/ | ||
public static final int BI_BITFIELDS = 3; // 16bit or 32bit "bit field" | ||
/** | ||
* Specifies JPEG compression. | ||
* | ||
* @see InfoHeader#iCompression InfoHeader | ||
*/ | ||
public static final int BI_JPEG = 4; // _JPEG compression | ||
// compression. | ||
/** | ||
* Specifies PNG compression. | ||
* | ||
* @see InfoHeader#iCompression InfoHeader | ||
*/ | ||
public static final int BI_PNG = 5; // PNG compression | ||
|
||
private BMPConstants() { | ||
} | ||
} |
Oops, something went wrong.