add loadBitmapAsset
This commit is contained in:
parent
20ed6e333c
commit
074fc9b788
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@ -20,42 +20,12 @@ import java.io.InputStream;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
|
||||
public final class BitmapUtils {
|
||||
// private static final String PREFIX_FILE = "file:";
|
||||
// private static final String PREFIX_JAR = "jar:";
|
||||
//
|
||||
// private static InputStream createInputStream(String src) throws
|
||||
// FileNotFoundException {
|
||||
// if (src.startsWith(PREFIX_JAR)) {
|
||||
// String name = "/org/oscim/theme/styles/" +
|
||||
// src.substring(PREFIX_JAR.length());
|
||||
//
|
||||
// InputStream inputStream = BitmapUtils.class.getResourceAsStream(name);
|
||||
// if (inputStream == null) {
|
||||
// throw new FileNotFoundException("resource not found: " + src + " " +
|
||||
// name);
|
||||
// }
|
||||
// return inputStream;
|
||||
// } else if (src.startsWith(PREFIX_FILE)) {
|
||||
// File file = new File(src.substring(PREFIX_FILE.length()));
|
||||
// if (!file.exists()) {
|
||||
// throw new IllegalArgumentException("file does not exist: " + src);
|
||||
// } else if (!file.isFile()) {
|
||||
// throw new IllegalArgumentException("not a file: " + src);
|
||||
// } else if (!file.canRead()) {
|
||||
// throw new IllegalArgumentException("cannot read file: " + src);
|
||||
// }
|
||||
// return new FileInputStream(file);
|
||||
// }
|
||||
// throw new IllegalArgumentException("invalid bitmap source: " + src);
|
||||
// }
|
||||
|
||||
public static Bitmap createBitmap(String src) throws IOException {
|
||||
if (src == null || src.length() == 0) {
|
||||
// no image source defined
|
||||
return null;
|
||||
}
|
||||
|
||||
// InputStream inputStream = createInputStream(src);
|
||||
InputStream inputStream = AssetAdapter.g.openFileAsStream(src);
|
||||
if (inputStream == null)
|
||||
throw new IllegalArgumentException("invalid bitmap source: " + src);
|
||||
@ -66,6 +36,6 @@ public final class BitmapUtils {
|
||||
}
|
||||
|
||||
private BitmapUtils() {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,13 +33,14 @@ public abstract class CanvasAdapter {
|
||||
|
||||
public abstract Bitmap decodeBitmap(InputStream inputStream);
|
||||
|
||||
public abstract Bitmap loadBitmapAsset(String fileName);
|
||||
|
||||
public abstract int getColor(Color color);
|
||||
|
||||
public abstract Paint getPaint();
|
||||
|
||||
public abstract int parseColor(String colorString);
|
||||
|
||||
|
||||
public abstract Bitmap getBitmap(int width, int height, int format);
|
||||
|
||||
public abstract Canvas getCanvas();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user