freeimage

 

int w = testfbo2.getWidth();
 int h = testfbo2.getHeight();

 glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
 
 if(0) {
  DWORD d1,  dsize;

  char fname[256];

  sprintf(fname, "C:\\%d-%d.yuv", w, h);
  
  HANDLE hFile = CreateFileA(fname,  (GENERIC_READ | GENERIC_WRITE), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  d1 = WriteFile(hFile, pixels, w * h * 4, &dsize, NULL);
  CloseHandle(hFile);
 }

 if(time > 28.0 && time < 36.0) {
  char fname[256];
  int imgW;
        int imgH;

  imgW = FreeImage_GetWidth(fiBitmap);
        imgH = FreeImage_GetHeight(fiBitmap);

  sprintf(fname, "C:\\%06d.png", nseqno++);
  
  BYTE *bytes;

  bytes =  FreeImage_GetScanLine(fiBitmap, 0);
  memcpy(bytes, pixels, w * h * 4);
  // for(int i = 0; i < imgH; i++) {
  //     bytes =  FreeImage_GetScanLine(fiBitmap, i);
  //  memcpy(bytes, ((char *)pixels + i * w * 4), w * 4);
  //}

  FreeImage_Save(FIF_PNG, fiBitmap, fname);
  // FreeImage_Unload(fiBitmap);
 }

 

 

 

 

 

 

 

 

 

 {
        int w = testfbo2.getWidth();
        int h = testfbo2.getHeight();
        glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
 
      if(0) {
    DWORD d1,  dsize;
    char fname[256];
    sprintf(fname, "C:\\%d-%d.yuv", w, h);
 
    HANDLE hFile = CreateFileA(fname,  (GENERIC_READ | GENERIC_WRITE), 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    d1 = WriteFile(hFile, pixels, w * h * 4, &dsize, NULL);
    CloseHandle(hFile);
     }

  if(time > 28.0 && time < 31.0) {
   char fname[256];
   int imgW;
   int imgH;
   imgW = FreeImage_GetWidth(fiBitmap);
   imgH = FreeImage_GetHeight(fiBitmap);
   sprintf(fname, "C:\\%06d.png", nseqno - 9);
 
   fiBitmap = FreeImage_ConvertFromRawBits((BYTE *)pixels, w, h, w * 4, 32, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0);
   FreeImage_Save(FIF_PNG, fiBitmap, fname);
   // FreeImage_Unload(fiBitmap);
  }

  nseqno++;
  }

posted on 2018-01-24 07:54  fanbird2008  阅读(333)  评论(0)    收藏  举报

导航