├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── builtin-decoder-common
    ├── pixelcomposer.cpp
    ├── pixelcomposer.h
    ├── sampler.cpp
    └── sampler.h
├── gradle-mvn-push.gradle
├── gradle.properties
├── gradle
    └── wrapper
    │   ├── gradle-wrapper.jar
    │   └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jpeg-decoder
    ├── .gitignore
    ├── build.gradle
    ├── gradle.properties
    ├── proguard-rules.pro
    └── src
    │   └── main
    │       ├── AndroidManifest.xml
    │       └── jni
    │           ├── jpegdecoder.cpp
    │           ├── jpgd.cpp
    │           └── jpgd.h
├── library
    ├── .gitignore
    ├── build.gradle
    ├── gradle.properties
    ├── proguard-rules.pro
    └── src
    │   └── main
    │       ├── AndroidManifest.xml
    │       └── java
    │           └── rapid
    │               └── decoder
    │                   ├── AssetBitmapLoader.java
    │                   ├── BackgroundTask.java
    │                   ├── BackgroundTaskManager.java
    │                   ├── BitmapDecoder.java
    │                   ├── BitmapLoader.java
    │                   ├── BitmapMeta.java
    │                   ├── BitmapPostProcessor.java
    │                   ├── BitmapTransformer.java
    │                   ├── BitmapUtils.java
    │                   ├── ByteArrayBitmapLoader.java
    │                   ├── CloneUtils.java
    │                   ├── Decodable.java
    │                   ├── FileBitmapLoader.java
    │                   ├── FileDescriptorBitmapLoader.java
    │                   ├── ForInternalUse.java
    │                   ├── IntegerMaker.java
    │                   ├── LazyInputStream.java
    │                   ├── NextLayoutInspector.java
    │                   ├── NullBitmapLoader.java
    │                   ├── Quality.java
    │                   ├── Queriable.java
    │                   ├── ResourceBitmapLoader.java
    │                   ├── StreamBitmapLoader.java
    │                   ├── StreamOpener.java
    │                   ├── TransitionDrawable.java
    │                   ├── TwiceReadableInputStream.java
    │                   ├── ViewFrameBuilder.java
    │                   ├── binder
    │                       ├── DrawableCreator.java
    │                       ├── DrawableInflater.java
    │                       ├── Effect.java
    │                       ├── ImageViewBinder.java
    │                       ├── TextViewBinder.java
    │                       ├── ViewBackgroundBinder.java
    │                       └── ViewBinder.java
    │                   ├── builtin
    │                       ├── BuiltInDecoder.java
    │                       ├── JpegDecoder.java
    │                       └── PngDecoder.java
    │                   ├── cache
    │                       ├── BitmapLruCache.java
    │                       ├── CacheSource.java
    │                       ├── DiskLruCache.java
    │                       ├── DiskLruCacheEngine.java
    │                       ├── LruCache.java
    │                       ├── ResourcePool.java
    │                       └── TransactionOutputStream.java
    │                   ├── compat
    │                       ├── DisplayCompat.java
    │                       ├── ImageViewCompat.java
    │                       └── ViewCompat.java
    │                   └── frame
    │                       ├── AspectRatioCalculator.java
    │                       ├── CenterCropFramedDecoder.java
    │                       ├── CenterFramedDecoder.java
    │                       ├── CenterInsideFramedDecoder.java
    │                       ├── FitGravityFramedDecoder.java
    │                       ├── FitXYFramedDecoder.java
    │                       ├── FramedDecoder.java
    │                       ├── FramingMethod.java
    │                       ├── MatrixFramedDecoder.java
    │                       └── ScaleTypeFraming.java
├── png-decoder
    ├── .gitignore
    ├── build.gradle
    ├── gradle.properties
    ├── proguard-rules.pro
    └── src
    │   └── main
    │       ├── AndroidManifest.xml
    │       └── jni
    │           ├── libpng
    │               ├── png.c
    │               ├── png.h
    │               ├── pngconf.h
    │               ├── pngdebug.h
    │               ├── pngerror.c
    │               ├── pngget.c
    │               ├── pnginfo.h
    │               ├── pnglibconf.h
    │               ├── pngmem.c
    │               ├── pngpread.c
    │               ├── pngpriv.h
    │               ├── pngread.c
    │               ├── pngrio.c
    │               ├── pngrtran.c
    │               ├── pngrutil.c
    │               ├── pngset.c
    │               ├── pngstruct.h
    │               └── pngtrans.c
    │           ├── pngdecoder.cpp
    │           └── pngdecoder.h
├── repository
    └── rapid
    │   └── decoder
    │       ├── jpeg-decoder
    │           ├── 0.3.0
    │           │   ├── jpeg-decoder-0.3.0-sources.jar
    │           │   ├── jpeg-decoder-0.3.0-sources.jar.md5
    │           │   ├── jpeg-decoder-0.3.0-sources.jar.sha1
    │           │   ├── jpeg-decoder-0.3.0.aar
    │           │   ├── jpeg-decoder-0.3.0.aar.md5
    │           │   ├── jpeg-decoder-0.3.0.aar.sha1
    │           │   ├── jpeg-decoder-0.3.0.pom
    │           │   ├── jpeg-decoder-0.3.0.pom.md5
    │           │   └── jpeg-decoder-0.3.0.pom.sha1
    │           ├── maven-metadata.xml
    │           ├── maven-metadata.xml.md5
    │           └── maven-metadata.xml.sha1
    │       ├── library
    │           ├── 0.3.0
    │           │   ├── library-0.3.0-sources.jar
    │           │   ├── library-0.3.0-sources.jar.md5
    │           │   ├── library-0.3.0-sources.jar.sha1
    │           │   ├── library-0.3.0.aar
    │           │   ├── library-0.3.0.aar.md5
    │           │   ├── library-0.3.0.aar.sha1
    │           │   ├── library-0.3.0.pom
    │           │   ├── library-0.3.0.pom.md5
    │           │   └── library-0.3.0.pom.sha1
    │           ├── maven-metadata.xml
    │           ├── maven-metadata.xml.md5
    │           └── maven-metadata.xml.sha1
    │       └── png-decoder
    │           ├── 0.3.0
    │               ├── png-decoder-0.3.0-sources.jar
    │               ├── png-decoder-0.3.0-sources.jar.md5
    │               ├── png-decoder-0.3.0-sources.jar.sha1
    │               ├── png-decoder-0.3.0.aar
    │               ├── png-decoder-0.3.0.aar.md5
    │               ├── png-decoder-0.3.0.aar.sha1
    │               ├── png-decoder-0.3.0.pom
    │               ├── png-decoder-0.3.0.pom.md5
    │               └── png-decoder-0.3.0.pom.sha1
    │           ├── maven-metadata.xml
    │           ├── maven-metadata.xml.md5
    │           └── maven-metadata.xml.sha1
├── sample
    ├── .gitignore
    ├── build.gradle
    ├── proguard-rules.pro
    └── src
    │   └── main
    │       ├── AndroidManifest.xml
    │       ├── assets
    │           └── squirrel.jpg
    │       ├── java
    │           └── rapid
    │           │   └── decoder
    │           │       └── sample
    │           │           ├── ContactsFragment.java
    │           │           ├── FrameFragment.java
    │           │           ├── GalleryFragment.java
    │           │           ├── MainActivity.java
    │           │           ├── MutableDecodingFragment.java
    │           │           ├── RegionalDecodingFragment.java
    │           │           ├── ResetFragment.java
    │           │           ├── ScaledDecodingFragment.java
    │           │           ├── WrapContentFragment.java
    │           │           └── widget
    │           │               └── SquaredImageView.java
    │       └── res
    │           ├── drawable-hdpi
    │               ├── ic_launcher.png
    │               └── ic_navigation_drawer.png
    │           ├── drawable-mdpi
    │               ├── ic_launcher.png
    │               ├── ic_navigation_drawer.png
    │               └── transparent_background_base.png
    │           ├── drawable-nodpi
    │               ├── amanda.jpg
    │               ├── amanda2.png
    │               ├── horizontal_reflex_848.jpg
    │               ├── ribbon.png
    │               └── vertical_panorama02.jpg
    │           ├── drawable-xhdpi
    │               ├── ic_launcher.png
    │               └── ic_navigation_drawer.png
    │           ├── drawable-xxhdpi
    │               └── ic_navigation_drawer.png
    │           ├── drawable
    │               ├── contacts_profile_image_placeholder.xml
    │               └── transparent_background.xml
    │           ├── layout
    │               ├── activity_main.xml
    │               ├── fragment_contacts.xml
    │               ├── fragment_frame.xml
    │               ├── fragment_gallery.xml
    │               ├── fragment_mutable_decoding.xml
    │               ├── fragment_regional_decoding.xml
    │               ├── fragment_reset.xml
    │               ├── fragment_scaled_decoding.xml
    │               ├── fragment_wrap_content.xml
    │               ├── item_contacts.xml
    │               └── item_gallery.xml
    │           └── values
    │               ├── arrays.xml
    │               ├── dimens.xml
    │               ├── strings.xml
    │               └── styles.xml
├── settings.gradle
└── test
    ├── .gitignore
    ├── build.gradle
    ├── proguard-rules.pro
    └── src
        ├── androidTest
            └── java
            │   └── rapid
            │       └── decoder
            │           ├── BasicUnitTest.java
            │           └── DecodeFromUriTest.java
        └── main
            ├── AndroidManifest.xml
            └── res
                ├── drawable-nodpi
                    └── android.jpg
                └── drawable-xhdpi
                    └── pond.jpg
/.gitignore:
--------------------------------------------------------------------------------
 1 | .gradle
 2 | /local.properties
 3 | .DS_Store
 4 | 
 5 | .classpath
 6 | .project
 7 | .settings
 8 | eclipsebin
 9 | 
10 | bin
11 | gen
12 | build
13 | out
14 | lib
15 | jniLibs
16 | 
17 | target
18 | pom.xml.*
19 | release.properties
20 | 
21 | .idea
22 | *.iml
23 | classes
24 | 
25 | obj
26 | 
27 | .DS_Store
28 | 
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
 2 | 
 3 | buildscript {
 4 |     repositories {
 5 |         jcenter()
 6 |     }
 7 |     dependencies {
 8 |         classpath 'com.android.tools.build:gradle:1.0.0'
 9 | 
10 |         // NOTE: Do not place your application dependencies here; they belong
11 |         // in the individual module build.gradle files
12 |     }
13 | }
14 | 
15 | allprojects {
16 |     repositories {
17 |         jcenter()
18 |     }
19 | }
20 | 
--------------------------------------------------------------------------------
/builtin-decoder-common/pixelcomposer.cpp:
--------------------------------------------------------------------------------
 1 | #include "pixelcomposer.h"
 2 | 
 3 | typedef unsigned char uint8;
 4 | typedef unsigned short uint16;
 5 | typedef unsigned long uint32;
 6 | 
 7 | void rgb565_composer(uint8*& dest, uint8 a, uint8 r, uint8 g, uint8 b)
 8 | {
 9 |     uint16* p = (uint16*)dest;
10 |     *p = (uint16)(((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3));
11 |     dest += 2;
12 | }
13 | 
14 | void rgba4444_composer(uint8*& dest, uint8 a, uint8 r, uint8 g, uint8 b)
15 | {
16 |     uint16* p = (uint16*)dest;
17 |     *p = (uint16)(((r & 0xf0) << 8) | ((g & 0xf0) << 4) | (b & 0xf0) | (a >> 4));
18 |     dest += 2;
19 | }
20 | 
21 | void rgb888_composer(uint8*& dest, uint8 a, uint8 r, uint8 g, uint8 b)
22 | {
23 |     dest[0] = r;
24 |     dest[1] = g;
25 |     dest[2] = b;
26 |     dest += 3;
27 | }
28 | 
29 | void argb_composer(uint8*& dest, uint8 a, uint8 r, uint8 g, uint8 b)
30 | {
31 |     uint32* p = (uint32*)dest;
32 |     *p = (b << 24) | (g << 16) | (r << 8) | a;
33 |     dest += 4;
34 | }
35 | 
36 | void rgba_composer(uint8*& dest, uint8 a, uint8 r, uint8 g, uint8 b)
37 | {
38 |     uint32* p = (uint32*)dest;
39 |     *p = (a << 24) | (b << 16) | (g << 8) | r;
40 |     dest += 4;
41 | }
42 | 
43 | pixel_format RGB565(rgb565_composer, 2, false);
44 | pixel_format RGBA4444(rgba4444_composer, 2, true);
45 | pixel_format RGB888(rgb888_composer, 3, false);
46 | pixel_format ARGB8888(argb_composer, 4, true);
47 | pixel_format RGBA8888(rgba_composer, 4, true);
--------------------------------------------------------------------------------
/builtin-decoder-common/pixelcomposer.h:
--------------------------------------------------------------------------------
 1 | #ifndef PIXELCOMPOSER_H
 2 | #define PIXELCOMPOSER_H
 3 | 
 4 | typedef void (*pixel_composer)(unsigned char*& dest, unsigned char a, unsigned char r, unsigned char g, unsigned char b);
 5 | 
 6 | class pixel_format
 7 | {
 8 | public:
 9 |     pixel_composer composer;
10 |     int bytes_per_pixel;
11 |     bool alpha;
12 | 
13 |     inline pixel_format()
14 |     {
15 |         composer = 0;
16 |         bytes_per_pixel = 0;
17 |         alpha = false;
18 |     }
19 | 
20 |     inline pixel_format(pixel_composer composer, int bytes_per_pixel, bool alpha)
21 |     {
22 |         this->composer = composer;
23 |         this->bytes_per_pixel = bytes_per_pixel;
24 |         this->alpha = alpha;
25 |     }
26 | 
27 |     inline bool operator==(const pixel_format& rhs) const
28 |     {
29 |         return composer == rhs.composer;
30 |     }
31 | };
32 | 
33 | extern pixel_format RGB565;
34 | extern pixel_format RGBA4444;
35 | extern pixel_format RGB888;
36 | extern pixel_format ARGB8888;
37 | extern pixel_format RGBA8888;
38 | 
39 | #endif // PIXELCOMPOSER_H
--------------------------------------------------------------------------------
/builtin-decoder-common/sampler.h:
--------------------------------------------------------------------------------
 1 | #ifndef SAMPLER_H
 2 | #define SAMPLER_H
 3 | 
 4 | #include "pixelcomposer.h"
 5 | 
 6 | class opaque_sampler
 7 | {
 8 | public:
 9 |     opaque_sampler(int width, int sampled_width, unsigned int sample_size, bool filter, const pixel_format& format);
10 |     virtual ~opaque_sampler();
11 | 
12 |     virtual bool sample(const unsigned char* pixels, int offset, unsigned char* out);
13 |     void finish(unsigned char* out);
14 | 
15 | protected:
16 |     unsigned int* m_red;
17 |     unsigned int* m_green;
18 |     unsigned int* m_blue;
19 |     unsigned int m_sample_size;
20 |     unsigned int m_shift_count_2;
21 |     unsigned int m_shift_count;
22 |     int m_width;
23 |     int m_sampled_width;
24 |     int m_remainder;
25 |     int m_rows;
26 |     bool m_filter;
27 |     pixel_composer m_composer;
28 | 
29 |     virtual int get_bytes_per_pixel();
30 |     virtual void emit_square(unsigned char* out);
31 |     virtual void emit(unsigned char* out);
32 | 
33 |     static unsigned int get_shift_count(unsigned int n);
34 | };
35 | 
36 | class sampler : public opaque_sampler
37 | {
38 | public:
39 |     sampler(int width, int sampled_width, unsigned int sample_size, bool filter, const pixel_format& format);
40 |     ~sampler();
41 | 
42 |     bool sample(const unsigned char* pixels, int offset, unsigned char* out);
43 | 
44 | protected:
45 |     unsigned int* m_alpha;
46 | 
47 |     int get_bytes_per_pixel();
48 |     void emit_square(unsigned char* out);
49 |     void emit(unsigned char* out);
50 | };
51 | 
52 | #endif // SAMPLER_H
--------------------------------------------------------------------------------
/gradle-mvn-push.gradle:
--------------------------------------------------------------------------------
  1 | /*
  2 |  * Copyright 2013 Chris Banes
  3 |  *
  4 |  * Licensed under the Apache License, Version 2.0 (the "License");
  5 |  * you may not use this file except in compliance with the License.
  6 |  * You may obtain a copy of the License at
  7 |  *
  8 |  *     http://www.apache.org/licenses/LICENSE-2.0
  9 |  *
 10 |  * Unless required by applicable law or agreed to in writing, software
 11 |  * distributed under the License is distributed on an "AS IS" BASIS,
 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 |  * See the License for the specific language governing permissions and
 14 |  * limitations under the License.
 15 |  */
 16 | 
 17 | apply plugin: 'maven'
 18 | apply plugin: 'signing'
 19 | 
 20 | def isReleaseBuild() {
 21 |     return VERSION_NAME.contains("SNAPSHOT") == false
 22 | }
 23 | 
 24 | def getReleaseRepositoryUrl() {
 25 |     return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
 26 |             : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
 27 | }
 28 | 
 29 | def getSnapshotRepositoryUrl() {
 30 |     return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
 31 |             : "https://oss.sonatype.org/content/repositories/snapshots/"
 32 | }
 33 | 
 34 | def getRepositoryUsername() {
 35 |     return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
 36 | }
 37 | 
 38 | def getRepositoryPassword() {
 39 |     return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
 40 | }
 41 | 
 42 | afterEvaluate { project ->
 43 |     uploadArchives {
 44 |         repositories {
 45 |             mavenDeployer {
 46 |                 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
 47 | 
 48 |                 pom.groupId = GROUP
 49 |                 pom.artifactId = POM_ARTIFACT_ID
 50 |                 pom.version = VERSION_NAME
 51 | 
 52 |                 repository(url: getReleaseRepositoryUrl()) {
 53 |                     authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
 54 |                 }
 55 |                 snapshotRepository(url: getSnapshotRepositoryUrl()) {
 56 |                     authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
 57 |                 }
 58 | 
 59 |                 pom.project {
 60 |                     name POM_NAME
 61 |                     packaging POM_PACKAGING
 62 |                     description POM_DESCRIPTION
 63 |                     url POM_URL
 64 | 
 65 |                     scm {
 66 |                         url POM_SCM_URL
 67 |                         connection POM_SCM_CONNECTION
 68 |                         developerConnection POM_SCM_DEV_CONNECTION
 69 |                     }
 70 | 
 71 |                     licenses {
 72 |                         license {
 73 |                             name POM_LICENCE_NAME
 74 |                             url POM_LICENCE_URL
 75 |                             distribution POM_LICENCE_DIST
 76 |                         }
 77 |                     }
 78 | 
 79 |                     developers {
 80 |                         developer {
 81 |                             id POM_DEVELOPER_ID
 82 |                             name POM_DEVELOPER_NAME
 83 |                         }
 84 |                     }
 85 |                 }
 86 |             }
 87 |         }
 88 |     }
 89 | 
 90 |     signing {
 91 |         required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
 92 |         sign configurations.archives
 93 |     }
 94 | 
 95 |     task androidJavadocs(type: Javadoc) {
 96 |         source = android.sourceSets.main.java.srcDirs
 97 |         classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
 98 |     }
 99 | 
100 |     task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
101 |         classifier = 'javadoc'
102 |         from androidJavadocs.destinationDir
103 |     }
104 | 
105 |     task androidSourcesJar(type: Jar) {
106 |         classifier = 'sources'
107 |         from android.sourceSets.main.java.sourceFiles
108 |     }
109 | 
110 |     artifacts {
111 |         archives androidSourcesJar
112 | //        archives androidJavadocsJar
113 |     }
114 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
 1 | # Project-wide Gradle settings.
 2 | 
 3 | # IDE (e.g. Android Studio) users:
 4 | # Settings specified in this file will override any Gradle settings
 5 | # configured through the IDE.
 6 | 
 7 | # For more details on how to configure your build environment visit
 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
 9 | 
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 | 
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | 
20 | RELEASE_REPOSITORY_URL=.//repository
21 | 
22 | VERSION_NAME=0.3.0
23 | VERSION_CODE=12
24 | GROUP=rapid.decoder
25 | 
26 | POM_DESCRIPTION=
27 | POM_URL=https://github.com/suckgamony/RapidDecoder
28 | POM_SCM_URL=https://github.com/suckgamony/RapidDecoder
29 | POM_SCM_CONNECTION=scm:git@github.com:suckgamony/RapidDecoder.git
30 | POM_SCM_DEV_CONNECTION=scm:git@github.com:suckgamony/RapidDecoder.git
31 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
32 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
33 | POM_LICENCE_DIST=repo
34 | POM_DEVELOPER_ID=suckgamony
35 | POM_DEVELOPER_NAME=suckgamony
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/skgmn/RapidDecoder/7cdfca47fa976c3f5f47a7091702cdf1462480be/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Nov 26 09:01:19 KST 2014
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
7 | 
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
  1 | #!/usr/bin/env bash
  2 | 
  3 | ##############################################################################
  4 | ##
  5 | ##  Gradle start up script for UN*X
  6 | ##
  7 | ##############################################################################
  8 | 
  9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 10 | DEFAULT_JVM_OPTS=""
 11 | 
 12 | APP_NAME="Gradle"
 13 | APP_BASE_NAME=`basename "$0"`
 14 | 
 15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
 16 | MAX_FD="maximum"
 17 | 
 18 | warn ( ) {
 19 |     echo "$*"
 20 | }
 21 | 
 22 | die ( ) {
 23 |     echo
 24 |     echo "$*"
 25 |     echo
 26 |     exit 1
 27 | }
 28 | 
 29 | # OS specific support (must be 'true' or 'false').
 30 | cygwin=false
 31 | msys=false
 32 | darwin=false
 33 | case "`uname`" in
 34 |   CYGWIN* )
 35 |     cygwin=true
 36 |     ;;
 37 |   Darwin* )
 38 |     darwin=true
 39 |     ;;
 40 |   MINGW* )
 41 |     msys=true
 42 |     ;;
 43 | esac
 44 | 
 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
 46 | if $cygwin ; then
 47 |     [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
 48 | fi
 49 | 
 50 | # Attempt to set APP_HOME
 51 | # Resolve links: $0 may be a link
 52 | PRG="$0"
 53 | # Need this for relative symlinks.
 54 | while [ -h "$PRG" ] ; do
 55 |     ls=`ls -ld "$PRG"`
 56 |     link=`expr "$ls" : '.*-> \(.*\)$'`
 57 |     if expr "$link" : '/.*' > /dev/null; then
 58 |         PRG="$link"
 59 |     else
 60 |         PRG=`dirname "$PRG"`"/$link"
 61 |     fi
 62 | done
 63 | SAVED="`pwd`"
 64 | cd "`dirname \"$PRG\"`/" >&-
 65 | APP_HOME="`pwd -P`"
 66 | cd "$SAVED" >&-
 67 | 
 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 69 | 
 70 | # Determine the Java command to use to start the JVM.
 71 | if [ -n "$JAVA_HOME" ] ; then
 72 |     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
 73 |         # IBM's JDK on AIX uses strange locations for the executables
 74 |         JAVACMD="$JAVA_HOME/jre/sh/java"
 75 |     else
 76 |         JAVACMD="$JAVA_HOME/bin/java"
 77 |     fi
 78 |     if [ ! -x "$JAVACMD" ] ; then
 79 |         die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
 80 | 
 81 | Please set the JAVA_HOME variable in your environment to match the
 82 | location of your Java installation."
 83 |     fi
 84 | else
 85 |     JAVACMD="java"
 86 |     which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
 87 | 
 88 | Please set the JAVA_HOME variable in your environment to match the
 89 | location of your Java installation."
 90 | fi
 91 | 
 92 | # Increase the maximum file descriptors if we can.
 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
 94 |     MAX_FD_LIMIT=`ulimit -H -n`
 95 |     if [ $? -eq 0 ] ; then
 96 |         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
 97 |             MAX_FD="$MAX_FD_LIMIT"
 98 |         fi
 99 |         ulimit -n $MAX_FD
100 |         if [ $? -ne 0 ] ; then
101 |             warn "Could not set maximum file descriptor limit: $MAX_FD"
102 |         fi
103 |     else
104 |         warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 |     fi
106 | fi
107 | 
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 |     GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 | 
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 |     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 |     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 | 
118 |     # We build the pattern for arguments to be converted via cygpath
119 |     ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 |     SEP=""
121 |     for dir in $ROOTDIRSRAW ; do
122 |         ROOTDIRS="$ROOTDIRS$SEP$dir"
123 |         SEP="|"
124 |     done
125 |     OURCYGPATTERN="(^($ROOTDIRS))"
126 |     # Add a user-defined pattern to the cygpath arguments
127 |     if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 |         OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 |     fi
130 |     # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 |     i=0
132 |     for arg in "$@" ; do
133 |         CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 |         CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
135 | 
136 |         if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
137 |             eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 |         else
139 |             eval `echo args$i`="\"$arg\""
140 |         fi
141 |         i=$((i+1))
142 |     done
143 |     case $i in
144 |         (0) set -- ;;
145 |         (1) set -- "$args0" ;;
146 |         (2) set -- "$args0" "$args1" ;;
147 |         (3) set -- "$args0" "$args1" "$args2" ;;
148 |         (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 |         (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 |         (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 |         (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 |         (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 |         (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 |     esac
155 | fi
156 | 
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 |     JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 | 
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 | 
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
 1 | @if "%DEBUG%" == "" @echo off
 2 | @rem ##########################################################################
 3 | @rem
 4 | @rem  Gradle startup script for Windows
 5 | @rem
 6 | @rem ##########################################################################
 7 | 
 8 | @rem Set local scope for the variables with windows NT shell
 9 | if "%OS%"=="Windows_NT" setlocal
10 | 
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 | 
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 | 
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 | 
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 | 
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 | 
32 | goto fail
33 | 
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 | 
38 | if exist "%JAVA_EXE%" goto init
39 | 
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 | 
46 | goto fail
47 | 
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 | 
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 | 
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 | 
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 | 
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 | 
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 | 
69 | :execute
70 | @rem Setup the command line
71 | 
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 | 
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 | 
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 | 
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 | 
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 | 
90 | :omega
91 | 
--------------------------------------------------------------------------------
/jpeg-decoder/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | 
--------------------------------------------------------------------------------
/jpeg-decoder/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: 'com.android.library'
 2 | 
 3 | android {
 4 |     compileSdkVersion 21
 5 |     buildToolsVersion "21.1.2"
 6 | 
 7 |     sourceSets.main {
 8 |         jni.srcDirs += ['../builtin-decoder-common']
 9 |     }
10 |     defaultConfig {
11 |         ndk {
12 |             abiFilters "armeabi", "armeabi-v7a", "x86"
13 |             moduleName "jpeg-decoder"
14 |             ldLibs "jnigraphics"
15 |             cFlags "-ffunction-sections -fdata-sections -fvisibility=hidden -Wl,--gc-sections " +
16 |                     "-Ibuiltin-decoder-common"
17 |         }
18 |     }
19 | }
20 | 
21 | dependencies {
22 | }
23 | 
24 | apply from: '../gradle-mvn-push.gradle'
--------------------------------------------------------------------------------
/jpeg-decoder/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=RapidDecoder jpeg decoder
2 | POM_ARTIFACT_ID=jpeg-decoder
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/jpeg-decoder/proguard-rules.pro:
--------------------------------------------------------------------------------
 1 | # Add project specific ProGuard rules here.
 2 | # By default, the flags in this file are appended to flags specified
 3 | # in /opt/android/sdk/tools/proguard/proguard-android.txt
 4 | # You can edit the include path and order by changing the proguardFiles
 5 | # directive in build.gradle.
 6 | #
 7 | # For more details, see
 8 | #   http://developer.android.com/guide/developing/tools/proguard.html
 9 | 
10 | # Add any project specific keep options here:
11 | 
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | #   public *;
17 | #}
18 | 
--------------------------------------------------------------------------------
/jpeg-decoder/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 |     
4 | 
5 | 
6 | 
--------------------------------------------------------------------------------
/jpeg-decoder/src/main/jni/jpegdecoder.cpp:
--------------------------------------------------------------------------------
  1 | #include 
  2 | #include 
  3 | #include 
  4 | 
  5 | #include "jpgd.h"
  6 | 
  7 | using namespace jpgd;
  8 | 
  9 | #define min(a, b) ((a) < (b) ? (a) : (b))
 10 | 
 11 | static jclass Bitmap;
 12 | static jmethodID Bitmap_createBitmap1;
 13 | static jmethodID Bitmap_recycle;
 14 | 
 15 | static jfieldID Options_inSampleSize;
 16 | static jfieldID Options_mCancel;
 17 | 
 18 | // Java apis
 19 | 
 20 | extern "C" JNIEXPORT
 21 | void JNICALL Java_rapid_decoder_builtin_JpegDecoder_init(JNIEnv* env, jclass clazz)
 22 | {
 23 |     Bitmap = (jclass) env->NewGlobalRef(env->FindClass("android/graphics/Bitmap"));
 24 |     Bitmap_createBitmap1 = env->GetStaticMethodID(Bitmap, "createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;");
 25 |     Bitmap_recycle = env->GetMethodID(Bitmap, "recycle", "()V");
 26 | 
 27 |     jclass Options = env->FindClass("android/graphics/BitmapFactory$Options");
 28 |     Options_inSampleSize = env->GetFieldID(Options, "inSampleSize", "I");
 29 |     Options_mCancel = env->GetFieldID(Options, "mCancel", "Z");
 30 | }
 31 | 
 32 | // JpegDecoder
 33 | 
 34 | extern "C" JNIEXPORT
 35 | jlong JNICALL Java_rapid_decoder_builtin_JpegDecoder_createNativeDecoder(JNIEnv* env, jclass clazz,
 36 | 	jobject in)
 37 | {
 38 |     jpeg_decoder* decoder = new jpeg_decoder(env, in);
 39 |     return (jlong)decoder;
 40 | }
 41 | 
 42 | extern "C" JNIEXPORT
 43 | void JNICALL Java_rapid_decoder_builtin_JpegDecoder_destroyNativeDecoder(JNIEnv* env, jclass clazz,
 44 | 	jlong decoderPtr)
 45 | {
 46 |     jpeg_decoder* decoder = (jpeg_decoder*)decoderPtr;
 47 |     delete decoder;
 48 | }
 49 | 
 50 | extern "C" JNIEXPORT
 51 | jboolean JNICALL Java_rapid_decoder_builtin_JpegDecoder_nativeBegin(JNIEnv* env, jclass clazz,
 52 | 	jlong decoderPtr)
 53 | {
 54 |     jpeg_decoder* decoder = (jpeg_decoder*)decoderPtr;
 55 |     return decoder->begin_decoding() == JPGD_SUCCESS;
 56 | }
 57 | 
 58 | extern "C" JNIEXPORT
 59 | jint JNICALL Java_rapid_decoder_builtin_JpegDecoder_nativeGetWidth(JNIEnv* env, jclass clazz,
 60 | 	jlong decoderPtr)
 61 | {
 62 |     jpeg_decoder* decoder = (jpeg_decoder*)decoderPtr;
 63 |     return decoder->get_width();
 64 | }
 65 | 
 66 | extern "C" JNIEXPORT
 67 | jint JNICALL Java_rapid_decoder_builtin_JpegDecoder_nativeGetHeight(JNIEnv* env, jclass clazz,
 68 | 	jlong decoderPtr)
 69 | {
 70 |     jpeg_decoder* decoder = (jpeg_decoder*)decoderPtr;
 71 |     return decoder->get_height();
 72 | }
 73 | 
 74 | extern "C" JNIEXPORT
 75 | jobject JNICALL Java_rapid_decoder_builtin_JpegDecoder_nativeDecode(JNIEnv* env, jclass clazz,
 76 | 	jlong decoderPtr, jint left, jint top, jint right, jint bottom, jboolean filter, jobject config, jobject opts)
 77 | {
 78 |     jpeg_decoder* decoder = (jpeg_decoder*)decoderPtr;
 79 | 
 80 |     if (left < 0)
 81 |     {
 82 |         left = top = 0;
 83 |         right = decoder->get_width();
 84 |         bottom = decoder->get_height();
 85 |     }
 86 | 
 87 |     int w = right - left;
 88 |     int h = bottom - top;
 89 | 
 90 |     jint sample_size = env->GetIntField(opts, Options_inSampleSize);
 91 |     int sampled_width = (sample_size > 1 ? (w + sample_size - 1) / sample_size : w);
 92 |     int sampled_height = (sample_size > 1 ? (h + sample_size - 1) / sample_size : h);
 93 | 
 94 |     jobject bitmap = env->CallStaticObjectMethod(Bitmap, Bitmap_createBitmap1, sampled_width, sampled_height, config);
 95 | 
 96 | 	AndroidBitmapInfo info;
 97 |     AndroidBitmap_getInfo(env, bitmap, &info);
 98 | 
 99 |     pixel_format format;
100 | 
101 |     switch (info.format)
102 |     {
103 |     case ANDROID_BITMAP_FORMAT_RGBA_8888: format = RGBA8888; break;
104 |     case ANDROID_BITMAP_FORMAT_RGBA_4444: format = RGBA4444; break;
105 |     case ANDROID_BITMAP_FORMAT_RGB_565: format = RGB565; break;
106 |     default:
107 |         env->CallVoidMethod(bitmap, Bitmap_recycle);
108 |         return NULL;
109 |     }
110 | 
111 |     opaque_sampler* sampler = NULL;
112 | 
113 |     if (sample_size > 1)
114 |     {
115 |         sampler = new opaque_sampler(w, sampled_width, sample_size, filter, format);
116 |         decoder->set_pixel_format(RGB888);
117 |     }
118 |     else
119 |     {
120 |         decoder->set_pixel_format(format);
121 |     }
122 | 
123 |     uint8* pixels;
124 |     AndroidBitmap_lockPixels(env, bitmap, (void**)&pixels);
125 | 
126 |     decoder->set_column_offset(left);
127 |     decoder->set_column_length(w);
128 | 
129 |     const void* buffer;
130 |     uint bytes_read;
131 |     
132 |     int dest_bypp = decoder->get_bytes_per_pixel();
133 |     uint scan_line_length = w * dest_bypp;
134 | 
135 |     for (int i = 0; i < top; ++i)
136 |     {
137 |         int ret = decoder->skip(&bytes_read);
138 |         if (ret == JPGD_DONE || ret == JPGD_FAILED ||
139 |             bytes_read < scan_line_length ||
140 |             env->GetBooleanField(opts, Options_mCancel)) goto canceled;
141 |     }
142 | 
143 |     for (int i = top; i < bottom; ++i)
144 |     {
145 |         int ret = decoder->decode(&buffer, &bytes_read);
146 |         if (ret == JPGD_DONE || ret == JPGD_FAILED ||
147 |             bytes_read < scan_line_length ||
148 |             env->GetBooleanField(opts, Options_mCancel)) goto canceled;
149 | 
150 |         if (sample_size > 1)
151 |         {
152 |             if (sampler->sample((const uint8*)buffer, 0, pixels))
153 |             {
154 |                 pixels += info.stride;
155 |             }
156 |         }
157 |         else
158 |         {
159 |             memcpy(pixels, buffer, scan_line_length);
160 |             pixels += info.stride;
161 |         }
162 |     }
163 | 
164 |     if (sample_size > 1)
165 |     {
166 |         sampler->finish(pixels);
167 |         delete sampler;
168 |     }
169 |     AndroidBitmap_unlockPixels(env, bitmap);
170 | 
171 |     return bitmap;
172 | 
173 | canceled:
174 |     if (sample_size > 1)
175 |     {
176 |         delete sampler;
177 |     }
178 | 
179 |     AndroidBitmap_unlockPixels(env, bitmap);
180 |     env->CallVoidMethod(bitmap, Bitmap_recycle);
181 |     return NULL;
182 | }
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | 
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: 'com.android.library'
 2 | 
 3 | android {
 4 |     compileSdkVersion 21
 5 |     buildToolsVersion "21.1.2"
 6 | 
 7 |     defaultConfig {
 8 |         minSdkVersion 8
 9 |         targetSdkVersion 21
10 |         versionCode 12
11 |         versionName "0.3.0"
12 |     }
13 |     lintOptions {
14 |         abortOnError false
15 |     }
16 | }
17 | 
18 | dependencies {
19 |     //noinspection GradleDynamicVersion
20 |     compile 'com.android.support:support-annotations:+'
21 |     //noinspection GradleDynamicVersion
22 |     provided 'com.android.support:support-v4:+'
23 | }
24 | 
25 | //apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
26 | apply from: '../gradle-mvn-push.gradle'
--------------------------------------------------------------------------------
/library/gradle.properties:
--------------------------------------------------------------------------------
1 | POM_NAME=RapidDecoder library
2 | POM_ARTIFACT_ID=library
3 | POM_PACKAGING=aar
--------------------------------------------------------------------------------
/library/proguard-rules.pro:
--------------------------------------------------------------------------------
 1 | # Add project specific ProGuard rules here.
 2 | # By default, the flags in this file are appended to flags specified
 3 | # in /opt/android/sdk/tools/proguard/proguard-android.txt
 4 | # You can edit the include path and order by changing the proguardFiles
 5 | # directive in build.gradle.
 6 | #
 7 | # For more details, see
 8 | #   http://developer.android.com/guide/developing/tools/proguard.html
 9 | 
10 | # Add any project specific keep options here:
11 | 
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | #   public *;
17 | #}
18 | 
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 | 
3 | 
4 |     
5 | 
6 | 
7 | 
--------------------------------------------------------------------------------
/library/src/main/java/rapid/decoder/AssetBitmapLoader.java:
--------------------------------------------------------------------------------
 1 | package rapid.decoder;
 2 | 
 3 | import android.annotation.TargetApi;
 4 | import android.content.Context;
 5 | import android.content.res.AssetManager;
 6 | import android.graphics.Bitmap;
 7 | import android.graphics.BitmapFactory;
 8 | import android.graphics.BitmapFactory.Options;
 9 | import android.graphics.BitmapRegionDecoder;
10 | import android.os.Build;
11 | import android.support.annotation.NonNull;
12 | 
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | 
16 | class AssetBitmapLoader extends BitmapLoader {
17 |     private AssetManager mAssetManager;
18 |     private String mPath;
19 | 
20 | 	public AssetBitmapLoader(Context context, @NonNull String path) {
21 |         mAssetManager = context.getAssets();
22 |         mPath = path;
23 | 	}
24 | 
25 | 	protected AssetBitmapLoader(AssetBitmapLoader other) {
26 | 		super(other);
27 | 	}
28 | 
29 | 	@Override
30 | 	protected Bitmap decode(Options opts) {
31 | 		return BitmapFactory.decodeStream(openInputStream(), null, opts);
32 | 	}
33 | 
34 |     @Override
35 | 	protected InputStream openInputStream() {
36 | 		try {
37 |             return new TwiceReadableInputStream(mAssetManager.open(mPath));
38 | 		} catch (IOException ignored) {
39 |         }
40 |         return null;
41 |     }
42 | 
43 | 	@TargetApi(Build.VERSION_CODES.GINGERBREAD_MR1)
44 | 	@Override
45 | 	protected BitmapRegionDecoder createBitmapRegionDecoder() {
46 | 		try {
47 |             InputStream in = openInputStream();
48 |             if (in == null) {
49 |                 return null;
50 |             }
51 |             return BitmapRegionDecoder.newInstance(in, false);
52 | 		} catch (IOException e) {
53 | 			return null;
54 | 		}
55 | 	}
56 | 
57 | 	@NonNull
58 |     @Override
59 | 	public BitmapLoader fork() {
60 | 		return new AssetBitmapLoader(this);
61 | 	}
62 | 	
63 | 	@Override
64 | 	public boolean equals(Object o) {
65 |         return o == this || o instanceof AssetBitmapLoader && super.equals(o);
66 |     }
67 | }
68 | 
--------------------------------------------------------------------------------
/library/src/main/java/rapid/decoder/BackgroundTask.java:
--------------------------------------------------------------------------------
  1 | package rapid.decoder;
  2 | 
  3 | import android.graphics.Bitmap;
  4 | import android.os.AsyncTask;
  5 | import android.os.Build;
  6 | 
  7 | import java.lang.ref.WeakReference;
  8 | 
  9 | import rapid.decoder.cache.CacheSource;
 10 | 
 11 | class BackgroundTask extends AsyncTask