width : 480 height : 800! wieso dann "java.lang.IllegalArgumentException: width and height must be > 0" ??

  • Antworten:4
L3322
  • Forum-Beiträge: 467

20.05.2011, 20:30:37 via Website

Ich scaliere am Anfang meines Spiels einige Bitmaps dass hat BISHER gut geklappt nun mache ich das alles in einer anderen Klasse!
Und nun bekomme ich bei folgenden Code:
1int bmpHeight = bmp.getHeight();
2 int bmpWidth = bmp.getWidth();
3 Log.e(tag, "width : " + bmpWidth + " height : " + bmpHeight);
4 scaledBitmap = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, bitmapMatrix, true);
diesen Error:
105-20 20:23:50.123: ERROR/AndroidRuntime(11027): java.lang.IllegalArgumentException: width and height must be > 0
205-20 20:23:50.123: ERROR/AndroidRuntime(11027): at android.graphics.Bitmap.nativeCreate(Native Method)
305-20 20:23:50.123: ERROR/AndroidRuntime(11027): at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
405-20 20:23:50.123: ERROR/AndroidRuntime(11027): at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
505-20 20:23:50.123: ERROR/AndroidRuntime(11027): at com.lapps.doodlerocket.GameHelper.getScaledBitmap(GameHelper.java:45)
605-20 20:23:50.123: ERROR/AndroidRuntime(11027): at com.lapps.doodlerocket.GameView.surfaceCreated(GameView.java:240)
705-20 20:23:50.123: ERROR/AndroidRuntime(11027): at android.view.SurfaceView.updateWindow(SurfaceView.java:543)
805-20 20:23:50.123: ERROR/AndroidRuntime(11027): at android.view.SurfaceView.dispatchDraw(SurfaceView.java:348)
9.............

bei dem Code oben wird mir in der Logcat "width : 480 height : 800" ausgegeben!

also weiß ich jetzt nicht wieso es meckert!?

wahrscheinlich nur ein kleiner Leichtsinnsfehler... ich hoffe jemand kann mir helfen!

"Hard work beats talent, when talent fails to work hard"

Antworten
Johnson Detlev
  • Forum-Beiträge: 7

25.05.2011, 01:05:11 via Website

Mal mit

1scaledBitmap = Bitmap.createBitmap(bmp, 1, 1, bmpWidth, bmpHeight, bitmapMatrix, true);
versucht?

Antworten
L3322
  • Forum-Beiträge: 467

25.05.2011, 06:43:37 via App

Ja hab ich probiert!
allerdings ist das ja x und y, wo es egal ist. und da meckerts au ned

— geändert am 25.05.2011, 07:27:51

"Hard work beats talent, when talent fails to work hard"

Antworten
Johnson Detlev
  • Forum-Beiträge: 7

25.05.2011, 18:00:03 via Website

Ja schon richtig, aber wenn es bei 1, 1 nicht meckert, dann wird es wohl so sein, dass das Gerät bei den Pixeln bei 1 anfängt zu zählen und nicht bei 0.

Antworten
L3322
  • Forum-Beiträge: 467

25.05.2011, 18:23:02 via App

oh da ham wir aneinander vorbeigeredet! sry
es meckert ja bei width und height egal was ich bei x und y einsetze

— geändert am 25.05.2011, 18:31:41

"Hard work beats talent, when talent fails to work hard"

Antworten