title: Open, edit and save image canvas on file.pgm in JavaFX
body: <p>this drawing area to draw image with canvas</p>
  
  <pre><code>        Canvas canvas= new Canvas();
          canvas.setHeight(500);
          canvas.setWidth(700);
  
  GraphicsContext gc = canvas.getGraphicsContext2D();
          gc.setFill(Color.BLACK);
          gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
          gc.setFill(Color.WHITE);
          gc.fillRect(1, 1, canvas.getWidth() - 2, canvas.getHeight() - 2);
  </code></pre>
  
  <p>and I made this method to export drawing canvas to imagem.pgn or snapshot and its correctly</p>
  
  <pre><code>public void snapshotCanvasImageToPNG(Stage primaryStage) {
  
          FileChooser fileChooser = new FileChooser();
  
          FileChooser.ExtensionFilter extFilter
                  = new FileChooser.ExtensionFilter("png files (*.png)", "*.png");
          fileChooser.getExtensionFilters().add(extFilter);
  
          File file = fileChooser.showSaveDialog(primaryStage);
  
          if (file != null) {
              try {
                  WritableImage writableImage = new WritableImage((int) canvas.getWidth(), (int) canvas.getHeight());
                  canvas.snapshot(null, writableImage);
                  RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);
                  ImageIO.write(renderedImage, "png", file);
              } catch (IOException ex) {
                  Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
              }
          }
      }
  </code></pre>
  
  <p>and I have many doubts in making these methods to open edit and save the canvas drawing to file.pgm
  I made this but it complicate to finish</p>
  
  <pre><code>public void openFilePGM(Stage primaryStage) {
  
      FileChooser fileChooser = new FileChooser();
  
      FileChooser.ExtensionFilter extFilter
              = new FileChooser.ExtensionFilter("PGM files (*.pgm)", "*.pgm");
      fileChooser.getExtensionFilters().add(extFilter);
  
  
      File file = fileChooser.showOpenDialog(primaryStage);
  
      if (file != null) {
      //doubt here
      }
  }
  
  public void saveFilePGM(Stage primaryStage) {
  
      FileChooser fileChooser = new FileChooser();
  
      FileChooser.ExtensionFilter extFilter
              = new FileChooser.ExtensionFilter("PGM files (*.pgm)", "*.pgm");
      fileChooser.getExtensionFilters().add(extFilter);
  
      File file = fileChooser.showSaveDialog(primaryStage);
  
      if (file != null) {
         //doubt here
      }  
  }
  </code></pre>