【发布时间】:2018-09-29 08:14:46
【问题描述】:
我想从 OpenTK 中的当前场景中以良好的分辨率获取屏幕截图。我正在使用 GL.ReadPixels 获取场景的照片。如果我将照片保存到磁盘;我发现它的分辨率/质量很低。
以下 C# 代码用于获取场景照片:
位图 bmp = null;
if (GraphicsContext.CurrentContext != null)
{
glControl_window.Invalidate();
int w = glControl_window.ClientSize.Width;
int h = glControl_window.ClientSize.Height;
bmp = new Bitmap(w, h);
System.Drawing.Imaging.BitmapData data =
bmp.LockBits(glControl_window.ClientRectangle,
System.Drawing.Imaging.ImageLockMode.ReadWrite,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
GL.ReadPixels(0, 0, w, h, OpenTK.Graphics.OpenGL.PixelFormat.Bgr,
PixelType.UnsignedByte, data.Scan0);
bmp.UnlockBits(data);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
}
在初始化 OpenTK 时使用:
this.glControl_window = new OpenTK.GLControl(new
OpenTK.Graphics.GraphicsMode(new OpenTK.Graphics.ColorFormat(32),
24,8,4,new OpenTK.Graphics.ColorFormat(0),2,false));
我使用 OpenTK 的 resize 事件:
GL.Viewport(0, 0, Width, Height);
我使用 OpenTK 的绘制事件(通过鼠标启用放大/缩小):
float aspectRatio;
if (Height == 0 || Width == 0) aspectRatio = 1f; else
aspectRatio = Width / (float)Height;
double W = 20 * aspectRatio / CameraZoomScale, H = 20 /
CameraZoomScale;
GL.Ortho(-0.5 * W, 0.5 * W, -0.5 * H, 0.5 * H, -600.0f, 600.0f);
我需要:
1.在 GL.ReadPixels 期间增加令牌屏幕截图的分辨率。
【问题讨论】:
-
另一个问题被搁置了!
-
@AhmedShaban 如果您回过头来阅读它被搁置的原因,您会发现如果您阅读并理解了stackoverflow.com/help/how-to-ask 准则,那么您会发现这是有问题的。在这种特定情况下,您最好发布两个问题。一个是关于如何使用 GLReadPixels 增加读取的像素数量,另一个是关于如何从磁盘升级和打印图像。如果这些问题都没有得到回答,我会感到惊讶。
-
好的。谢谢。在旧帖子中;我没有找到孔的原因。我将这个问题修改为删除关于打印比例的问题。
标签: opengl printing screenshot resolution opentk