title: How to convert HBITMAP to BYTE array for JNI
body: <p>first of all sorry by my bad english, Hello i am new in this kind of forum, the question i have is a headache, well i still looking for everywere in this page and other, i can't no find the solution, first i need to create a screen capture and save it in a jpeg byte array, my code is simple and create the HBITMAP but the trouble is convert it to an array, here is my code:</p>
  
  <pre><code>int takeScreenShoot(){
  GdiplusStartupInput gdiplusStartupInput;
  ULONG_PTR gdiplusToken;
  GdiplusStartup(&amp;gdiplusToken, &amp;gdiplusStartupInput, NULL);
  
  HDC screenDC,memDC;
  HBITMAP screenBITMAP;
  screenDC= GetDC(NULL);
  memDC= CreateCompatibleDC(screenDC);
  int Height = GetSystemMetrics(SM_CYSCREEN);
  int Width = GetSystemMetrics(SM_CXSCREEN);
  screenBITMAP = CreateCompatibleBitmap(screenDC,Width,Height);
  BitBlt(memDC,0,0,Width,Height,screenDC,0,0,SRCCOPY);
  
  /*
    use GDIplus for transform the image to JPEG and pass to a byte stream
    or somethig like that
  */
  ReleaseDC(NULL,memDC);
  ReleaseDC(NULL,screenDC);
  
  return 0;
  </code></pre>
  
  <p>}</p>
  
  <p>well, this code if for practice, i try to use Image class from GDI+ and also Bitmap but i don't find the way to save it in a byte array, in some pages talk to use IStream but is dificult to me understand it, i need someone to direct me in the right way, thanks beforehand for the help :D</p>