是否可以保存DWM_THUMBNAIL图像?

时间:2016-08-26 20:41:52

标签: c#

我尝试制作一个采用THUMBNAIL图像的程序,然后拍摄项目的屏幕截图。当我打开项目图像时,不存在THUMBNAIL图像。但是当我按下键盘上的“打印屏幕”按钮时,图像就可以了。

有人可以帮助我吗?

keyboard Screen Shot

1 个答案:

答案 0 :(得分:0)

    private void UpdateThumb()
    {
        if (thumb != IntPtr.Zero)
        {
            PSIZE size;
            DwmQueryThumbnailSourceSize(thumb, out size);

            DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES();

            props.fVisible = true;
            props.dwFlags = DWM_TNP_VISIBLE | DWM_TNP_RECTDESTINATION | DWM_TNP_OPACITY;
            props.opacity = (byte)opacity.Value;
            props.rcDestination = new Rect(image.Left, image.Top, image.Right, image.Bottom);

            if (size.x < image.Width)
                props.rcDestination.Right = props.rcDestination.Left + size.x;

            if (size.y < image.Height)
                props.rcDestination.Bottom = props.rcDestination.Top + size.y;


            DwmUpdateThumbnailProperties(thumb, ref props);
        }
    }