Tag: 内存图片

避免一次又一次地创建PictureBoxes

我有以下问题。 我的目的是在Windows窗体中从右向左移动多个图像。 下面的代码非常好用。 困扰我的是,每次创建PictureBox对象时,此过程都会占用大量内存。 每个图像从右到左不间断地跟随前一图像。 图像显示从一侧移动到另一侧的天空。 它应该看起来像一架飞机在空中飞舞。 如何避免使用太多内存? 我可以用PaintEvent和GDI做些什么吗? 我对图形编程不太熟悉。 using System; using System.Drawing; using System.Windows.Forms; using System.Collections.Generic; public class Background : Form { private PictureBox sky, skyMove; private Timer moveSky; private int positionX = 0, positionY = 0, width, height; private List consecutivePictures; public Background(int width, int height) { this.width = width; this.height = […]