fixes onionskin when background is not showed
authorDralagen <dralagen@dralagen.fr>
Sun, 12 Apr 2015 16:05:49 +0000 (18:05 +0200)
committerDralagen <dralagen@dralagen.fr>
Sun, 12 Apr 2015 16:06:08 +0000 (18:06 +0200)
app/src/main/java/org/alma/rotoscope/DrawingActivity.java

index 050bfd5..de97425 100644 (file)
@@ -357,19 +357,6 @@ public class DrawingActivity extends Activity implements View.OnTouchListener {
     Bitmap background;
     if (showBackground) {
       background = Bitmap.createBitmap(currentFrame);
-      Canvas canvasBackground = new Canvas(background);
-      Paint backgroundPaint = new Paint(Paint.DITHER_FLAG);
-      backgroundPaint.setAlpha(100);
-
-      // Draw onion skin on background
-      int firstIndex = Math.max(currentPicture - nbOnion*freqOnion, 0);
-
-      for (int i = currentPicture - freqOnion ; i >= firstIndex; i-=freqOnion) {
-        // opacity between [100,200]
-        backgroundPaint.setAlpha((100/nbOnion*freqOnion)*(i-firstIndex) + 100);
-        canvasBackground.drawBitmap(layers.get(i), 0, 0, backgroundPaint);
-      }
-
     } else {
       Point size = new Point();
       getWindowManager().getDefaultDisplay().getSize(size);
@@ -377,6 +364,19 @@ public class DrawingActivity extends Activity implements View.OnTouchListener {
       background = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.RGB_565);
     }
 
+    Canvas canvasBackground = new Canvas(background);
+    Paint backgroundPaint = new Paint(Paint.DITHER_FLAG);
+    backgroundPaint.setAlpha(100);
+
+    // Draw onion skin on background
+    int firstIndex = Math.max(currentPicture - nbOnion*freqOnion, 0);
+
+    for (int i = currentPicture - freqOnion ; i >= firstIndex; i-=freqOnion) {
+      // opacity between [100,200]
+      backgroundPaint.setAlpha((100/nbOnion*freqOnion)*(i-firstIndex) + 100);
+      canvasBackground.drawBitmap(layers.get(i), 0, 0, backgroundPaint);
+    }
+
     drawingArea.setBackground(new BitmapDrawable(getResources(), background));
 
     ((TextView)findViewById(R.id.numFrameLabel)).setText(currentPicture + 1 + "/" + layers.size());