Tag: image manipulation

使用libpng将OpenGL屏幕像素保存到PNG

我一直在使用SOIL来保存图像作为BMP,但事实certificateSOIL(或stbi更具体)可以节省~5MB图像(大约1366×768分辨率图像或更多),这非常疯狂。 原始BMP保存代码( 注意一切都在渲染function中完成): uint8_t *pixels = new uint8_t[w * h * 3]; // copy pixels from screen glBindTexture(GL_TEXTURE_2D, screenTex); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, w, h); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *)pixels); // invert pixels (stolen from SOILs source code) for (int j = 0; j * 2 0; –i) […]