private bool ReadDat(string file, out byte[] outData, EnumCALTarget style) { outData = null; if (style == EnumCALTarget.Cabinet) { int len = (_cabinetWidth * 18 + 10) * _cabinetHeight; outData = new byte[len]; int readLen = 0; FileStream reader = null; try { reader = new FileStream(file, FileMode.Open, FileAccess.Read); if (reader.Length == len) { readLen = reader.Read(outData, 0, len);//读取整个纯校正文件 } else { reader.Close();//关闭文件 outData = null; return(false); } } catch { outData = null; return(false); } reader.Close(); } else if (style == EnumCALTarget.Module) { int len = (_modulePixelWidth * 18 + 10) * _modulePixelHeight; outData = new byte[len]; int readLen = 0; FileStream reader = null; try { reader = new FileStream(file, FileMode.Open, FileAccess.Read); if (reader.Length == len) { readLen = reader.Read(outData, 0, len);//读取整个纯校正文件 } else { reader.Close();//关闭文件 outData = null; return(false); } } catch { outData = null; return(false); } reader.Close(); } return(true); }
} //箱体高度 private bool ReadZDat(string file, out byte[] outData, EnumCALTarget style) { if (style == EnumCALTarget.Cabinet) { int len = _cabinetWidth * _cabinetHeight * 16; FileStream fsIn = new FileStream(file, FileMode.Open); if (fsIn.Length != len) { outData = null; fsIn.Close(); return(false); } outData = new byte[len]; //读取整个文件 if (fsIn.Read(outData, 0, outData.Length) != outData.Length) { fsIn.Close(); return(false); } fsIn.Close();//关闭文件 return(true); } else if (style == EnumCALTarget.Module) { int len = _modulePixelWidth * _modulePixelHeight * 16; FileStream fsIn = new FileStream(file, FileMode.Open); if (fsIn.Length != len) { outData = null; fsIn.Close(); return(false); } outData = new byte[len]; //读取整个文件 if (fsIn.Read(outData, 0, outData.Length) != outData.Length) { fsIn.Close(); return(false); } fsIn.Close();//关闭文件 return(true); } outData = null; return(false); }
private bool ConvertDatToSDat(byte[] src, out byte[] target, EnumCALTarget style) { int width = 0; int height = 0; target = null; if (style == EnumCALTarget.Cabinet) { width = _cabinetWidth; height = _cabinetHeight; } else if (style == EnumCALTarget.Module) { width = _modulePixelWidth; height = _modulePixelHeight; } else { return(false); } target = new byte[width * height * 18]; int len = width * 18; int offset = 9; int offset1 = 0; for (int row = 0; row < height; row++) { Array.Copy(src, offset, target, offset1, len); if (row < height - 1) { offset += len + 9 + 1;//9为前导数据,1为最后一位校验和 } else { //最后一行不需要再移动9字节 offset += 0; } offset1 += len; } return(true); }
private bool ConvertDatToZDat(byte[] src, out byte[] target, EnumCALTarget style) { int width = 0; int height = 0; target = null; if (style == EnumCALTarget.Cabinet) { width = _cabinetWidth; height = _cabinetHeight; } else if (style == EnumCALTarget.Module) { width = _modulePixelWidth; height = _modulePixelHeight; } else { return(false); } if (ConvertDatToSDat(src, out byte[] sDat, style) == false)
private bool ConvertZDatToSDat(byte[] src, out byte[] target, EnumCALTarget style) { int width = 0; int height = 0; target = null; if (style == EnumCALTarget.Cabinet) { width = _cabinetWidth; height = _cabinetHeight; } else if (style == EnumCALTarget.Module) { width = _modulePixelWidth; height = _modulePixelHeight; } else { return(false); } int nNewLen = width * height * 18;//sdat文件大小 target = new byte[nNewLen]; int points = width * height; //像素点数 byte[] pt = new Byte[16]; //zdat一个像素的数据 ushort tmp = 0; int nLeftMove = 5;//左移的位数 2017-11-16 nLeftMove = nLeftMove + 1; for (int i = 0; i < points; i++) { //获取一个像素的数据 Array.Copy(src, i * 16, pt, 0, 16); target[i * 18] = pt[0]; target[i * 18 + 1] = pt[1];//R1 主色 tmp = (ushort)(pt[2] << nLeftMove); target[i * 18 + 2] = tmp.HByte(); target[i * 18 + 3] = tmp.LByte();//R2 tmp = (ushort)(pt[3] << nLeftMove); target[i * 18 + 4] = tmp.HByte(); target[i * 18 + 5] = tmp.LByte();//R3 tmp = (ushort)(pt[4] << nLeftMove); target[i * 18 + 6] = tmp.HByte(); target[i * 18 + 7] = tmp.LByte();//G1 target[i * 18 + 8] = pt[5]; target[i * 18 + 9] = pt[6];//G2 主色 tmp = (ushort)(pt[7] << nLeftMove); target[i * 18 + 10] = tmp.HByte(); target[i * 18 + 11] = tmp.LByte();//G3 tmp = (ushort)(pt[8] << nLeftMove); target[i * 18 + 12] = tmp.HByte(); target[i * 18 + 13] = tmp.LByte();//B1 tmp = (ushort)(pt[9] << nLeftMove); target[i * 18 + 14] = tmp.HByte(); target[i * 18 + 15] = tmp.LByte();//B2 target[i * 18 + 16] = pt[10]; target[i * 18 + 17] = pt[11];//B3 主色 } return(true); }