0
본질적으로 Rect 및 글리프를 기반으로 메뉴를 만드는 프로그램을 만들고 있습니다. 어떤 이유로이 코드는 에뮬레이터에서 작동하고 내 친구는 전화를하지만 내 제품에서는 작동하지 않습니다. 나는 아마도 내 전화기가 너무 오래되었다고 (혜성 시리즈) 믿기 시작했다. 그러나, 어떤 좋은 전화 응용 프로그램 dev에처럼, 나는 내 사과가 어떤 유형의 안드로이드 전화에서도 작동하기를 원한다. 그래서 나는이 문제를 아주 철저하게 조사하고있다. java.lang.IllegalArgumentException가 :일부 장치에서는 런타임 오류 "x + width가 <= bitmap.width()"여야합니다.
에 의해 발생 : 내가 말하는 오류가 X + 폭이해야 < = bitmap.width()
내가 비트 맵을 사용하는 유일한 장소 내 상형 문자 클래스에 여기에 게시 :
package text;
import java.util.HashMap;
import java.util.Map;
import android.graphics.Bitmap;
import android.graphics.Canvas;
public class Glyphs {
private Bitmap bitmap;
private Map<Character, Bitmap> glyphs = new HashMap<Character, Bitmap>(62);
private int width;
private int height;
private char[] charactersL = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
private char[] charactersU = new char[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
private char[] numbers = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
public int getWidth(){
return width;
}
public int getHeight(){
return height;
}
public Glyphs(Bitmap bitmap){
super();
this.bitmap = bitmap;
this.width = 12;
this.height = 18;
for(int i = 0; i < 26; i++){
glyphs.put(charactersL[i], Bitmap.createBitmap(bitmap, 0 + (i * width), 0, width, height));
}
for(int i = 0; i < 26; i++){
glyphs.put(charactersU[i], Bitmap.createBitmap(bitmap, 0 + (i * width), 24, width, height));
}
for(int i = 0; i < 10; i++){
glyphs.put(numbers[i], Bitmap.createBitmap(bitmap, 0 + (i * width), 48, width, height));
}
}
public Bitmap getBitmap(){
return bitmap;
}
public void drawString(Canvas canvas, String text, int x, int y){
if(canvas == null){
//return a tag
}
for(int i = 0; i < text.length(); i++){
Character ch = text.charAt(i);
if(glyphs.get(ch) != null){
canvas.drawBitmap(glyphs.get(ch), x + (i * width), y, null);
}
}
}
}
그러나이 프로그램은 다른 휴대폰에서 완벽하게 작동합니다. 나는 내 옛날 폰에서 왜 충돌하는지 정확히 알지 못한다.