110,534
社区成员
发帖
与我相关
我的任务
分享
Bitmap tagbit;//要处理的图片81*20
Bitmap[] subbits=new Bitmap[4];
int lefpix = 9, rightpix = 12;//左右要裁掉的空白宽度
Rectangle r = new Rectangle(lefpix, 0, tagbit.Width - rightpix - lefpix, tagbit.Height);//裁掉左右
Bitmap bit = tagbit.Clone(r, tagbit.PixelFormat);
int CovWidth = bit.Width / 4;//每张小图的宽度
int toppix = 4;
int Height = bit.Height - toppix-2;//去掉上下端空白后得到每个数字小图的高度
Rectangle r1 = new Rectangle(0, toppix, CovWidth, Height );
Rectangle r2 = new Rectangle(CovWidth, 2, CovWidth, Height );
Rectangle r3 = new Rectangle(CovWidth * 2, toppix, CovWidth, Height );
Rectangle r4 = new Rectangle(CovWidth * 3, 2, CovWidth, Height );
//四副等高等款且数字居中的小图。15×14
subbits[0] = bit.Clone(r1, bit.PixelFormat);
subbits[1] = bit.Clone(r2, bit.PixelFormat);
subbits[2] = bit.Clone(r3, bit.PixelFormat);
subbits[3] = bit.Clone(r4, bit.PixelFormat);
//取四幅图片的中心5*5
Rectangle rec = new Rectangle(5, 5, 5, 5);
for(int i=0;i<4;i++)
{
subbits[i]=subbits[i].Clone(rec, bit.PixelFormat);
}