fork download
  1.  
  2. public Bitmap viewToBitmap(View view) {
  3.  
  4. Canvas canvas;
  5. Matrix matrix;
  6. Bitmap bitmapOutput;
  7.  
  8. // bitmap placeholder for the canvas output
  9. bitmapOutput = Bitmap.createBitmap(
  10. view.getWidth(),
  11. view.getHeight(),
  12. Bitmap.Config.ARGB_8888
  13. );
  14.  
  15. // downscale the output image to 20% of the view's original size
  16. matrix = new Matrix();
  17. matrix.setScale(
  18. Math.round(view.getWidth() * 0.2f),
  19. Math.round(view.getHeight() * 0.2f)
  20. );
  21.  
  22. canvas = new Canvas(bitmapOutput);
  23. canvas.setMatrix(matrix);
  24.  
  25. // tell the view to draw it's current layout onto the provided canvas
  26. view.draw(canvas);
  27.  
  28. return bitmapOutput;
  29.  
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:2: error: class, interface, or enum expected
public Bitmap viewToBitmap(View view) {
       ^
Main.java:5: error: class, interface, or enum expected
    Matrix matrix;
    ^
Main.java:6: error: class, interface, or enum expected
    Bitmap bitmapOutput;
    ^
Main.java:9: error: class, interface, or enum expected
    bitmapOutput = Bitmap.createBitmap(
    ^
Main.java:16: error: class, interface, or enum expected
    matrix = new Matrix();
    ^
Main.java:17: error: class, interface, or enum expected
    matrix.setScale(
    ^
Main.java:22: error: class, interface, or enum expected
    canvas = new Canvas(bitmapOutput);
    ^
Main.java:23: error: class, interface, or enum expected
    canvas.setMatrix(matrix);
    ^
Main.java:26: error: class, interface, or enum expected
    view.draw(canvas);
    ^
Main.java:28: error: class, interface, or enum expected
    return bitmapOutput;
    ^
Main.java:30: error: class, interface, or enum expected
}
^
11 errors
stdout
Standard output is empty