网上发现C#将图片转换层RGB32的byte的结果很少,找了很多代码,经过自己的多次调试,终于实现了。具体代码片段如下:
/// <summary>
/// Bitmap转换层RGB32
/// </summary>
/// <param name="Source">Bitmap图片</param>
/// <returns></returns>
public static byte[] GetRgb32_From_Bitmap(Bitmap Source)
{
bool bError = false;
string errorMsg = string.Empty;
return GetRgb32_From_Bitmap(Source, ref bError, ref errorMsg);
}
/// <summary>
/// Bitmap转换层RGB32
/// </summary>
/// <param name="Source">Bitmap图片</param>
/// <returns></returns>
public static byte[] GetRgb32_From_Bitmap(Bitmap Source, ref bool bError, ref string errorMsg)
{
bError = false;
int lPicWidth = Source.Width;