110,502
社区成员
发帖
与我相关
我的任务
分享
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet=CharSet.Auto)]
extern static bool DestroyIcon(IntPtr handle);
private void GetHicon_Example(PaintEventArgs e)
{
// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap(@"c:\FakePhoto.jpg");
// Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap, 0, 0);
// Get an Hicon for myBitmap.
IntPtr Hicon = myBitmap.GetHicon();
// Create a new icon from the handle.
Icon newIcon = Icon.FromHandle(Hicon);
// Set the form Icon attribute to the new icon.
this.Icon = newIcon;
// Destroy the Icon, since the form creates
// its own copy of the icon.
DestroyIcon(newIcon.Handle);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
using (OpenFileDialog of = new OpenFileDialog())
{
if (of.ShowDialog() == DialogResult.OK)
{
//pictureBox1.Image = Image.FromFile(of.FileName);
Icon icon = new Icon(of.FileName);
icon.Save(stream);
}
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
using (OpenFileDialog of = new OpenFileDialog())
{
if (of.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(of.FileName);
}
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
using (OpenFileDialog of = new OpenFileDialog())
{
if (of.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(of.FileName);
}
}
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
pictureBox1.ImageLocation = "D:\\VS08code\\NET_Test\\Draw\\Blackqi.jpg";
pictureBox1.BringToFront();
}