【问题标题】:C# bitmap rows and columns helpC# 位图行和列帮助
【发布时间】:2011-04-17 21:23:41
【问题描述】:

我想要一个行和列的位图或图片(不确定),这样说如果我设置 10 行和 10 列,那么它必须构建一个类(不确定),其行和列的宽度为 10,高度为 10这样我就可以访问任何位置并在该框/位置的任何位置设置图像我该怎么做? 提前非常感谢

有点像我通过了

private printGrid(int x, int y) {
  // this function will print x rows and y columns such that each box's width is 10 px and height is 10px and also a way to modify any (x,y) in this to hold an image of 5px at later time
}

private insertImage(Image img, int x, int y) {
  // inserts the image in the xth row and yth column
}

我如何在 C# 中做到这一点?

【问题讨论】:

  • 您能改写一下吗?我不明白你想做什么......
  • 我想要的是一张动态制作的图片,它分为行和列,每个框的宽度为 10px,高度为 10px,我应该能够在 C# 中动态地将 5px 的图像插入任何框
  • 你的问题还不是很清楚,但似乎你需要的只是一个图像网格。是这样吗?你需要可视化这些图像吗?它是一个 WinForms 应用程序吗? WPF?银光? ASP.NET?如果是可视化问题,仅仅说你在使用 C# 通常是不够的。
  • 是的 C# windforms 中的图像网格

标签: c# bitmap grid location image


【解决方案1】:

所以您想将一张图片分成每个 10x10 的盒子,然后将另一个 5x5 的图片插入其中的任何一个盒子,然后让更改反映在原始图片上?你可以这样做:

void AddBox(int row, int col, Image mainImage, Image otherImage) {
     using(Graphics g = Graphics.FromImage(mainImage)) {
          g.DrawImage(otherImage, col * 10, row * 10);
     }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    • 2011-03-28
    • 2011-08-30
    • 2017-08-05
    • 2011-08-07
    相关资源
    最近更新 更多