Bonjour à tous,

Je commence le dev sous android, j'en suis juste à tester l'API.
Là j'ai un soucis avec setPixels qui fait planter mon appli.

Voilà le début du onCreate :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
 
		setContentView(R.layout.activity_fullscreen);
 
	    ImageView image = (ImageView) findViewById(R.id.sly);
 
 
	    Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.pic793849);
	    final int bMapWidth = bMap.getWidth();
	    final int bMapHeight = bMap.getHeight();
 
	    int[] pixels = new int[bMapHeight*bMapWidth];
	    bMap.getPixels(pixels, 0, bMapWidth, 0, 0, bMapWidth, bMapHeight);
 
	    for(int i=0 ; i<bMapHeight; i++)
	    {
		    for(int j=0 ; j<bMapWidth; j++)
		    {
		    	//pixels[ i + (j*bMapHeight)] ^= 77;
		    }
 
	    }
 
 
	    bMap.setPixels(pixels, 0, bMapWidth, 0, 0, bMapWidth, bMapHeight);
 
//	    image.setImageBitmap(bMap);
 
		final View controlsView = findViewById(R.id.fullscreen_content_controls);
		final View contentView = findViewById(R.id.fullscreen_content);
Si je commente le bMap.setPixels() ça tourne bien, sinon ça plante direct.

Je vois pas ce que j'ai mal fait, bMap est alloué, pixels aussi et je crois pas être hors-limites... toute aide serait appréciée !

Voilà le logcat :
06-12 10:25:19.770: W/ActivityThread(1074): Application com.example.moos is waiting for the debugger on port 8100...
06-12 10:25:19.810: I/System.out(1074): Sending WAIT chunk
06-12 10:25:20.280: I/dalvikvm(1074): Debugger is active
06-12 10:25:20.470: I/System.out(1074): Debugger has connected
06-12 10:25:20.480: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:20.690: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:20.890: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.090: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.290: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.500: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.700: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:21.900: I/System.out(1074): waiting for debugger to settle...
06-12 10:25:22.100: I/System.out(1074): debugger has settled (1363)
06-12 10:25:23.490: D/dalvikvm(1074): GC_FOR_ALLOC freed 37K, 4% free 3339K/3448K, paused 34ms, total 37ms
06-12 10:25:23.570: D/dalvikvm(1074): GC_FOR_ALLOC freed 36K, 4% free 3648K/3800K, paused 22ms, total 23ms
06-12 10:25:23.670: D/AndroidRuntime(1074): Shutting down VM
06-12 10:25:23.670: W/dalvikvm(1074): threadid=1: thread exiting with uncaught exception (group=0xb2aceba8)
06-12 10:25:23.760: E/AndroidRuntime(1074): FATAL EXCEPTION: main
06-12 10:25:23.760: E/AndroidRuntime(1074): Process: com.example.moos, PID: 1074
06-12 10:25:23.760: E/AndroidRuntime(1074): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.moos/com.example.moos.FullscreenActivity}: java.lang.IllegalStateException
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.access$800(ActivityThread.java:135)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.os.Handler.dispatchMessage(Handler.java:102)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.os.Looper.loop(Looper.java:136)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.main(ActivityThread.java:5017)
06-12 10:25:23.760: E/AndroidRuntime(1074): at java.lang.reflect.Method.invokeNative(Native Method)
06-12 10:25:23.760: E/AndroidRuntime(1074): at java.lang.reflect.Method.invoke(Method.java:515)
06-12 10:25:23.760: E/AndroidRuntime(1074): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-12 10:25:23.760: E/AndroidRuntime(1074): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-12 10:25:23.760: E/AndroidRuntime(1074): at dalvik.system.NativeStart.main(Native Method)
06-12 10:25:23.760: E/AndroidRuntime(1074): Caused by: java.lang.IllegalStateException
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.graphics.Bitmap.setPixels(Bitmap.java:1427)
06-12 10:25:23.760: E/AndroidRuntime(1074): at com.example.moos.FullscreenActivity.onCreate(FullscreenActivity.java:114)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.Activity.performCreate(Activity.java:5231)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
06-12 10:25:23.760: E/AndroidRuntime(1074): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
06-12 10:25:23.760: E/AndroidRuntime(1074): ... 11 more


Merci d'avance !