求C#图片重叠代码
如题,两张图片
string aPath = " ";a图路径
string bPath = " ";b图路径
string cPath = " ";重叠成c图,并保存到cPath
求GDI+原码,哪位达人贴一个
------解决方案--------------------Bitmap bp_a=new Bitmap(aPath);
Bitmap bp_b=new Bitmap(bPath);
Bitmap bp_c=new Bitmap(bp_a.Width,bp_a.Height);
Graphics theGrp = Graphics.FromImage(bp_c);
theGrp.DrawImage(bp_a,0,0,bp_a.Width,bp_a.Height);
theGrp.DrawImage(bp_b,x,y,w,h);
theGrp.Save();
theBit.Save(cPath);
------解决方案-------------------- public static void MadeIndex5(Bitmap NewPicture,Bitmap [] SmallPicture,int Distance_x,int Distance_y,int SmallWidth,int SmallHeight,int PictureHang,int PictureLie,int sort)
{
int w = NewPicture.Width,h = NewPicture.Height;
BitmapData[] PictureData = new BitmapData[sort];
System.IntPtr[] PictureScan = new IntPtr[sort];
int i = 0;
BitmapData NewData = NewPicture.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int Offset = NewData.Stride - w*3;
System.IntPtr Scan0 = NewData.Scan0;
for(i = 0;i < sort; i ++)
{
PictureData[i] = SmallPicture[i].LockBits(new Rectangle(0,0,SmallWidth,SmallHeight),ImageLockMode.ReadWrite,PixelFormat.Format24bppRgb);
PictureScan[i] = PictureData[i].Scan0;
}
int PictureOffset = PictureData[0].Stride - 3 * SmallWidth;
unsafe
{
byte *p =(byte *)(void *)Scan0;
byte *pause=(byte *)(void *)PictureScan[0];
int Hang=0,Lie=0;
i=0;
for(int j=0;j <h;j++)
{
for(int x=0;x <w;x++)
{
if((j> =(115+(Hang+1)*Distance_y+Hang*SmallHeight))&&(j <(115+(Hang+1)*(SmallHeight+Distance_y)))&&(x> =(19+(Lie+1)*Distance_x+Lie*SmallWidth))&&(x <(19+(Lie+1)*(SmallWidth+Distance_x))))
{
if((Hang*PictureLie+Lie) <sort)
{
p[2]=pause[2];
p[1]=pause[1];
p[0]=pause[0];
pause+=3;
}
if(x==(19+(Lie+1)*(SmallWidth+Distance_x)-1))
{
pause+=PictureOffset;
if((Hang*PictureLie+Lie) <sort)
PictureScan[Hang*PictureLie+Lie]=(IntPtr)pause;
Lie++;
if(Lie%PictureLie==0)
{
Lie=0;
if(j==(115+(Hang+1)*(SmallHeight+Distance_y)-1))
Hang++;
}
if((Hang*PictureLie+Lie) <sort)
pause=(byte *)(void *)PictureScan[Hang*PictureLie+Lie];
}
}
p+=3;
}
p+=Offset;
}
}
NewPicture.UnlockBits(NewData);
for(i=0;i <sort;i++)
SmallPicture[i].UnlockBits(PictureData[i]);
for(i=0;i <sort;i++)
SmallPicture[i].Dispose();
}