Last active
August 29, 2015 14:07
-
-
Save hjanetzek/0e09da59b7af91de877e to your computer and use it in GitHub Desktop.
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
@@ -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