Skip to content

Instantly share code, notes, and snippets.

@hjanetzek
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjanetzek/0e09da59b7af91de877e to your computer and use it in GitHub Desktop.
Save hjanetzek/0e09da59b7af91de877e to your computer and use it in GitHub Desktop.
@@ -14,10 +14,12 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.android.canvas;
+import static android.graphics.Bitmap.Config.ARGB_8888;
+
import java.io.InputStream;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLES20;
@@ -25,11 +27,17 @@ import android.opengl.GLUtils;
public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
final Bitmap mBitmap;
public AndroidBitmap(InputStream inputStream) {
- mBitmap = BitmapFactory.decodeStream(inputStream);
+ Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
+ try {
+ GLUtils.getType(bitmap);
+ } catch (IllegalArgumentException e) {
+ bitmap = bitmap.copy(ARGB_8888, false);
+ }
+ mBitmap = bitmap;
}
@Override
public boolean isValid() {
return mBitmap != null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment