Draw an array of images

image_pdfimage_print


   
  
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class MainForm : Form {
    private Bitmap[] myImages = new Bitmap[3];
    public MainForm() {
        myImages[0] = new Bitmap("imageA.bmp");
        myImages[1] = new Bitmap("imageB.bmp");
        myImages[2] = new Bitmap("imageC.bmp");
    }

    protected void OnPaint(PaintEventArgs e) {
        Graphics g = e.Graphics;
        int yOffset = 10;
        foreach (Bitmap b in myImages) {
            g.DrawImage(b, 10, yOffset, 90, 90);
            yOffset += 100;
        }
    }
    public static void Main() {
        Application.Run(new MainForm());
    }
}

   
     


This entry was posted in 2D Graphics. Bookmark the permalink.