Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. glTexSubImage2D(GL_TEXTURE_2D,0,0,0,widthGL,heightGL,
  2. GL_LUMINANCE,GL_UNSIGNED_BYTE,noise);
  3. //computation
  4. QImage mySurface(noise,widthGL,heightGL,QImage::Format_Indexed8);
  5. mySurface.save("test.bmp","BMP");
  6.  
  7. static unsigned char* mbuffer = new unsigned char[3*widthGL*heightGL];
  8. for (int i = 0,bpos=0;i<widthGL*heightGL;i++)
  9. {
  10. mbuffer[bpos++]=noise[i];
  11. mbuffer[bpos++]=noise[i];
  12. mbuffer[bpos++]=noise[i];
  13. }
  14. QImage mySurface(mbuffer,widthGL,heightGL,QImage::Format_RGB888);
  15.  
  16. glTexSubImage2D(GL_TEXTURE_2D,0,0,0,widthGL,heightGL,GL_LUMINANCE,GL_UNSIGNED_BYTE,noise);
  17. //computation
  18. QVector<QRgb> colorTable(256); //our grayscale palette
  19. QImage mySurface(noise,widthGL,heightGL,QImage::Format_Indexed8);
  20. for (int i = 0; i < 256; ++i)
  21. colorTable[i] = qRgb(i, i, i); //build palette
  22. mySurface.setColorCount(256);
  23. mySurface.setColorTable(colorTable);
  24. mySurface.save("test.bmp","BMP");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement