picturebox里能不能放两张图片,或者能不能制定图片picturebox具体显示的位置,具体到坐标

震我一下巧克力 2008-11-28 10:57:21
picturebox里能不能放两张图片,或者能不能制定图片picturebox具体显示的位置,具体到坐标

假如picturebox为640*480,图片为128*128,能不能制定图片在picturebox中位置的具体坐标
...全文
144 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
kelikeli521 2010-01-13
  • 打赏
  • 举报
回复
最好的方法就是把图片画在父窗体上,这样就ok了,再把picbox里面的图片做透明处理
  • 打赏
  • 举报
回复
我已经把两个GIF图片按流读取到一个字节数组中了(imby)
然后
MemoryStream ms = new MemoryStream(imby);
picCG.Image = Image.FromStream(ms);
现在遇到情况是,picCG中只显示imby第一个添加的图片

我的代码

byte[] imgbyte, imgbyte2;

FileStream fs = new FileStream("hero//Attack.gif", FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);

imgbyte = br.ReadBytes((int)fs.Length);

FileStream fs2 = new FileStream("monster//stand.gif", FileMode.Open, FileAccess.Read);
BinaryReader br2 = new BinaryReader(fs2);

imgbyte2 = br2.ReadBytes((int)fs2.Length);

byte[] imby = new byte[imgbyte.Length+imgbyte2.Length];

for (int i = 0; i < imgbyte.Length; i++)
{
imby[i] = imgbyte[i];
}
for (int i = imgbyte.Length; i < imgbyte2.Length + imgbyte.Length; i++)
{
imby[i] = imgbyte2[i - imgbyte.Length];
}

//for (int i = 0; i < imgbyte2.Length; i++)
//{
// imby[i] = imgbyte2[i];
//}
//for (int i = imgbyte2.Length; i < imgbyte.Length + imgbyte2.Length; i++)
//{
// imby[i] = imgbyte[i - imgbyte2.Length];
//}


MemoryStream ms = new MemoryStream(imby);

picCG.Image = Image.FromStream(ms);

只显示imby中第一个图片,这个怎么办
Tomato77 2008-11-30
  • 打赏
  • 举报
回复
up
  • 打赏
  • 举报
回复
人气这么低.......
  • 打赏
  • 举报
回复
来人解决啊...
是是非非 2008-11-29
  • 打赏
  • 举报
回复


在picturebox_Paint里面用 e.Graphics.DrawImage
  • 打赏
  • 举报
回复
这样放入picturebox中的图片,能不能设置图片在picturebox中的坐标?
pvgyetg 2008-11-29
  • 打赏
  • 举报
回复
一张里面放二张好像做不到,干嘛不放二个picturebox,调整下位置就可以了,
猿敲月下码 2008-11-29
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 fkago 的回复:]
引用 3 楼 thc1987 的回复:
可以先将图片转换成图片流的形式

再将流读入到字节数组里面

很高深的样子...
有没有个例子给我参考一下
[/Quote]

 #region  将图片转换成字节数组
public void Read_Image(OpenFileDialog openF, PictureBox MyImage) //
{

if (openF.ShowDialog(this) == DialogResult.OK) //如果打开了图片文件
{
try
{
MyImage.Image = System.Drawing.Image.FromFile(openF.FileName); //将图片文件存入到PictureBox控件中
string strimg = openF.FileName.ToString(); //记录图片的所在路径
FileStream fs = new FileStream(strimg, FileMode.Open, FileAccess.Read); //将图片以文件流的形式进行保存
BinaryReader br = new BinaryReader(fs);
imgByte = br.ReadBytes((int)fs.Length); //将流读入到字节数组中
}
catch
{
MessageBox.Show("您选择的图片不能被读取或文件类型不对!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
picBox.Image = null;
}
}
}
#endregion


     #region 显示图片
public void ShowData_Image(byte[] DI, PictureBox Ima) //显示数据库图片
{
byte[] buffer = DI;
MemoryStream ms = new MemoryStream(buffer);

Ima.Image = Image.FromStream(ms);
}
#endregion
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 thc1987 的回复:]
可以先将图片转换成图片流的形式

再将流读入到字节数组里面
[/Quote]
很高深的样子...
有没有个例子给我参考一下
猿敲月下码 2008-11-29
  • 打赏
  • 举报
回复
可以先将图片转换成图片流的形式

再将流读入到字节数组里面
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 pvgyetg 的回复:]
一张里面放二张好像做不到,干嘛不放二个picturebox,调整下位置就可以了,
[/Quote]
有特殊需要....

111,125

社区成员

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

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

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