GDI画图从右到左显示怎么实现

pgcat 2008-12-30 05:23:32
从左到右拉升显示
int width = this.MyBitmap.Width; //图像宽度
int height = this.MyBitmap.Height; //图像高度
Graphics g = this.panel1.CreateGraphics();g.Clear(Color.Gray); //初始为全灰色
for (int x = 1; x <= width; x++)
{
Bitmap bitmap=MyBitmap.Clone (new Rectangle
(0,0,x ,height),
System.Drawing .Imaging.PixelFormat .Format24bppRgb );
g.DrawImage (bitmap,0,0);
System.Threading.Thread.Sleep(10);
}
}
catch (Exception ex){MessageBox.Show(ex.Message, "信息提示");
}

从右到左 怎么实现呢 谢谢
...全文
98 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
bbbbbb888888 2008-12-30
  • 打赏
  • 举报
回复
2个循环就是可以吧,比较笨的方法
net5i 2008-12-30
  • 打赏
  • 举报
回复
注意这里:for (int x = width - 1; x >= 1; x--) 步进值是-1,倒着循环的
net5i 2008-12-30
  • 打赏
  • 举报
回复
Bitmap MyBitmap = Bitmap.FromFile("c:\\a.bmp") as Bitmap;
//改变图像大小为panel1的大小
MyBitmap = new Bitmap(MyBitmap, this.panel1.Size);
int width = MyBitmap.Width; //图像宽度
int height = MyBitmap.Height; //图像高度
Graphics g = this.panel1.CreateGraphics();
g.Clear(Color.Gray); //初始为全灰色
for (int x = width - 1; x >= 1; x--)
{
Bitmap bitmap = MyBitmap.Clone(new Rectangle
(x, 0, width - x, height),
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
g.DrawImage(bitmap, x, 0);
System.Threading.Thread.Sleep(10);
}

搂主这样运行就可以了,不妨试试。
pgcat 2008-12-30
  • 打赏
  • 举报
回复
谢谢 楼上 不过还是没反转过来 我代码是这样的
public void turnPageLeft(Image ims)
{
int width=ims.Width;
int height=ims.Height;
Bitmap MyBitmap=new Bitmap(ims,ims.Width,ims.Height);
Graphics g=this.pictureBox1.CreateGraphics();
g.Clear(Color.Gray);
for(int x=1;x<=width;x++)
{
Bitmap im=MyBitmap.Clone(new Rectangle(0,0,x,height),System.Drawing.Imaging.PixelFormat.Format24bppRgb);

g.FillRectangle(Brushes.Transparent,new Rectangle(0,0,x,height));
//g.DrawImage(im,new Rectangle(0,0,x,height),new Rectangle(0,0,x,height),GraphicsUnit.Pixel);
g.DrawImage(im,0,0);
//System.Threading.Thread.Sleep(1);
}
}
zgke 2008-12-30
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 zgke 的回复:]
for (int x = 1; x <= width; x++)
{
g.FillRectangle(Brushes.Transparent, new Rectangle(0, x, Width, Height));


}
[/Quote]

错了

for (int x = 1; x <= width; x++)
{
g.FillRectangle(Brushes.Transparent, new Rectangle(0, 0, X, Height));
}
zgke 2008-12-30
  • 打赏
  • 举报
回复
for (int x = 1; x <= width; x++)
{
g.FillRectangle(Brushes.Transparent, new Rectangle(0, x, Width, Height));


}
pgcat 2008-12-30
  • 打赏
  • 举报
回复
都是从左到右拉伸~
wzuomin 2008-12-30
  • 打赏
  • 举报
回复
呦,怎么发了这么多遍啊。
前两次没提示发贴成功呐。
h_w_king 2008-12-30
  • 打赏
  • 举报
回复
int width = this.MyBitmap.Width; //图像宽度
int height = this.MyBitmap.Height; //图像高度
Graphics g = this.panel1.CreateGraphics();
g.Clear(Color.Gray); //初始为全灰色
for (int x = 1; x <= width; x++)
{
g.DrawImage(MyBitmap, new Rectangle(0, 0, x, height), new Rectangle(0, 0, x, height), GraphicsUnit.Pixel);
Thread.Sleep(10);
}
zgke 2008-12-30
  • 打赏
  • 举报
回复
for (int x = 1; x <= width; x++)
{
g.FillRectangle(Brushes.Transparent, new Rectangle(width - i, 0, Width, Height));


}
没调试~~你测试下

110,532

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧