암이 정의를 사용하는 대신 구글지도의 매핑입니다 응용 프로그램을 만들려고 Google지도의 이미지. 모든 것이 잘 작동하고 있기 때문에 치수> 240 x 320 인 휴대 전화에 맞게 이미지를 확장 할 수는 없지만이 크기보다 큰 휴대 전화의 경우 Android의 기본 힙 크기를 초과하고 Java를 얻으므로 충돌이 발생합니다. .lang.OutOfMemoryError : 비트 맵 크기가 VM 예산을 초과합니다. 전화의 해상도에 따라 이미지의 크기를 조정하는 방법을 알 수 없습니다.GoogleMap으로/Custombitmap 타일로드 크기는 VM 예산 java.lang.OutOfMemoryError와 초과 :
이 뭐하는 거지입니다 : 나는 zoomout의 함수를 호출하는 zoomIn 버튼에 대한 OnClickListener를 설정 한
Display display = getWindowManager().getDefaultDisplay();
Constatnts.SCR_WD = display.getWidth();
Constatnts.SCR_HT = display.getHeight();
2) :
1) 먼저 너비와 휴대 전화의 높이를 계산하고 :
public static Bitmap ScaleBitmap(Bitmap bitmapOrg,int newWidth,int newHeight) {
if(bitmapOrg==null)
return null;
int width = bitmapOrg.getWidth();
int height = bitmapOrg.getHeight();
// calculate the scale - in this case = 0.4f
float scaleWidth = ((float) newWidth)/width;
float scaleHeight = ((float) newHeight)/height;
// createa matrix for the manipulation
Matrix matrix = new Matrix();
// resize the bit map
matrix.postScale(scaleWidth, scaleHeight);
// rotate the Bitmap
//matrix.postRotate(45);
// recreate the new Bitmap
return Bitmap
.createBitmap(bitmapOrg, 0, 0, width, height, matrix, true);
}
: 스케일링에 대한
public void zoomOut() {
if (isloading > 5)
return;
System.gc();
if (zoomLevel < 12) {
dc = true;
sc = true;
emptyBuffer();
zoom = -1;
stopload = true;
bitmapArr1 = new Bitmap[tilesyno][tilesxno];
for (int i = 0; i < bitmapArr.length; i++) {// row
for (int j = 0; j < bitmapArr[i].length; j++) {// coloum
if (bitmapArr[i][j] != null) {
int tmpTilewd = bitmapArr[i][j].getWidth()/2;
int tmpTileHt = bitmapArr[i][j].getHeight()/2;
Bitmap b = ExtraFunctions.ScaleBitmap(bitmapArr[i][j],
tmpTilewd, tmpTileHt);
if (bitmapArr1 != null)
bitmapArr1[i][j] = b;
}
}
}
lastPressed1 = System.currentTimeMillis();
setCenterLatLon();
zoomLevel++;
if (!isStarted)
tryLoadMap();
}
}
void tryLoadMap() {
if (isStarted)
return;
isStarted = true;
Thread th = new Thread() {
public void run() {
try {
Thread.sleep(System.currentTimeMillis() - lastPressed1);
} catch (InterruptedException e) {
e.printStackTrace();
}
loadLocalMap();
if (showDirection)
DirectionPath(lat, lon);
if (isSearchAvail)
SearchPath(lat, lon, tmpselected);
isStarted = false;
}
};
th.start();
}
로그 캣 :
08-30 17:09:30.342: E/dalvikvm-heap(440): 1451808-byte external allocation too large for this process.
08-30 17:09:30.382: E/GraphicsJNI(440): VM won't let us allocate 1451808 bytes
08-30 17:09:30.382: D/AndroidRuntime(440): Shutting down VM
08-30 17:09:30.401: W/dalvikvm(440): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
08-30 17:09:30.442: E/AndroidRuntime(440): FATAL EXCEPTION: main
08-30 17:09:30.442: E/AndroidRuntime(440): java.lang.IllegalStateException: Could not execute method of the activity
08-30 17:09:30.442: E/AndroidRuntime(440): at android.view.View$1.onClick(View.java:2072)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.view.View.performClick(View.java:2408)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.view.View$PerformClick.run(View.java:8816)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.os.Handler.handleCallback(Handler.java:587)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.os.Handler.dispatchMessage(Handler.java:92)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.os.Looper.loop(Looper.java:123)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-30 17:09:30.442: E/AndroidRuntime(440): at java.lang.reflect.Method.invokeNative(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440): at java.lang.reflect.Method.invoke(Method.java:521)
08-30 17:09:30.442: E/AndroidRuntime(440): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-30 17:09:30.442: E/AndroidRuntime(440): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-30 17:09:30.442: E/AndroidRuntime(440): at dalvik.system.NativeStart.main(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440): Caused by: java.lang.reflect.InvocationTargetException
08-30 17:09:30.442: E/AndroidRuntime(440): at com.Map.zoomIn(MapScreen.java:762)
08-30 17:09:30.442: E/AndroidRuntime(440): at java.lang.reflect.Method.invokeNative(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440): at java.lang.reflect.Method.invoke(Method.java:521)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.view.View$1.onClick(View.java:2067)
08-30 17:09:30.442: E/AndroidRuntime(440): ... 11 more
08-30 17:09:30.442: E/AndroidRuntime(440): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-30 17:09:30.442: E/AndroidRuntime(440): at android.graphics.Bitmap.nativeCreate(Native Method)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
08-30 17:09:30.442: E/AndroidRuntime(440): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
08-30 17:09:30.442: E/AndroidRuntime(440): at com.Map.ncore.XtraFunctions.ScaleBitmap(ExtraFunctions.java:32)
08-30 17:09:30.442: E/AndroidRuntime(440): at com.Map.MapCanvas.zoomIn(MapCanvas.java:1018)
08-30 17:09:30.442: E/AndroidRuntime(440): ... 15 more
08-30 17:14:30.522: I/Process(440): Sending signal. PID: 440 SIG: 9
bitmapArr [A [0] [A [1] = BitmapFactory \t \t \t \t \t \t \t \t \t .decodeByteArray (b, 0, b.length)를; –
여기서 바이트 [] B = S.getTiles (stopload, tilesWd, tilesHt, \t \t \t \t \t \t \t Y1, X1, 개의 zoomLevel "JPEG"); –
그래, 거기도 먼저 다운 샘플링해야합니다. 먼저 경계 (x와 y)를 얻은 다음 해당 정보를 사용하여 다운 샘플링 된 크기를 올바르게 계산할 수 있습니다. 메모리를 사용하지 않고 이미지의 경계를 잡는 방법은 http://stackoverflow.com/questions/11128481/android-get-image-dimensions-with-open-itit을 참조하십시오. – dmon