title: Java BufferedImage in C++
body: <p>I'm translating from Java to C++ an OpenCV project for university. I'm looking for a way to translate the Java BufferedImage in C++. </p>
  
  <p>It is possible to translate that class in some way in C++?</p>
  
  <p>Am I looking the problem from the wrong angle and I should use OpenCV objects like <code>IplImage</code> or <code>Mat</code>?</p>
  
  <p>I'm translating a project that convert paper graph into a digital form. I'm posting the Java main function to make an example:</p>
  
  <pre><code>    String name = "";
      IplImage greyScaleGraph = null;
      // open up standard input
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      System.out
              .println("Insert the name of an image from the Input Folder (ex graph.png):");
      String input = null;
      try {
          input = br.readLine();
      } catch (IOException ioe) {
          System.out.println("IO error trying to read the input");
      }
      if (input != null) {
          if (input.contains("."))
              name = input.substring(0, input.lastIndexOf('.'));
          else
              name = input;
  
          greyScaleGraph = ImageManager.loadGreyscaleImage(PATH + input);
          if (greyScaleGraph == null) {
              System.err.println("No image with that name found");
              System.err.println("--- exit ---");
              System.exit(0);
          }
      }
  
      // IplImage greyScaleGraph = ImageManager.loadGreyscaleImage(PATH + NAME
      // + EXTENSION);
      ImageManager.ShowImage(greyScaleGraph, "GreyGraph", 512);
  
      // alternativa di openCV per la binarizzazione:
      IplImage bWImage = cvCreateImage(cvGetSize(greyScaleGraph),
              IPL_DEPTH_8U, 1);
      cvThreshold(greyScaleGraph, bWImage, 127, 255, CV_THRESH_OTSU);
      bWImage = Utility.reverse(bWImage);
      // IplImage bWImage = OtsuBinarize.otsuBinarize(greyScaleGraph);
  
      // cvReleaseImage(greyScaleGraph);
  
      IplImage result = ZhangSuenThinning.thinning(bWImage.asCvMat())
              .asIplImage();
      ImageManager.ShowImage(result, "Result after thinning", 512);
  
      IplImage houghLinesImage = HoughLines.houghLines(result,
              "probabilistic");
      ImageManager.ShowImage(bWImage, "bWImage", 512);
      ImageManager.ShowImage(houghLinesImage, "houghLinesImage", 512);
  
      IplImage noAxisImage = AxisManipulator.deleteAxis(result.clone(),
              houghLinesImage);
      // ImageManager.ShowImage(noAxisImage, "noAxisImage", 512);
  
      ConnectedComponents.findConnectedComponents(noAxisImage.clone(),
              "Connected Components");
  
      TicksFinder.FindTicks(noAxisImage);
  
      SymbolsFinder.connectedComponentsAnalysis(bWImage);
  
      SymbolsFinder.groupMinus();
      SymbolsFinder.groupParenthesis();
      TicksFinder.tickNumberCoupleFinder();
  
      IplImage symbolsImage = IplImage.createFrom(Utility.reverse(result
              .getBufferedImage()));
      SymbolsFinder.printSymbols(symbolsImage);
  
      SVGCreator.createSVG(name);
  </code></pre>