当构建位图并共同构建一些位图并将它们组合成一个位图时,.MakeTransparent() 是否有帮助。
或者,在我将位图发送到请求客户端之前,如果我 .MakeTransparent() 它会变小吗?不是宽度或高度,以字节为单位?
换句话说,.MakeTransparent() 将优化位图,如果没有,在通过互联网通过网络发送到请求客户端之前,是否有人获得有关如何优化位图的任何建议?
有问题的代码是sheet.MakeTransparent()
internal static Task<Bitmap> GetDoorSecheduleSheetAsync(ShopDrawing.DoorSchedules schedules, RotateFlipType rotate, byte schedulesPerSheet, byte currentI)
{
return Task.Run(() =>
{
var sheet = new Bitmap(DrawingOptions.PAGE_HEIGHT_SIZE, DrawingOptions.PAGE_WIDTH_SIZE);
sheet.SetResolution(150, 150);
byte scheduleCnt = 0;
float prevWidth = 0;
using (Graphics dc = Graphics.FromImage(sheet))
{
dc.Clear(Color.White);
using (Pen pen = new Pen(Color.FromArgb(80, Color.Black), 4))
{
for (; currentI < schedules.Count(); currentI++)
{
if (scheduleCnt > 0)
{
dc.DrawLine(pen, prevWidth, 380/*need constant for start height*/, prevWidth, sheet.Height);
};
using (var doorSchedule = schedules[currentI].Door)
{
dc.DrawImage(doorSchedule, prevWidth + 50, 380/*need constant for start height*/);
prevWidth += doorSchedule.Width + 50;
scheduleCnt++;
}
if (scheduleCnt == schedulesPerSheet)
{
sheet.RotateFlip(rotate);
sheet.MakeTransparent();
return sheet;
}
};
};
};
sheet.MakeTransparent();
sheet.RotateFlip(rotate);
return sheet;
});
}
谢谢!