[求助]图片百叶窗效果
下面的代码可以实现垂直百叶窗显示效果,但不是图像百叶窗显示,而是先出现一个黑色的百叶窗显示,然后出现图片。我要的结果是图片百叶窗显示,请大家帮我看看错在哪里了?
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ImageShow
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//声明一个API函数
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest,
int nXDest,
int nYDest,
int nWidth,
int nHeight,
IntPtr hdcSrc,
int nXSrc,
int nYSrc,
System.Int32 dwRop
);
private void button1_Click(object sender, EventArgs e)
{
Bitmap myBitmap = new Bitmap(@"C:\weixinwang\f\csharp\pictures\cut tail machine.jpg");
Graphics g1 =Graphics.FromImage(myBitmap);
Graphics g2 = this.pictureBox1.CreateGraphics();
IntPtr dc1=g1.GetHdc();
IntPtr dc2=g2.GetHdc();
for (int j = 0; j < 18; j += 3)
{
for (int i = 0; i < myBitmap.Width + 3; i += 18)
{
int P3 = i + j;
BitBlt(dc2, P3, 0, 3, myBitmap.Height, dc1, P3, 0, 13369376);
}
this.pictureBox1.Image = myBitmap;
System.Threading.Thread.Sleep(50);
}
g1.Dispose();
g2.Dispose();
}
}
}