public void HandleBlock(string type, MLVTypes.mlv_rawi_hdr_t header, byte[] raw_data, int raw_pos, int raw_length) { RawiHeader = header; if (FileHeader.videoClass != 0x01) { return; } for (int pos = 0; pos < camMatrix.Length; pos++) { camMatrix[pos] = (float)header.raw_info.color_matrix1[2 * pos] / (float)header.raw_info.color_matrix1[2 * pos + 1]; } Bitunpack.BitsPerPixel = header.raw_info.bits_per_pixel; Debayer.Saturation = 0.12f; Debayer.Brightness = 1; Debayer.BlackLevel = header.raw_info.black_level; Debayer.WhiteLevel = header.raw_info.white_level; Debayer.CamMatrix = camMatrix; /* simple fix to overcome a mlv_dump misbehavior. it simply doesnt scale white and black level when changing bit depth */ while (Debayer.WhiteLevel > (1 << header.raw_info.bits_per_pixel)) { Debayer.BlackLevel >>= 1; Debayer.WhiteLevel >>= 1; } PixelData = new ushort[header.yRes, header.xRes]; RGBData = new float[header.yRes, header.xRes, 3]; CurrentFrame = new System.Drawing.Bitmap(RawiHeader.xRes, RawiHeader.yRes, PixelFormat.Format24bppRgb); LockBitmap = new LockBitmap(CurrentFrame); }