19,468
社区成员
发帖
与我相关
我的任务
分享
unknown.w //不明参数,取出即可,无需使用
width.w
height.w
depthRes.l
paletteFlag.l (bool)//这个值取出后主要用作bool运算
if paletteFlag
paletteEntry.w * 256
dataPos.l //这里取出一个值,表示从文件头开始的偏移值,这个偏移值后就开始是图形数据
imageCount.w //图片组,即开头说到的3
for imageCount
unknown1.l
if unknown1
unknown2.l
//上面这个fos循环主要是把流位置移正确,本身变量含义不用管
frameCount.w
for frameCount
top.w
left.w
bottom.w
right.w
flag.l
if flag & 8 == 0 // hasAlpha
length.l
dataOffset.l
if flag & 4 // hasBase
dataOffset.l
length.l
if flag & 1 // hasDepth
depthType.b //0指WORD / depthRes, 1指BYTE / depthRes, 2指步长 3指填充nearestDist。(看不明白)
val2.w
nearestDist.w
depthOffset.l
depthSize.l
unk2Length.l
if unk2Length
unk2offset.l
paletteIndex.b * (width * height)
rowSize1.l
for height
rowSize2.l
for width * height
data.w //0x7fff 至 555
rowSize = getLong();
for(int i=0; i<height; i++) {
rowSize2 = getLong();
rows[i] = (rowSize2 - rowSize) / 2;
rowSize = rowSize2;
}
for(int y=0; y<height; y++) {
x = 0;
for(int i=0; rows[y]<width; i++) {
data1 = getByte();
data2 = getByte();
for(int j=0; j<((data1 & 7) << 8 | data2); j++) {
data[x++ + y * width] = data1 & 0xf8;
}
}
}
return data;
data.w * (ceil(width / depthRes) * ceil(height / depthRes))
//WORD = short LONG = int byte = byte;
//调试用,写死目标文件名
string path = @"C:\test.dat";
//FileStream方式读取文件到缓冲区buff
FileStream test= new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader reader = new BinaryReader(test);
//文件头部分,一个文件只有一个文件头
short unknow = reader.ReadInt16();
short width = reader.ReadInt16();//这个貌似不是单个图片的宽度和高度,
short height = reader.ReadInt16();
int depthRes = reader.ReadInt32();
int paletteFlag = reader.ReadInt32();
short[] paletteEntry = new short[256];
if (paletteFlag > 0)
{
for (int pe = 0; pe < 256; pe++) //这里是我解读的,不知道对不对,原文写的是if paletteFlag paletteEntry.w * 256
{
paletteEntry[pe] = reader.ReadInt16();
}
}
int dataPos = reader.ReadInt32(); //文件头偏移值,表示这里开始是图片数据
short imageCount = reader.ReadInt16(); //图形组,值=3
//因为已经知道有297张图片,所以直接建数组来存
short[] top = new short[297];
short[] left = new short[297];
short[] bottom = new short[297];
short[] right = new short[297];
int[] flag = new int[297];
int[] hasAlpha = new int[297];
int[] alpha_legth = new int[297];
int[] alpha_dataOffset = new int[297];
int[] hasBase = new int[297];
int[] base_dataOffset = new int[297];
int[] base_length = new int[297];
int[] hasDepth = new int[297];
byte[] depthType = new byte[297];
short[] val2 = new short[297];
short[] nearestDist = new short[297];
int[] depthOffset = new int[297];
int[] depthSize = new int[297];
int[] unk2Length = new int[297];
int[] unk2Offset = new int[297];
//本来这里要for循环3次,遍历3个组,因为我们只取第一个组,所以取消,直接按顺序读
//unknown变量没有使用到,只是需要按逻辑读取,一面流的位置错误
int unknown1 = reader.ReadInt32();
if (unknown1 > 0)
{
int unknown2 = reader.ReadInt32();
}
short frameCount= reader.ReadInt16(); //每组图片的总数量,这里值为297
for (int n = 0; n < frameCount; n++)
{
top[n] = reader.ReadInt16(); //用着4个点算出来的距离,从值上来看刚好等于单个图片的尺寸
left[n] = reader.ReadInt16();
bottom[n] = reader.ReadInt16();
right[n] = reader.ReadInt16();
flag[n] = reader.ReadInt32(); //unknow point
hasAlpha[n] = flag[n] & 8; // 0:hasAlpha 1:noAlpha
if (hasAlpha[n] == 0)
{
alpha_legth[n] = reader.ReadInt32();
alpha_dataOffset[n] = reader.ReadInt32();
}
hasBase[n] = flag[n] & 4; //0:noBase 1:hasBase
if (hasBase[n] != 0)
{
base_dataOffset[n] = reader.ReadInt32();
base_length[n] = reader.ReadInt32();
}
hasDepth[n] = flag[n] & 1; //0:noDepth 1:hasDepth
if (hasDepth[n] != 0)
{
depthType[n] = reader.ReadByte();//0指WORD / depthRes, 1指BYTE / depthRes, 2指步长 3指填充nearestDist。(这个是网上找到的,具体意思不明)
val2[n] = reader.ReadInt16();
nearestDist[n] = reader.ReadInt16();
depthOffset[n] = reader.ReadInt32();
depthSize[n] = reader.ReadInt32();
}
unk2Length[n] = reader.ReadInt32();
if (unk2Length[n] > 0)
{
unk2Offset[n] = reader.ReadInt32();
}
if( m_cimage.IsNull() )
{
m_cimage.Create( imgw4, -imgh-1, 8 ); // 负高度表示原点在左上角,img.GetBits(); 得到数据区的起点。 // 20150310 imgw 改为imgw4 加宽的图像
RGBQUAD * pp = (RGBQUAD*)(theApp.palbuffer + 8 + sizeof(UINT)*2 /*+ (256*4+8)*3*/);
m_cimage.SetColorTable( 0, 256, pp );
}
LPBYTE p = (LPBYTE)m_cimage.GetBits();
LPWORD p2 = pimgdata1;
//const int w2 = (imgw + 0x3) & ~0x3; //?? 实际宽度是4的倍数?是否与操作系统或硬件有关。
WORD threshold = tbg_threshold ? roundint( tbg_threshold * kt * 0.95 ) : temperaturemin; // 背景和人体分界点
//ASSERT( !tbg_threshold );
int dd = temperaturemax - threshold; // 窗宽
if( dd < roundint(5 * kt) ) // 设置温差最小值为10度,防止除零、未初始化等等。
dd = roundint(5 * kt);
for( int i = 0; i < imgh; i++ ){
int j = 0;
for( ; j < imgw; j++ )
{
int w = (*p2++ - threshold) * 255 / dd;
if( w < 0 ) w = 0;
if( w > 255 ) w = 255;
*p++ = (BYTE)w;
}
for( ; j < imgw4; j++, p++ ); //?? 补齐多余的宽度?
}
m_cimage.StretchBlt( hDestDC, drc, orc, dwRop );