Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Graphics.DrawImage缩小显示的图像?_C#_Drawimage_Sizing - Fatal编程技术网

C# Graphics.DrawImage缩小显示的图像?

C# Graphics.DrawImage缩小显示的图像?,c#,drawimage,sizing,C#,Drawimage,Sizing,编辑:谢谢你的回复,我刚刚发现bmpSize修正了大小。我还根据Polotoix的建议添加了一个阵列。谢谢大家 使用Visual Studio开发游戏,这是使用C#进行编程的新手。我使用switch语句和Graphics.DrawImage方法从文本文件生成地图。图像缩放为24x24像素,画布为979x571。由于某些原因,我的图像显示得非常小。我尝试过使用给定的Graphics.DrawImage方法调整大小,但它只在一条瓷砖上创建缩放。((我也可以添加我试图实现的代码。尽量保持简短。) 我在

编辑:谢谢你的回复,我刚刚发现bmpSize修正了大小。我还根据Polotoix的建议添加了一个阵列。谢谢大家

使用Visual Studio开发游戏,这是使用C#进行编程的新手。我使用switch语句和Graphics.DrawImage方法从文本文件生成地图。图像缩放为24x24像素,画布为979x571。由于某些原因,我的图像显示得非常小。我尝试过使用给定的Graphics.DrawImage方法调整大小,但它只在一条瓷砖上创建缩放。((我也可以添加我试图实现的代码。尽量保持简短。)

我在地图上有一个更大的玩家对象作为大小参考,地图的大小应该像黄色的玩家一样大

                case 'W':
                    e.Graphics.DrawImage(Properties.Resources.wall, countCol, countRow);
                    countCol = countCol + 8;
                    break;
                case 'G':
                    e.Graphics.DrawImage(Properties.Resources.grass, countCol, countRow);
                    countCol = countCol + 8;
                    break;
                case 'P':
                    e.Graphics.DrawImage(Properties.Resources.player, countCol, countRow);
                    countCol = countCol + 8;
                    break;

将这些资源加载到集合或数组中。照现在的情况,你每次都要创建一个新的,而不是处理它们,因此你的应用程序正在泄漏查看图像的dpi分辨率值。在您绘制它们之前,它们需要与屏幕相同(即与e.Graphics.dpiXY相同)(除非您使用设置目标矩形的DrawImage重载)。谢谢您的所有响应,我刚刚发现bmpSize修复了大小。我还根据Polotoix的建议添加了一个阵列。谢谢大家!