| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 958 人关注过本帖
标题:[求助]图片百叶窗效果
只看楼主 加入收藏
wwx024
Rank: 1
等 级:新手上路
帖 子:33
专家分:4
注 册:2008-6-15
收藏
 问题点数:0 回复次数:2 
[求助]图片百叶窗效果
下面的代码可以实现垂直百叶窗显示效果,但不是图像百叶窗显示,而是先出现一个黑色的百叶窗显示,然后出现图片。
我要的结果是图片百叶窗显示,请大家帮我看看错在哪里了?

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();
        }   
    }
}
搜索更多相关主题的帖子: 百叶窗 效果 
2008-10-03 18:26
wwx024
Rank: 1
等 级:新手上路
帖 子:33
专家分:4
注 册:2008-6-15
收藏
得分:0 
2008-10-04 10:02
yihonggongzi
Rank: 2
等 级:论坛游民
帖 子:8
专家分:20
注 册:2010-5-15
收藏
得分:0 
  没时间看你的,下面的给你参考一下
try
            {
                Bitmap MyBitmap = (Bitmap)this.pbFill.Image.Clone();
                int dw = MyBitmap.Width / 30;
                int dh = MyBitmap.Height;
                Graphics g = this.pbFill.CreateGraphics();
                g.Clear(Color.Gray);
                Point[] MyPoint = new Point[30];
                for (int x = 0; x < 30; x++)
                {
                    MyPoint[x].Y = 0;
                    MyPoint[x].X = x * dw;
                }
                Bitmap bitmap = new Bitmap(MyBitmap.Width, MyBitmap.Height);
                for (int i = 0; i < dw; i++)
                {
                    for (int j = 0; j < 30; j++)
                    {
                        for (int k = 0; k < dh; k++)
                        {
                            bitmap.SetPixel(MyPoint[j].X + i, MyPoint[j].Y + k,
                            MyBitmap.GetPixel(MyPoint[j].X + i, MyPoint[j].Y + k));
                        }
                    }
                    this.pbFill.Refresh();
                    this.pbFill.Image = bitmap;
                    System.Threading.Thread.Sleep(200);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "信息提示");
            }
2010-08-03 10:45
快速回复:[求助]图片百叶窗效果
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034697 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved