非淡泊无以明志,非宁静无以致远 -心静如止水,动于静

从JPG中获取缩略图

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

using System.Net;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            string p = "s.JPG";
            Image i = Image.FromFile ( p );
            Image tn = i.GetThumbnailImage(50, 50, null, IntPtr.Zero);  // <=>(IntPtr)0
            e.Graphics.DrawImage(tn, 100, 0, tn.Width, tn.Height);

            e.Graphics.Dispose();
        }
    }
}

 

posted @ 2015-05-28 11:28  烟雨客  阅读(1526)  评论(0编辑  收藏  举报