Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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#如何操作图像数组_C#_Arrays - Fatal编程技术网

c#如何操作图像数组

c#如何操作图像数组,c#,arrays,C#,Arrays,我有17个不同的图像正在被洗牌,然后从字符串数组ImgLocation加载到图像数组Deck。在此之后,我将图像添加到picturebox数组Holder 因此,我想知道如何在位置Deck[0]处获得名为“3.png”的示例图像。我试图使用位图,但这不是工作的方式,因为它可能会创建一个重复,我不希望这样。有办法做到这一点吗 for (i = ImgLocation.Length; i > 0; i--) { int j = r.Next(i); va

我有17个不同的图像正在被洗牌,然后从字符串数组
ImgLocation
加载到图像数组
Deck
。在此之后,我将图像添加到picturebox数组
Holder

因此,我想知道如何在位置
Deck[0]
处获得名为“3.png”的示例图像。我试图使用位图,但这不是工作的方式,因为它可能会创建一个重复,我不希望这样。有办法做到这一点吗

   for (i = ImgLocation.Length; i > 0; i--)
   {
       int j = r.Next(i);
       var k = ImgLocation[j];
       ImgLocation[j] = ImgLocation[i - 1];
       ImgLocation[i - 1] = k;
   }
 for (i = 0; i < 17; i++)
 {
   Deck[i] = Image.FromFile(ImgLocation[i]);

   Bitmap card1 = new Bitmap("Assets\\Cards\\3.png");
   Bitmap card2 = new Bitmap("Assets\\Cards\\11.png");
   Bitmap card3 = new Bitmap("Assets\\Cards\\15.png");
   Bitmap card4 = new Bitmap("Assets\\Cards\\27.png");
   Bitmap card5 = new Bitmap("Assets\\Cards\\33.png");

   Holder[12].Image = card1;
   Holder[13].Image = card2;
   Holder[14].Image = card3;
   Holder[15].Image = card4;
   Holder[16].Image = card5;
}
for(i=ImgLocation.Length;i>0;i--)
{
int j=r.Next(i);
var k=语言[j];
ImgLocation[j]=ImgLocation[i-1];
i位置[i-1]=k;
}
对于(i=0;i<17;i++)
{
Deck[i]=Image.FromFile(ImgLocation[i]);
位图card1=新位图(“资产\\Cards\\3.png”);
位图card2=新位图(“资产\\Cards\\11.png”);
位图card3=新位图(“资产\\Cards\\15.png”);
位图card4=新位图(“资产\\Cards\\27.png”);
位图card5=新位图(“资产\\Cards\\33.png”);
支架[12]。图像=card1;
支架[13]。图像=卡片2;
支架[14]。图像=卡片3;
支架[15]。图像=卡片4;
支架[16]。图像=卡片5;
}

试试这样的方法。对甲板进行排序,而不是对图像进行排序

    public partial class Form1 : Form
    {
        List<card> deck = new List<card>();
        public Form1()
        {
            InitializeComponent();
        }
    }
       public class card
    {
           string suit { get; set; }
           int rank { get; set; }
           Bitmap image { get; set; }
    }
​
公共部分类表单1:表单
{
列表组=新列表();
公共表格1()
{
初始化组件();
}
}
公务舱卡
{
字符串套装{get;set;}
int秩{get;set;}
位图图像{get;set;}
}
​

我已经读了你的问题十遍了,但我仍然不知道你的问题是什么,也不知道你想要什么。我想在我的picturebox数组“Holder”的特定索引处获得特定图像。我从字符串数组imglocation中获得图像位置。这是你的实际代码吗?您是否在循环17次(创建85个位图)中从磁盘加载5个位图?我删除了一些代码,因为它与主题无关,而且没有循环17次
队列如何?您可以将其出列,不会显示重复的图像。