首页 > 解决方案 > 将图像放入绘图网格的特定单元格

问题描述

我正在delpi中制作connect 4游戏。我需要根据用户单击的位置将正确的彩色圆圈放在正确的位置。您如何将图像(最好是JPEG)加载到特定单元格中?

我不知道从哪里开始(因为我的老师没用哈哈)所以任何帮助都会非常感激。!

在表单上创建:

 images:=timagelist.Create(self);
 image1:=tjpegimage.Create;
 image2:=tjpegimage.Create;
 bimage1:=tbitmap.Create;
 bimage2:=tbitmap.Create;
try
image1.loadfromfile('red.jpg') ;
bimage1.Assign(image1);
image2.loadfromfile('yellow.jpg') ;
bimage2.Assign(image2);
finally
  image1.free;
  image2.free;
end;
images.Add(bimage1,nil);
images.Add(bimage2,nil) ;

在drawcell上:

  row:=c4grid.Row;
col:=c4grid.Col;
images.Draw(c4grid.Canvas,row,col,0);

到目前为止,没有任何反应,也没有证据表明您实际上可以单击该单元格。任何帮助/建议/指导将不胜感激!

标签: delphipascallazarus

解决方案


推荐阅读