我想将一幅GIF图像画到画板上,但是我想将GIF白色的区域透明的,应该如何来做,望高手指点!
解决方案 »
- SplitterDistance 必须在 Panel1MinSize 和 Width - Panel2MinSize 之间
- Datagridview如果查询没有信息怎么返回上一次查询的信息
- C#窗体在未被激活状态下截获键盘消息
- c# 怎么做 QQ那样的魔法表情
- 100求教!如何控制程序自动选择走哪个网络代理服务器?
- C#怎样把一个Bitmap以梯形的形状绘制在窗体上
- 有趣的问题,如何解析这个XML
- 如果有一个URL如http://www.google.com 用.net C#中的那个类的那个方法 可以得到网页的内容?
- 如何在DataGrid中不显示指定列中的重复值?
- 寻SQL Server 2000 Reporting Services
- 同样的方法执行btnPprt_Click事件,在VB6中进度条是活动的,事件过程中的函数AnalyseReport()也同时在处理,而转到C#,就连Timer1_Tick这个事件也不会激发了。看代码
- c# winform: 代码验证sql语句是否合法?
Public Class Form1 Private gif As Image = Nothing
Private pic As PictureBox = Nothing Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
pic = New PictureBox With {.Dock = DockStyle.Fill, .BorderStyle = BorderStyle.FixedSingle}
Me.Controls.Add(pic) Using ofd As New OpenFileDialog With {.Filter = "*.gif|*.gif"}
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
gif = Image.FromFile(ofd.FileName)
If ImageAnimator.CanAnimate(gif) Then
ImageAnimator.Animate(gif, New EventHandler(AddressOf gif_FrameChanged))
End If
End If
End Using
End Sub Private Sub gif_FrameChanged(ByVal sender As Object, ByVal e As EventArgs)
ImageAnimator.UpdateFrames(gif)
Using img As New Bitmap(gif)
img.MakeTransparent(Color.White)
pic.Image = img.Clone
End Using
End SubEnd Class
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{ private Image gif = null;
private PictureBox pic = null; public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
pic = new PictureBox { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle };
this.Controls.Add(pic); using (OpenFileDialog ofd = new OpenFileDialog { Filter = "*.gif|*.gif" })
{
if (ofd.ShowDialog() == DialogResult.OK)
{
gif = Image.FromFile(ofd.FileName);
if (ImageAnimator.CanAnimate(gif))
{
ImageAnimator.Animate(gif, new EventHandler(gif_FrameChanged));
}
}
} } private void gif_FrameChanged(object sender, EventArgs e)
{
ImageAnimator.UpdateFrames(gif);
using (Bitmap img = new Bitmap(gif))
{
img.MakeTransparent(Color.White);
pic.Image =(Image ) img.Clone();
}
} }
}